From 5b0492dc27bc0a543123836bb5304e349099f2b0 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 8 Apr 2022 01:06:26 +0000 Subject: [PATCH] CodeGen from PR 18611 in Azure/azure-rest-api-specs Merge 9480276363465408fd18ab70a21486ecf90e8660 into 18a8f9df1c94fdbdac9492099013bb6656d3c95a --- .../azure-mgmt-consumption/_meta.json | 4 +- .../azure/mgmt/consumption/_version.py | 2 +- .../aio/operations/_lots_operations.py | 93 ++++++++++++- .../mgmt/consumption/models/_models_py3.py | 7 - .../operations/_lots_operations.py | 128 +++++++++++++++++- 5 files changed, 211 insertions(+), 23 deletions(-) diff --git a/sdk/consumption/azure-mgmt-consumption/_meta.json b/sdk/consumption/azure-mgmt-consumption/_meta.json index 4d72f9b7503e..7f5be8efc56f 100644 --- a/sdk/consumption/azure-mgmt-consumption/_meta.json +++ b/sdk/consumption/azure-mgmt-consumption/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.12.0", "@autorest/modelerfour@4.19.3" ], - "commit": "87c075973362d149fd8e23b31b061692d8c6dd45", + "commit": "270216612a7426cce8408d2b690d864248d69759", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/consumption/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/consumption/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/consumption/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py index b77ac9246082..e5754a47ce68 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py index bf8185fc2cd3..a95318051556 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py @@ -20,7 +20,7 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._lots_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request +from ...operations._lots_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_customer_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,9 +53,8 @@ def list_by_billing_profile( billing_profile_id: str, **kwargs: Any ) -> AsyncIterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Azure credits for a billing account or a billing profile. The API is only supported + for Microsoft Customer Agreements (MCA) billing accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -127,9 +126,9 @@ def list_by_billing_account( filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Microsoft Azure consumption commitments for a billing account. The API is only + supported for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing + accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -195,3 +194,83 @@ async def get_next(next_link=None): get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore + + @distributed_trace + def list_by_customer( + self, + billing_account_id: str, + customer_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Lots"]: + """Lists all Azure credits for a customer. The API is only supported for Microsoft Partner + Agreements (MPA) billing accounts. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param customer_id: Customer ID. + :type customer_id: str + :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', + 'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is + separated by a colon (:). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Lots or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Lots] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + filter=filter, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("Lots", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots'} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py index e5e45e6f8c92..8c9c5abd2a55 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py @@ -533,8 +533,6 @@ class BudgetFilter(msrest.serialization.Model): :ivar and_property: The logical "AND" expression. Must have at least 2 items. :vartype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] - :ivar not_property: The logical "NOT" expression. - :vartype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties :ivar dimensions: Has comparison expression for a dimension. :vartype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression :ivar tags: A set of tags. Has comparison expression for a tag. @@ -543,7 +541,6 @@ class BudgetFilter(msrest.serialization.Model): _attribute_map = { 'and_property': {'key': 'and', 'type': '[BudgetFilterProperties]'}, - 'not_property': {'key': 'not', 'type': 'BudgetFilterProperties'}, 'dimensions': {'key': 'dimensions', 'type': 'BudgetComparisonExpression'}, 'tags': {'key': 'tags', 'type': 'BudgetComparisonExpression'}, } @@ -552,7 +549,6 @@ def __init__( self, *, and_property: Optional[List["BudgetFilterProperties"]] = None, - not_property: Optional["BudgetFilterProperties"] = None, dimensions: Optional["BudgetComparisonExpression"] = None, tags: Optional["BudgetComparisonExpression"] = None, **kwargs @@ -560,8 +556,6 @@ def __init__( """ :keyword and_property: The logical "AND" expression. Must have at least 2 items. :paramtype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] - :keyword not_property: The logical "NOT" expression. - :paramtype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties :keyword dimensions: Has comparison expression for a dimension. :paramtype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression :keyword tags: A set of tags. Has comparison expression for a tag. @@ -569,7 +563,6 @@ def __init__( """ super(BudgetFilter, self).__init__(**kwargs) self.and_property = and_property - self.not_property = not_property self.dimensions = dimensions self.tags = tags diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py index 5d74e051f327..e941c8d03e4f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py @@ -93,6 +93,43 @@ def build_list_by_billing_account_request( **kwargs ) + +def build_list_by_customer_request( + billing_account_id: str, + customer_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + "customerId": _SERIALIZER.url("customer_id", customer_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + class LotsOperations(object): """LotsOperations operations. @@ -122,9 +159,8 @@ def list_by_billing_profile( billing_profile_id: str, **kwargs: Any ) -> Iterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Azure credits for a billing account or a billing profile. The API is only supported + for Microsoft Customer Agreements (MCA) billing accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -196,9 +232,9 @@ def list_by_billing_account( filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Microsoft Azure consumption commitments for a billing account. The API is only + supported for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing + accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -264,3 +300,83 @@ def get_next(next_link=None): get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore + + @distributed_trace + def list_by_customer( + self, + billing_account_id: str, + customer_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.Lots"]: + """Lists all Azure credits for a customer. The API is only supported for Microsoft Partner + Agreements (MPA) billing accounts. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param customer_id: Customer ID. + :type customer_id: str + :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', + 'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is + separated by a colon (:). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Lots or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Lots] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + filter=filter, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("Lots", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots'} # type: ignore