From c54ab92e5a0c7dbe94fcf8cada62141505f0dfba Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 24 Mar 2022 07:05:03 +0000 Subject: [PATCH] CodeGen from PR 18387 in Azure/azure-rest-api-specs Merge 285e087686fb20c4aecf62f528dd7d3ebf733c74 into ce6e1414f546d09834a24dc24814b2b8e932b1de --- .../azure-mgmt-consumption/_meta.json | 2 +- .../azure/mgmt/consumption/_version.py | 2 +- .../aio/operations/_lots_operations.py | 83 +++++++++++- .../mgmt/consumption/models/_models_py3.py | 7 -- .../operations/_lots_operations.py | 118 ++++++++++++++++++ 5 files changed, 202 insertions(+), 10 deletions(-) diff --git a/sdk/consumption/azure-mgmt-consumption/_meta.json b/sdk/consumption/azure-mgmt-consumption/_meta.json index 4d72f9b7503e..2a110e25b559 100644 --- a/sdk/consumption/azure-mgmt-consumption/_meta.json +++ b/sdk/consumption/azure-mgmt-consumption/_meta.json @@ -4,7 +4,7 @@ "@autorest/python@5.12.0", "@autorest/modelerfour@4.19.3" ], - "commit": "87c075973362d149fd8e23b31b061692d8c6dd45", + "commit": "55f588f347e3d3bfe6dccbcd7fd9792c109b1181", "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", "readme": "specification/consumption/resource-manager/readme.md" 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..1431f9de7990 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]] @@ -195,3 +195,84 @@ 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 and Microsoft Azure consumption commitments for a billing account or a + billing profile and a customer. Microsoft Azure consumption commitments are only supported for + the billing account scope. + + :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..f769b9292772 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. @@ -264,3 +301,84 @@ 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 and Microsoft Azure consumption commitments for a billing account or a + billing profile and a customer. Microsoft Azure consumption commitments are only supported for + the billing account scope. + + :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