From 64b29dc9d4fbae86f926d34acebda6dceb5ee457 Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Tue, 24 May 2022 15:45:36 +0800 Subject: [PATCH 1/6] Add marketplace SDK --- .../vendored_sdks/marketplace/__init__.py | 16 + .../marketplace/_configuration.py | 73 ++++ .../marketplace/_marketplace_rp_service.py | 120 ++++++ .../vendored_sdks/marketplace/_version.py | 8 + .../vendored_sdks/marketplace/aio/__init__.py | 10 + .../marketplace/aio/_configuration.py | 69 ++++ .../aio/_marketplace_rp_service.py | 119 ++++++ .../vendored_sdks/marketplace/models.py | 7 + .../vendored_sdks/marketplace/py.typed | 1 + .../marketplace/v2018_08_01_beta/__init__.py | 18 + .../v2018_08_01_beta/_configuration.py | 78 ++++ .../_marketplace_rp_service.py | 102 +++++ .../v2018_08_01_beta/_metadata.json | 114 ++++++ .../marketplace/v2018_08_01_beta/_patch.py | 31 ++ .../marketplace/v2018_08_01_beta/_vendor.py | 27 ++ .../marketplace/v2018_08_01_beta/_version.py | 9 + .../v2018_08_01_beta/aio/__init__.py | 15 + .../v2018_08_01_beta/aio/_configuration.py | 74 ++++ .../aio/_marketplace_rp_service.py | 95 +++++ .../v2018_08_01_beta/aio/_patch.py | 31 ++ .../aio/operations/__init__.py | 13 + .../aio/operations/_offer_operations.py | 100 +++++ .../v2018_08_01_beta/models/__init__.py | 40 ++ .../v2018_08_01_beta/models/_models.py | 330 ++++++++++++++++ .../v2018_08_01_beta/models/_models_py3.py | 357 ++++++++++++++++++ .../v2018_08_01_beta/operations/__init__.py | 13 + .../operations/_offer_operations.py | 149 ++++++++ .../marketplace/v2018_08_01_beta/py.typed | 1 + 28 files changed, 2020 insertions(+) create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/__init__.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/_configuration.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/_marketplace_rp_service.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/_version.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/aio/__init__.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/aio/_configuration.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/aio/_marketplace_rp_service.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/models.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/py.typed create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/__init__.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_configuration.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_marketplace_rp_service.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_metadata.json create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_patch.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_vendor.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_version.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/__init__.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_configuration.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_marketplace_rp_service.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_patch.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/__init__.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/_offer_operations.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/__init__.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models_py3.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/__init__.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/_offer_operations.py create mode 100644 src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/py.typed diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/__init__.py b/src/spring/azext_spring/vendored_sdks/marketplace/__init__.py new file mode 100644 index 00000000000..027c248725a --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._marketplace_rp_service import MarketplaceRPService +__all__ = ['MarketplaceRPService'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/_configuration.py b/src/spring/azext_spring/vendored_sdks/marketplace/_configuration.py new file mode 100644 index 00000000000..1ee87a11353 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/_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. +# -------------------------------------------------------------------------- +from typing import 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 TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +class MarketplaceRPServiceConfiguration(Configuration): + """Configuration for MarketplaceRPService. + + 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. + :type credential: ~azure.core.credentials.TokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + market="US", # type: Optional[str] + include_stop_sold_plans="true", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(MarketplaceRPServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.market = market + self.include_stop_sold_plans = include_stop_sold_plans + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-marketplace/{}'.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/src/spring/azext_spring/vendored_sdks/marketplace/_marketplace_rp_service.py b/src/spring/azext_spring/vendored_sdks/marketplace/_marketplace_rp_service.py new file mode 100644 index 00000000000..910eedcdc10 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/_marketplace_rp_service.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.mgmt.core import ARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin + +from ._configuration import MarketplaceRPServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class MarketplaceRPService(MultiApiClientMixin, _SDKClient): + """REST APIs for Azure Marketplace. + + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + 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. + :type credential: ~azure.core.credentials.TokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str + :param base_url: Service URL + :type base_url: str + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + """ + + DEFAULT_API_VERSION = '2018-08-01-beta' + _PROFILE_TAG = "azure.mgmt.marketplace.MarketplaceRPService" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + + def __init__( + self, + credential, # type: "TokenCredential" + market="US", # type: Optional[str] + include_stop_sold_plans="true", # type: Optional[str] + api_version=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str + profile=KnownProfiles.default, # type: KnownProfiles + **kwargs # type: Any + ): + self._config = MarketplaceRPServiceConfiguration(credential, "US", "true", **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(MarketplaceRPService, self).__init__( + api_version=api_version, + profile=profile + ) + + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: + + * 2018-08-01-beta: :mod:`v2018_08_01_beta.models` + """ + if api_version == '2018-08-01-beta': + from .v2018_08_01_beta import models + return models + raise ValueError("API version {} is not available".format(api_version)) + + @property + def offer(self): + """Instance depends on the API version: + + * 2018-08-01-beta: :class:`OfferOperations` + """ + api_version = self._get_api_version('offer') + if api_version == '2018-08-01-beta': + from .v2018_08_01_beta.operations import OfferOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'offer'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + def close(self): + self._client.close() + def __enter__(self): + self._client.__enter__() + return self + def __exit__(self, *exc_details): + self._client.__exit__(*exc_details) diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/_version.py b/src/spring/azext_spring/vendored_sdks/marketplace/_version.py new file mode 100644 index 00000000000..a30a458f8b5 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/_version.py @@ -0,0 +1,8 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" \ No newline at end of file diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/aio/__init__.py b/src/spring/azext_spring/vendored_sdks/marketplace/aio/__init__.py new file mode 100644 index 00000000000..d294a30c210 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._marketplace_rp_service import MarketplaceRPService +__all__ = ['MarketplaceRPService'] diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/aio/_configuration.py b/src/spring/azext_spring/vendored_sdks/marketplace/aio/_configuration.py new file mode 100644 index 00000000000..d114aa2f027 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/aio/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Optional, 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 TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class MarketplaceRPServiceConfiguration(Configuration): + """Configuration for MarketplaceRPService. + + 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + market: Optional[str] = "US", + include_stop_sold_plans: Optional[str] = "true", + **kwargs # type: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(MarketplaceRPServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.market = market + self.include_stop_sold_plans = include_stop_sold_plans + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-marketplace/{}'.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/src/spring/azext_spring/vendored_sdks/marketplace/aio/_marketplace_rp_service.py b/src/spring/azext_spring/vendored_sdks/marketplace/aio/_marketplace_rp_service.py new file mode 100644 index 00000000000..556e3442d4a --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/aio/_marketplace_rp_service.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, 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 ._configuration import MarketplaceRPServiceConfiguration + +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): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class MarketplaceRPService(MultiApiClientMixin, _SDKClient): + """REST APIs for Azure Marketplace. + + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str + :param base_url: Service URL + :type base_url: str + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + """ + + DEFAULT_API_VERSION = '2018-08-01-beta' + _PROFILE_TAG = "azure.mgmt.marketplace.MarketplaceRPService" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + + def __init__( + self, + credential: "AsyncTokenCredential", + market: Optional[str] = "US", + include_stop_sold_plans: Optional[str] = "true", + api_version: Optional[str] = None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles = KnownProfiles.default, + **kwargs # type: Any + ) -> None: + self._config = MarketplaceRPServiceConfiguration(credential, market, include_stop_sold_plans, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(MarketplaceRPService, self).__init__( + api_version=api_version, + profile=profile + ) + + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: + + * 2018-08-01-beta: :mod:`v2018_08_01_beta.models` + """ + if api_version == '2018-08-01-beta': + from ..v2018_08_01_beta import models + return models + raise ValueError("API version {} is not available".format(api_version)) + + @property + def offer(self): + """Instance depends on the API version: + + * 2018-08-01-beta: :class:`OfferOperations` + """ + api_version = self._get_api_version('offer') + if api_version == '2018-08-01-beta': + from ..v2018_08_01_beta.aio.operations import OfferOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'offer'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + async def close(self): + await self._client.close() + async def __aenter__(self): + await self._client.__aenter__() + return self + async def __aexit__(self, *exc_details): + await self._client.__aexit__(*exc_details) diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/models.py b/src/spring/azext_spring/vendored_sdks/marketplace/models.py new file mode 100644 index 00000000000..9c020db9776 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/models.py @@ -0,0 +1,7 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from .v2018_08_01_beta.models import * diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/py.typed b/src/spring/azext_spring/vendored_sdks/marketplace/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/__init__.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/__init__.py new file mode 100644 index 00000000000..d495e51aad2 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._marketplace_rp_service import MarketplaceRPService +from ._version import VERSION + +__version__ = VERSION +__all__ = ['MarketplaceRPService'] + +# `._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() diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_configuration.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_configuration.py new file mode 100644 index 00000000000..f9b0855dbd8 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_configuration.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import 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 TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + + +class MarketplaceRPServiceConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for MarketplaceRPService. + + 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. + :type credential: ~azure.core.credentials.TokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + :keyword api_version: Api Version. Default value is "2018-08-01-beta". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + market="US", # type: Optional[str] + include_stop_sold_plans="true", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + super(MarketplaceRPServiceConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-08-01-beta") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.market = market + self.include_stop_sold_plans = include_stop_sold_plans + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-marketplace/{}'.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/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_marketplace_rp_service.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_marketplace_rp_service.py new file mode 100644 index 00000000000..20b0aa0e682 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_marketplace_rp_service.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import MarketplaceRPServiceConfiguration +from .operations import OfferOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + +class MarketplaceRPService(object): + """REST APIs for Azure Marketplace. + + :ivar offer: OfferOperations operations + :vartype offer: azure.mgmt.marketplace.v2018_08_01_beta.operations.OfferOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-08-01-beta". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + market="US", # type: Optional[str] + include_stop_sold_plans="true", # type: Optional[str] + base_url="https://management.azure.com", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + self._config = MarketplaceRPServiceConfiguration(credential=credential, market="US", include_stop_sold_plans="true", **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.offer = OfferOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> 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/python/protocol/quickstart + + :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: () -> MarketplaceRPService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_metadata.json b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_metadata.json new file mode 100644 index 00000000000..3f64ec7d6af --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_metadata.json @@ -0,0 +1,114 @@ +{ + "chosen_version": "2018-08-01-beta", + "total_api_version_list": ["2018-08-01-beta"], + "client": { + "name": "MarketplaceRPService", + "filename": "_marketplace_rp_service", + "description": "REST APIs for Azure Marketplace.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MarketplaceRPServiceConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MarketplaceRPServiceConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "market": { + "signature": "market=\"US\", # type: Optional[str]", + "description": "The Market to use for the request. Default value is \"US\".", + "docstring_type": "str", + "required": false + }, + "include_stop_sold_plans": { + "signature": "include_stop_sold_plans=\"true\", # type: Optional[str]", + "description": "The Market to use for the request. Default value is \"true\".", + "docstring_type": "str", + "required": false + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "market": { + "signature": "market: Optional[str] = \"US\",", + "description": "The Market to use for the request. Default value is \"US\".", + "docstring_type": "str", + "required": false + }, + "include_stop_sold_plans": { + "signature": "include_stop_sold_plans: Optional[str] = \"true\",", + "description": "The Market to use for the request. Default value is \"true\".", + "docstring_type": "str", + "required": false + } + }, + "constant": { + }, + "call": "credential, market, include_stop_sold_plans", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"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\", \"Optional\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "offer": "OfferOperations" + } +} \ No newline at end of file diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_patch.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_patch.py new file mode 100644 index 00000000000..74e48ecd07c --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_vendor.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_vendor.py new file mode 100644 index 00000000000..138f663c53a --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_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/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_version.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_version.py new file mode 100644 index 00000000000..e5754a47ce6 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/__init__.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/__init__.py new file mode 100644 index 00000000000..b616b046b07 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._marketplace_rp_service import MarketplaceRPService +__all__ = ['MarketplaceRPService'] + +# `._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() diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_configuration.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_configuration.py new file mode 100644 index 00000000000..f6f73f02673 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_configuration.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, 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 TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MarketplaceRPServiceConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for MarketplaceRPService. + + 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + :keyword api_version: Api Version. Default value is "2018-08-01-beta". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + market: Optional[str] = "US", + include_stop_sold_plans: Optional[str] = "true", + **kwargs: Any + ) -> None: + super(MarketplaceRPServiceConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-08-01-beta") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.market = market + self.include_stop_sold_plans = include_stop_sold_plans + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-marketplace/{}'.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/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_marketplace_rp_service.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_marketplace_rp_service.py new file mode 100644 index 00000000000..5dc70c4de80 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_marketplace_rp_service.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Optional, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import MarketplaceRPServiceConfiguration +from .operations import OfferOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class MarketplaceRPService: + """REST APIs for Azure Marketplace. + + :ivar offer: OfferOperations operations + :vartype offer: azure.mgmt.marketplace.v2018_08_01_beta.aio.operations.OfferOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param market: The Market to use for the request. Default value is "US". + :type market: str + :param include_stop_sold_plans: The Market to use for the request. Default value is "true". + :type include_stop_sold_plans: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-08-01-beta". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + market: Optional[str] = "US", + include_stop_sold_plans: Optional[str] = "true", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MarketplaceRPServiceConfiguration(credential=credential, market=market, include_stop_sold_plans=include_stop_sold_plans, **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.offer = OfferOperations(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/python/protocol/quickstart + + :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) -> "MarketplaceRPService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_patch.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_patch.py new file mode 100644 index 00000000000..74e48ecd07c --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/__init__.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/__init__.py new file mode 100644 index 00000000000..d57e3328b94 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._offer_operations import OfferOperations + +__all__ = [ + 'OfferOperations', +] diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/_offer_operations.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/_offer_operations.py new file mode 100644 index 00000000000..8b18df2433e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/aio/operations/_offer_operations.py @@ -0,0 +1,100 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._offer_operations import build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OfferOperations: + """OfferOperations 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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.marketplace.v2018_08_01_beta.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + offer_id: str, + **kwargs: Any + ) -> "_models.Offer": + """Gets information about a specific offer. + + :param offer_id: The offer ID to update or delete. + :type offer_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Offer, or the result of cls(response) + :rtype: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Offer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Offer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2018-08-01-beta") # type: str + + + request = build_get_request( + offer_id=offer_id, + api_version=api_version, + market=self._config.market, + include_stop_sold_plans=self._config.include_stop_sold_plans, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Offer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Marketplace/offers/{offerId}"} # type: ignore + diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/__init__.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/__init__.py new file mode 100644 index 00000000000..1a81dcdfa6e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/__init__.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AvailabilityEntity + from ._models_py3 import ErrorResponse + from ._models_py3 import ErrorResponseError + from ._models_py3 import IncludedQuantityProperty + from ._models_py3 import Meter + from ._models_py3 import Offer + from ._models_py3 import OfferListResponse + from ._models_py3 import Plan + from ._models_py3 import Price +except (SyntaxError, ImportError): + from ._models import AvailabilityEntity # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ErrorResponseError # type: ignore + from ._models import IncludedQuantityProperty # type: ignore + from ._models import Meter # type: ignore + from ._models import Offer # type: ignore + from ._models import OfferListResponse # type: ignore + from ._models import Plan # type: ignore + from ._models import Price # type: ignore + +__all__ = [ + 'AvailabilityEntity', + 'ErrorResponse', + 'ErrorResponseError', + 'IncludedQuantityProperty', + 'Meter', + 'Offer', + 'OfferListResponse', + 'Plan', + 'Price', +] diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models.py new file mode 100644 index 00000000000..de05963102e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models.py @@ -0,0 +1,330 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.exceptions import HttpResponseError +import msrest.serialization + + +class AvailabilityEntity(msrest.serialization.Model): + """AvailabilityEntity. + + :ivar id: + :vartype id: str + :ivar actions: List of allowed actions. + :vartype actions: list[str] + :ivar market: Market for the availability collection. + :vartype market: str + :ivar meter: Applicable billing meter information. + :vartype meter: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Meter + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'actions': {'key': 'actions', 'type': '[str]'}, + 'market': {'key': 'market', 'type': 'str'}, + 'meter': {'key': 'meter', 'type': 'Meter'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword id: + :paramtype id: str + :keyword actions: List of allowed actions. + :paramtype actions: list[str] + :keyword market: Market for the availability collection. + :paramtype market: str + :keyword meter: Applicable billing meter information. + :paramtype meter: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Meter + """ + super(AvailabilityEntity, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.actions = kwargs.get('actions', None) + self.market = kwargs.get('market', None) + self.meter = kwargs.get('meter', None) + + +class ErrorResponse(msrest.serialization.Model): + """Error response indicates Microsoft.Marketplace service is not able to process the incoming request. The reason is provided in the error message. + + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.marketplace.v2018_08_01_beta.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.marketplace.v2018_08_01_beta.models.ErrorResponseError + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseError(msrest.serialization.Model): + """The details of the error. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorResponseError, self).__init__(**kwargs) + self.code = None + self.message = None + + +class IncludedQuantityProperty(msrest.serialization.Model): + """IncludedQuantityProperty. + + :ivar term_id: Term id. + :vartype term_id: str + :ivar quantity: Quantity. + :vartype quantity: str + """ + + _attribute_map = { + 'term_id': {'key': 'termId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword term_id: Term id. + :paramtype term_id: str + :keyword quantity: Quantity. + :paramtype quantity: str + """ + super(IncludedQuantityProperty, self).__init__(**kwargs) + self.term_id = kwargs.get('term_id', None) + self.quantity = kwargs.get('quantity', None) + + +class Meter(msrest.serialization.Model): + """Meter. + + :ivar meter_id: Metetr id. + :vartype meter_id: str + :ivar price: Price for this meter. + :vartype price: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Price + :ivar included_quantity_properties: Included quantity properties. + :vartype included_quantity_properties: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.IncludedQuantityProperty] + """ + + _attribute_map = { + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'price': {'key': 'price', 'type': 'Price'}, + 'included_quantity_properties': {'key': 'includedQuantityProperties', 'type': '[IncludedQuantityProperty]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword meter_id: Metetr id. + :paramtype meter_id: str + :keyword price: Price for this meter. + :paramtype price: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Price + :keyword included_quantity_properties: Included quantity properties. + :paramtype included_quantity_properties: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.IncludedQuantityProperty] + """ + super(Meter, self).__init__(**kwargs) + self.meter_id = kwargs.get('meter_id', None) + self.price = kwargs.get('price', None) + self.included_quantity_properties = kwargs.get('included_quantity_properties', None) + + +class Offer(msrest.serialization.Model): + """The offer data structure. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar offer_id: Offers unique id. + :vartype offer_id: str + :ivar display_name: It will be displayed prominently in the marketplace. + :vartype display_name: str + :ivar publisher_id: Publisher unique id. + :vartype publisher_id: str + :ivar publisher_display_name: Publisher name that will be displayed prominently in the + marketplace. + :vartype publisher_display_name: str + :ivar e_tag: Identifier for purposes of race condition. + :vartype e_tag: str + :ivar plans: Offer plans. + :vartype plans: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Plan] + """ + + _validation = { + 'offer_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'publisher_id': {'readonly': True}, + 'publisher_display_name': {'readonly': True}, + } + + _attribute_map = { + 'offer_id': {'key': 'properties.offerId', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'publisher_id': {'key': 'properties.publisherId', 'type': 'str'}, + 'publisher_display_name': {'key': 'properties.publisherDisplayName', 'type': 'str'}, + 'e_tag': {'key': 'properties.eTag', 'type': 'str'}, + 'plans': {'key': 'properties.plans', 'type': '[Plan]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword e_tag: Identifier for purposes of race condition. + :paramtype e_tag: str + :keyword plans: Offer plans. + :paramtype plans: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Plan] + """ + super(Offer, self).__init__(**kwargs) + self.offer_id = None + self.display_name = None + self.publisher_id = None + self.publisher_display_name = None + self.e_tag = kwargs.get('e_tag', None) + self.plans = kwargs.get('plans', None) + + +class OfferListResponse(msrest.serialization.Model): + """OfferListResponse. + + :ivar value: + :vartype value: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Offer] + :ivar next_link: URL to get the next set of offer list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Offer]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Offer] + :keyword next_link: URL to get the next set of offer list results if there are any. + :paramtype next_link: str + """ + super(OfferListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class Plan(msrest.serialization.Model): + """Plan. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar description: Description for this plan. + :vartype description: str + :ivar plan_id: Text identifier for this plan. + :vartype plan_id: str + :ivar display_name: Friendly name for the plan for display in the marketplace. + :vartype display_name: str + :ivar availabilities: + :vartype availabilities: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.AvailabilityEntity] + """ + + _validation = { + 'description': {'readonly': True}, + 'plan_id': {'readonly': True}, + 'display_name': {'readonly': True}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'plan_id': {'key': 'planId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'availabilities': {'key': 'availabilities', 'type': '[AvailabilityEntity]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword availabilities: + :paramtype availabilities: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.AvailabilityEntity] + """ + super(Plan, self).__init__(**kwargs) + self.description = None + self.plan_id = None + self.display_name = None + self.availabilities = kwargs.get('availabilities', None) + + +class Price(msrest.serialization.Model): + """Price. + + :ivar currency_code: Currency code i.e. 'USD'. + :vartype currency_code: str + :ivar list_price: Retail price for the item. + :vartype list_price: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'list_price': {'key': 'listPrice', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword currency_code: Currency code i.e. 'USD'. + :paramtype currency_code: str + :keyword list_price: Retail price for the item. + :paramtype list_price: float + """ + super(Price, self).__init__(**kwargs) + self.currency_code = kwargs.get('currency_code', None) + self.list_price = kwargs.get('list_price', None) diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models_py3.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models_py3.py new file mode 100644 index 00000000000..7c88e11c7d1 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/models/_models_py3.py @@ -0,0 +1,357 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import List, Optional + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class AvailabilityEntity(msrest.serialization.Model): + """AvailabilityEntity. + + :ivar id: + :vartype id: str + :ivar actions: List of allowed actions. + :vartype actions: list[str] + :ivar market: Market for the availability collection. + :vartype market: str + :ivar meter: Applicable billing meter information. + :vartype meter: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Meter + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'actions': {'key': 'actions', 'type': '[str]'}, + 'market': {'key': 'market', 'type': 'str'}, + 'meter': {'key': 'meter', 'type': 'Meter'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + actions: Optional[List[str]] = None, + market: Optional[str] = None, + meter: Optional["Meter"] = None, + **kwargs + ): + """ + :keyword id: + :paramtype id: str + :keyword actions: List of allowed actions. + :paramtype actions: list[str] + :keyword market: Market for the availability collection. + :paramtype market: str + :keyword meter: Applicable billing meter information. + :paramtype meter: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Meter + """ + super(AvailabilityEntity, self).__init__(**kwargs) + self.id = id + self.actions = actions + self.market = market + self.meter = meter + + +class ErrorResponse(msrest.serialization.Model): + """Error response indicates Microsoft.Marketplace service is not able to process the incoming request. The reason is provided in the error message. + + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.marketplace.v2018_08_01_beta.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponseError"] = None, + **kwargs + ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.marketplace.v2018_08_01_beta.models.ErrorResponseError + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseError(msrest.serialization.Model): + """The details of the error. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorResponseError, self).__init__(**kwargs) + self.code = None + self.message = None + + +class IncludedQuantityProperty(msrest.serialization.Model): + """IncludedQuantityProperty. + + :ivar term_id: Term id. + :vartype term_id: str + :ivar quantity: Quantity. + :vartype quantity: str + """ + + _attribute_map = { + 'term_id': {'key': 'termId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'str'}, + } + + def __init__( + self, + *, + term_id: Optional[str] = None, + quantity: Optional[str] = None, + **kwargs + ): + """ + :keyword term_id: Term id. + :paramtype term_id: str + :keyword quantity: Quantity. + :paramtype quantity: str + """ + super(IncludedQuantityProperty, self).__init__(**kwargs) + self.term_id = term_id + self.quantity = quantity + + +class Meter(msrest.serialization.Model): + """Meter. + + :ivar meter_id: Metetr id. + :vartype meter_id: str + :ivar price: Price for this meter. + :vartype price: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Price + :ivar included_quantity_properties: Included quantity properties. + :vartype included_quantity_properties: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.IncludedQuantityProperty] + """ + + _attribute_map = { + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'price': {'key': 'price', 'type': 'Price'}, + 'included_quantity_properties': {'key': 'includedQuantityProperties', 'type': '[IncludedQuantityProperty]'}, + } + + def __init__( + self, + *, + meter_id: Optional[str] = None, + price: Optional["Price"] = None, + included_quantity_properties: Optional[List["IncludedQuantityProperty"]] = None, + **kwargs + ): + """ + :keyword meter_id: Metetr id. + :paramtype meter_id: str + :keyword price: Price for this meter. + :paramtype price: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Price + :keyword included_quantity_properties: Included quantity properties. + :paramtype included_quantity_properties: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.IncludedQuantityProperty] + """ + super(Meter, self).__init__(**kwargs) + self.meter_id = meter_id + self.price = price + self.included_quantity_properties = included_quantity_properties + + +class Offer(msrest.serialization.Model): + """The offer data structure. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar offer_id: Offers unique id. + :vartype offer_id: str + :ivar display_name: It will be displayed prominently in the marketplace. + :vartype display_name: str + :ivar publisher_id: Publisher unique id. + :vartype publisher_id: str + :ivar publisher_display_name: Publisher name that will be displayed prominently in the + marketplace. + :vartype publisher_display_name: str + :ivar e_tag: Identifier for purposes of race condition. + :vartype e_tag: str + :ivar plans: Offer plans. + :vartype plans: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Plan] + """ + + _validation = { + 'offer_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'publisher_id': {'readonly': True}, + 'publisher_display_name': {'readonly': True}, + } + + _attribute_map = { + 'offer_id': {'key': 'properties.offerId', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'publisher_id': {'key': 'properties.publisherId', 'type': 'str'}, + 'publisher_display_name': {'key': 'properties.publisherDisplayName', 'type': 'str'}, + 'e_tag': {'key': 'properties.eTag', 'type': 'str'}, + 'plans': {'key': 'properties.plans', 'type': '[Plan]'}, + } + + def __init__( + self, + *, + e_tag: Optional[str] = None, + plans: Optional[List["Plan"]] = None, + **kwargs + ): + """ + :keyword e_tag: Identifier for purposes of race condition. + :paramtype e_tag: str + :keyword plans: Offer plans. + :paramtype plans: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Plan] + """ + super(Offer, self).__init__(**kwargs) + self.offer_id = None + self.display_name = None + self.publisher_id = None + self.publisher_display_name = None + self.e_tag = e_tag + self.plans = plans + + +class OfferListResponse(msrest.serialization.Model): + """OfferListResponse. + + :ivar value: + :vartype value: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Offer] + :ivar next_link: URL to get the next set of offer list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Offer]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Offer"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.marketplace.v2018_08_01_beta.models.Offer] + :keyword next_link: URL to get the next set of offer list results if there are any. + :paramtype next_link: str + """ + super(OfferListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Plan(msrest.serialization.Model): + """Plan. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar description: Description for this plan. + :vartype description: str + :ivar plan_id: Text identifier for this plan. + :vartype plan_id: str + :ivar display_name: Friendly name for the plan for display in the marketplace. + :vartype display_name: str + :ivar availabilities: + :vartype availabilities: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.AvailabilityEntity] + """ + + _validation = { + 'description': {'readonly': True}, + 'plan_id': {'readonly': True}, + 'display_name': {'readonly': True}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'plan_id': {'key': 'planId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'availabilities': {'key': 'availabilities', 'type': '[AvailabilityEntity]'}, + } + + def __init__( + self, + *, + availabilities: Optional[List["AvailabilityEntity"]] = None, + **kwargs + ): + """ + :keyword availabilities: + :paramtype availabilities: + list[~azure.mgmt.marketplace.v2018_08_01_beta.models.AvailabilityEntity] + """ + super(Plan, self).__init__(**kwargs) + self.description = None + self.plan_id = None + self.display_name = None + self.availabilities = availabilities + + +class Price(msrest.serialization.Model): + """Price. + + :ivar currency_code: Currency code i.e. 'USD'. + :vartype currency_code: str + :ivar list_price: Retail price for the item. + :vartype list_price: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'list_price': {'key': 'listPrice', 'type': 'float'}, + } + + def __init__( + self, + *, + currency_code: Optional[str] = None, + list_price: Optional[float] = None, + **kwargs + ): + """ + :keyword currency_code: Currency code i.e. 'USD'. + :paramtype currency_code: str + :keyword list_price: Retail price for the item. + :paramtype list_price: float + """ + super(Price, self).__init__(**kwargs) + self.currency_code = currency_code + self.list_price = list_price diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/__init__.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/__init__.py new file mode 100644 index 00000000000..d57e3328b94 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._offer_operations import OfferOperations + +__all__ = [ + 'OfferOperations', +] diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/_offer_operations.py b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/_offer_operations.py new file mode 100644 index 00000000000..a4311e1e6b4 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/operations/_offer_operations.py @@ -0,0 +1,149 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Optional, TypeVar + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + offer_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version', "2018-08-01-beta") # type: str + market = kwargs.pop('market', "US") # type: Optional[str] + include_stop_sold_plans = kwargs.pop('include_stop_sold_plans', "true") # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Marketplace/offers/{offerId}") + path_format_arguments = { + "offerId": _SERIALIZER.url("offer_id", offer_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if market is not None: + _query_parameters['market'] = _SERIALIZER.query("market", market, 'str') + if include_stop_sold_plans is not None: + _query_parameters['includeStopSoldPlans'] = _SERIALIZER.query("include_stop_sold_plans", include_stop_sold_plans, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +# fmt: on +class OfferOperations(object): + """OfferOperations operations. + + You 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.marketplace.v2018_08_01_beta.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + offer_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Offer" + """Gets information about a specific offer. + + :param offer_id: The offer ID to update or delete. + :type offer_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Offer, or the result of cls(response) + :rtype: ~azure.mgmt.marketplace.v2018_08_01_beta.models.Offer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Offer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2018-08-01-beta") # type: str + + + request = build_get_request( + offer_id=offer_id, + api_version=api_version, + market=self._config.market, + include_stop_sold_plans=self._config.include_stop_sold_plans, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Offer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Marketplace/offers/{offerId}"} # type: ignore + diff --git a/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/py.typed b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/marketplace/v2018_08_01_beta/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file From c7eef0239f9b0ad64b28cbc7ad9051b4f8c502db Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Tue, 24 May 2022 16:39:32 +0800 Subject: [PATCH 2/6] Add command to list plans --- src/spring/azext_spring/_constant.py | 11 ++++++ src/spring/azext_spring/_help.py | 8 +++++ src/spring/azext_spring/_marketplace.py | 36 +++++++++++++++++++ src/spring/azext_spring/_params.py | 4 +++ src/spring/azext_spring/_validators.py | 22 ++++++++---- src/spring/azext_spring/commands.py | 4 +++ src/spring/azext_spring/spring_instance.py | 16 +++++++++ .../tests/latest/test_asa_validator.py | 6 ++-- 8 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 src/spring/azext_spring/_constant.py create mode 100644 src/spring/azext_spring/_marketplace.py diff --git a/src/spring/azext_spring/_constant.py b/src/spring/azext_spring/_constant.py new file mode 100644 index 00000000000..2901d4b39bd --- /dev/null +++ b/src/spring/azext_spring/_constant.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=wrong-import-order +# pylint: disable=unused-argument, logging-format-interpolation, protected-access, wrong-import-order, too-many-lines + +MARKETPLACE_OFFER_ID='azure-spring-cloud-vmware-tanzu-2' +MARKETPLACE_PUBLISHER_ID='vmware-inc' +MARKETPLACE_PLAN_ID='asa-ent-hr-mtr' diff --git a/src/spring/azext_spring/_help.py b/src/spring/azext_spring/_help.py index 89a9a86e2ab..a8e28e6e706 100644 --- a/src/spring/azext_spring/_help.py +++ b/src/spring/azext_spring/_help.py @@ -39,6 +39,14 @@ az spring create -n MyService -g MyResourceGroup --sku Enterprise --enable-application-configuration-service --enable-service-registry --enable-gateway --enable-api-portal """ +helps['spring list-marketplace-plan'] = """ + type: command + short-summary: (Enterprise tier only) List Marketplace plan to be purchased. + examples: + - name: List all plans. + text: az spring list-marketplace-plan -o table +""" + helps['spring update'] = """ type: command short-summary: Update an Azure Spring Apps. diff --git a/src/spring/azext_spring/_marketplace.py b/src/spring/azext_spring/_marketplace.py new file mode 100644 index 00000000000..a303c8eaaf9 --- /dev/null +++ b/src/spring/azext_spring/_marketplace.py @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=wrong-import-order +# pylint: disable=unused-argument, logging-format-interpolation, protected-access, wrong-import-order, too-many-lines +from asyncio.log import logger +from ._constant import (MARKETPLACE_OFFER_ID, MARKETPLACE_PUBLISHER_ID) + +def _spring_list_marketplace_plan(cmd, client): + # return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20220501preview) + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from .vendored_sdks.marketplace.v2018_08_01_beta import MarketplaceRPService + from .vendored_sdks.marketplace.v2018_08_01_beta.models import Offer + + client = get_mgmt_service_client(cmd.cli_ctx, MarketplaceRPService) + offer = client.offer.get('{}.{}'.format(MARKETPLACE_PUBLISHER_ID, MARKETPLACE_OFFER_ID)) + offer.plans = [x for x in offer.plans if _is_valid_plan(x)] + return Offer.deserialize(offer).serialize(offer) + + +def _is_valid_plan(plan): + return plan.availabilities + +def transform_marketplace_plan_output(result): + def _table_item_view(plan): + return { + 'publisher id': result['properties']['publisherId'], + 'product id': result['properties']['offerId'], + 'plan id': plan['planId'], + 'plan display name': plan['displayName'] + } + + plans = result['properties']['plans'] + return [_table_item_view(plan) for plan in plans] diff --git a/src/spring/azext_spring/_params.py b/src/spring/azext_spring/_params.py index 9d1a2f7fa77..e04c7cfd79f 100644 --- a/src/spring/azext_spring/_params.py +++ b/src/spring/azext_spring/_params.py @@ -152,6 +152,10 @@ def load_arguments(self, _): is_preview=True, options_list=['--api-portal-instance-count', '--ap-instance'], help='(Enterprise Tier Only) Number of API portal instances.') + c.argument('marketplace_plan_id', + is_preview=True, + help='(Enterprise Tier Only) Specify a different Marketplace plan to purchase with Spring instance. ' + 'List all plans by running `az spring list-marketplace-plan -o table`.') with self.argument_context('spring update') as c: c.argument('sku', arg_type=sku_type, validator=normalize_sku) diff --git a/src/spring/azext_spring/_validators.py b/src/spring/azext_spring/_validators.py index e2482896f92..4a803048c2f 100644 --- a/src/spring/azext_spring/_validators.py +++ b/src/spring/azext_spring/_validators.py @@ -20,6 +20,7 @@ from knack.log import get_logger from ._utils import (ApiType, _get_rg_location, _get_file_type, _get_sku_name) from .vendored_sdks.appplatform.v2020_07_01 import models +from ._constant import (MARKETPLACE_OFFER_ID, MARKETPLACE_PLAN_ID, MARKETPLACE_PUBLISHER_ID) logger = get_logger(__name__) @@ -47,6 +48,7 @@ def validate_sku(cmd, namespace): _validate_saas_provider(cmd, namespace) _validate_terms(cmd, namespace) else: + _check_saas_not_set(cmd, namespace) _check_tanzu_components_not_enable(cmd, namespace) normalize_sku(cmd, namespace) @@ -56,6 +58,11 @@ def normalize_sku(cmd, namespace): namespace.sku = models.Sku(name=_get_sku_name(namespace.sku), tier=namespace.sku) +def _check_saas_not_set(cmd, namespace): + if namespace.marketplace_plan_id: + raise InvalidArgumentValueError('--marketplace-plan-id is supported only when --sku=Enterprise') + + def _validate_saas_provider(cmd, namespace): from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.cli.core.profiles import ResourceType @@ -69,15 +76,18 @@ def _validate_terms(cmd, namespace): from azure.mgmt.marketplaceordering import MarketplaceOrderingAgreements from azure.cli.core.commands.client_factory import get_mgmt_service_client client = get_mgmt_service_client(cmd.cli_ctx, MarketplaceOrderingAgreements).marketplace_agreements + plan_id = namespace.marketplace_plan_id or MARKETPLACE_PLAN_ID term = client.get(offer_type="virtualmachine", - publisher_id='vmware-inc', - offer_id='azure-spring-cloud-vmware-tanzu-2', - plan_id='tanzu-asc-ent-mtr') + publisher_id=MARKETPLACE_PUBLISHER_ID, + offer_id=MARKETPLACE_OFFER_ID, + plan_id=plan_id) if not term.accepted: raise InvalidArgumentValueError('Terms for Azure Spring Apps Enterprise is not accepted.\n' - 'Run "az term accept --publisher vmware-inc ' - '--product azure-spring-cloud-vmware-tanzu-2 ' - '--plan tanzu-asc-ent-mtr" to accept the term.') + 'Run "az term accept --publisher {} ' + '--product {} ' + '--plan {}" to accept the term.'.format(MARKETPLACE_PUBLISHER_ID, + MARKETPLACE_OFFER_ID, + plan_id)) def _check_tanzu_components_not_enable(cmd, namespace): diff --git a/src/spring/azext_spring/commands.py b/src/spring/azext_spring/commands.py index 713d1dd04d3..b5d183f5f44 100644 --- a/src/spring/azext_spring/commands.py +++ b/src/spring/azext_spring/commands.py @@ -21,6 +21,7 @@ transform_service_registry_output, transform_spring_cloud_gateway_output, transform_api_portal_output) +from ._marketplace import (transform_marketplace_plan_output) from ._validators_enterprise import (validate_gateway_update, validate_api_portal_update) from ._app_managed_identity_validator import (validate_app_identity_remove_or_warning, validate_app_identity_assign_or_warning) @@ -91,6 +92,9 @@ def load_command_table(self, _): with self.command_group('spring', custom_command_type=spring_routing_util, exception_handler=handle_asc_exception) as g: g.custom_command('create', 'spring_create', supports_no_wait=True) + g.custom_command('list-marketplace-plan', 'spring_list_marketplace_plan', + is_preview=True, + table_transformer=transform_marketplace_plan_output) with self.command_group('spring', client_factory=cf_spring_20220501preview, exception_handler=handle_asc_exception) as g: diff --git a/src/spring/azext_spring/spring_instance.py b/src/spring/azext_spring/spring_instance.py index eccd9d8e514..a212f7b9f2c 100644 --- a/src/spring/azext_spring/spring_instance.py +++ b/src/spring/azext_spring/spring_instance.py @@ -20,6 +20,8 @@ from ._validators import (_parse_sku_name) from knack.log import get_logger +from ._marketplace import _spring_list_marketplace_plan +from ._constant import (MARKETPLACE_OFFER_ID, MARKETPLACE_PUBLISHER_ID) logger = get_logger(__name__) @@ -58,11 +60,19 @@ def create_service(self, sku=None, tags=None, ingress_read_timeout=None, + marketplace_plan_id=None, **_): properties = models.ClusterResourceProperties( zone_redundant=zone_redundant ) + if marketplace_plan_id: + properties.marketplace_resource = models.MarketplaceResource( + plan=marketplace_plan_id, + product=MARKETPLACE_OFFER_ID, + publisher=MARKETPLACE_PUBLISHER_ID + ) + if service_runtime_subnet or app_subnet or reserved_cidr_range: properties.network_profile = models.NetworkProfile( service_runtime_subnet_id=service_runtime_subnet, @@ -137,6 +147,7 @@ def spring_create(cmd, client, resource_group, name, enable_api_portal=False, api_portal_instance_count=None, ingress_read_timeout=None, + marketplace_plan_id=None, no_wait=False): """ Because Standard/Basic tier vs. Enterprise tier creation are very different. Here routes the command to different @@ -165,6 +176,7 @@ def spring_create(cmd, client, resource_group, name, 'gateway_instance_count': gateway_instance_count, 'enable_api_portal': enable_api_portal, 'api_portal_instance_count': api_portal_instance_count, + 'marketplace_plan_id': marketplace_plan_id, 'no_wait': no_wait } @@ -180,3 +192,7 @@ def _enable_app_insights(cmd, client, resource_group, name, location, app_insigh return create_default_buildpack_binding_for_application_insights(cmd, client, resource_group, name, location, app_insights_key, app_insights, sampling_rate) + + +def spring_list_marketplace_plan(cmd, client): + return _spring_list_marketplace_plan(cmd, client) \ No newline at end of file diff --git a/src/spring/azext_spring/tests/latest/test_asa_validator.py b/src/spring/azext_spring/tests/latest/test_asa_validator.py index 6bce1b17e32..1b80700c3a5 100644 --- a/src/spring/azext_spring/tests/latest/test_asa_validator.py +++ b/src/spring/azext_spring/tests/latest/test_asa_validator.py @@ -308,20 +308,20 @@ def _mock_not_registered_client(cli_ctx, client_type, **kwargs): class TestSkuValidator(unittest.TestCase): @mock.patch('azure.cli.core.commands.client_factory.get_mgmt_service_client', _mock_happy_client) def test_happy_path(self): - ns = Namespace(sku='Enterprise') + ns = Namespace(sku='Enterprise', marketplace_plan_id=None) validate_sku(_get_test_cmd(), ns) self.assertEqual('Enterprise', ns.sku.tier) @mock.patch('azure.cli.core.commands.client_factory.get_mgmt_service_client', _mock_not_accepted_term_client) def test_term_not_accept(self): - ns = Namespace(sku='Enterprise') + ns = Namespace(sku='Enterprise', marketplace_plan_id=None) with self.assertRaises(InvalidArgumentValueError) as context: validate_sku(_get_test_cmd(), ns) self.assertTrue('Terms for Azure Spring Apps Enterprise is not accepted.' in str(context.exception)) @mock.patch('azure.cli.core.commands.client_factory.get_mgmt_service_client', _mock_not_registered_client) def test_provider_not_registered(self): - ns = Namespace(sku='Enterprise') + ns = Namespace(sku='Enterprise', marketplace_plan_id=None) with self.assertRaises(InvalidArgumentValueError) as context: validate_sku(_get_test_cmd(), ns) self.assertTrue('Microsoft.SaaS resource provider is not registered.' in str(context.exception)) From 91554aa7211f5c56f4ac602060634d6c2755dca2 Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Tue, 24 May 2022 16:48:42 +0800 Subject: [PATCH 3/6] Add test --- .../azext_spring/tests/latest/test_asa_create.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/spring/azext_spring/tests/latest/test_asa_create.py b/src/spring/azext_spring/tests/latest/test_asa_create.py index 68a2e7d07b7..6c63c45db0f 100644 --- a/src/spring/azext_spring/tests/latest/test_asa_create.py +++ b/src/spring/azext_spring/tests/latest/test_asa_create.py @@ -79,6 +79,17 @@ def test_asc_create_enterprise(self): self.assertEqual('E0', resource.sku.name) self.assertEqual('Enterprise', resource.sku.tier) self.assertEqual(False, resource.properties.zone_redundant) + self.assertIsNone(resource.properties.marketplace_resource) + + def test_asc_create_enterprise_with_plan(self): + self._execute('rg', 'asc', sku=self._get_sku('Enterprise'), disable_app_insights=True, marketplace_plan_id='my-plan') + resource = self.created_resource + self.assertEqual('E0', resource.sku.name) + self.assertEqual('Enterprise', resource.sku.tier) + self.assertEqual(False, resource.properties.zone_redundant) + self.assertEqual('my-plan', resource.properties.marketplace_resource.plan) + self.assertEqual('azure-spring-cloud-vmware-tanzu-2', resource.properties.marketplace_resource.product) + self.assertEqual('vmware-inc', resource.properties.marketplace_resource.publisher) class TestSpringCloudCreateWithAI(BasicTest): From 90281d829298653dc9ca04de8102f3d767c51583 Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Tue, 24 May 2022 16:50:42 +0800 Subject: [PATCH 4/6] Add history --- src/spring/HISTORY.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/spring/HISTORY.md b/src/spring/HISTORY.md index b6bd7aab6e1..c905fd426aa 100644 --- a/src/spring/HISTORY.md +++ b/src/spring/HISTORY.md @@ -2,8 +2,9 @@ Release History =============== 1.1.0 --- -* New command `az spring create` has new argument "--ingress-read-timeout" to set ingress read timeout when create Azure Spring App. -* New command `az spring update` has new argument "--ingress-read-timeout" to update ingress read timeout for Azure Spring App. +* Command `az spring create` has new argument "--ingress-read-timeout" to set ingress read timeout when create Azure Spring Apps. +* Command `az spring update` has new argument "--ingress-read-timeout" to update ingress read timeout for Azure Spring Apps. +* Command `az spring create` has new argument "--marketplace-plan-id" to purchase SaaS resource against given plan for Azure Spring Apps. * Command `az spring app deploy` and `az spring app deployment create` has new argument "--build-cpu" and "--build-memory" to set cpu and memory during build process. 1.0.0 From 50bd03d58ea66ae7235cff6b3655a102b91de75f Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Tue, 24 May 2022 18:00:08 +0800 Subject: [PATCH 5/6] fix lint --- src/spring/azext_spring/_constant.py | 6 +++--- src/spring/azext_spring/_marketplace.py | 2 ++ src/spring/azext_spring/spring_instance.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/spring/azext_spring/_constant.py b/src/spring/azext_spring/_constant.py index 2901d4b39bd..a9635e05d97 100644 --- a/src/spring/azext_spring/_constant.py +++ b/src/spring/azext_spring/_constant.py @@ -6,6 +6,6 @@ # pylint: disable=wrong-import-order # pylint: disable=unused-argument, logging-format-interpolation, protected-access, wrong-import-order, too-many-lines -MARKETPLACE_OFFER_ID='azure-spring-cloud-vmware-tanzu-2' -MARKETPLACE_PUBLISHER_ID='vmware-inc' -MARKETPLACE_PLAN_ID='asa-ent-hr-mtr' +MARKETPLACE_OFFER_ID = 'azure-spring-cloud-vmware-tanzu-2' +MARKETPLACE_PUBLISHER_ID = 'vmware-inc' +MARKETPLACE_PLAN_ID = 'asa-ent-hr-mtr' diff --git a/src/spring/azext_spring/_marketplace.py b/src/spring/azext_spring/_marketplace.py index a303c8eaaf9..397aab8aed6 100644 --- a/src/spring/azext_spring/_marketplace.py +++ b/src/spring/azext_spring/_marketplace.py @@ -8,6 +8,7 @@ from asyncio.log import logger from ._constant import (MARKETPLACE_OFFER_ID, MARKETPLACE_PUBLISHER_ID) + def _spring_list_marketplace_plan(cmd, client): # return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20220501preview) from azure.cli.core.commands.client_factory import get_mgmt_service_client @@ -23,6 +24,7 @@ def _spring_list_marketplace_plan(cmd, client): def _is_valid_plan(plan): return plan.availabilities + def transform_marketplace_plan_output(result): def _table_item_view(plan): return { diff --git a/src/spring/azext_spring/spring_instance.py b/src/spring/azext_spring/spring_instance.py index a212f7b9f2c..ed626598c12 100644 --- a/src/spring/azext_spring/spring_instance.py +++ b/src/spring/azext_spring/spring_instance.py @@ -195,4 +195,4 @@ def _enable_app_insights(cmd, client, resource_group, name, location, app_insigh def spring_list_marketplace_plan(cmd, client): - return _spring_list_marketplace_plan(cmd, client) \ No newline at end of file + return _spring_list_marketplace_plan(cmd, client) From dcb6bbb274324f3a6681d9cb0c3fe706c1fbe85c Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Wed, 25 May 2022 10:07:58 +0800 Subject: [PATCH 6/6] Update _help.py --- src/spring/azext_spring/_help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring/azext_spring/_help.py b/src/spring/azext_spring/_help.py index a8e28e6e706..866fc15ed2e 100644 --- a/src/spring/azext_spring/_help.py +++ b/src/spring/azext_spring/_help.py @@ -41,7 +41,7 @@ helps['spring list-marketplace-plan'] = """ type: command - short-summary: (Enterprise tier only) List Marketplace plan to be purchased. + short-summary: (Enterprise Tier Only) List Marketplace plan to be purchased. examples: - name: List all plans. text: az spring list-marketplace-plan -o table