Skip to content

Commit d6d8758

Browse files
author
SDKAuto
committed
CodeGen from PR 18543 in Azure/azure-rest-api-specs
Merge c3c30786aee07f72a2f19b2eb6bbd89aa8b94fd1 into 12aa4dd9607f82bdc1087f24b91cec7d5c4499c2
1 parent 833e766 commit d6d8758

File tree

5 files changed

+203
-11
lines changed

5 files changed

+203
-11
lines changed

sdk/consumption/azure-mgmt-consumption/_meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"@autorest/python@5.12.0",
55
"@autorest/modelerfour@4.19.3"
66
],
7-
"commit": "87c075973362d149fd8e23b31b061692d8c6dd45",
7+
"commit": "76c641c5f75c5c62657740c26e4946758fbad8b3",
88
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
9-
"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",
9+
"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",
1010
"readme": "specification/consumption/resource-manager/readme.md"
1111
}

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "9.0.0"
9+
VERSION = "1.0.0b1"

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from ... import models as _models
2222
from ..._vendor import _convert_request
23-
from ...operations._lots_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request
23+
from ...operations._lots_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_customer_request
2424
T = TypeVar('T')
2525
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
2626

@@ -195,3 +195,84 @@ async def get_next(next_link=None):
195195
get_next, extract_data
196196
)
197197
list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore
198+
199+
@distributed_trace
200+
def list_by_customer(
201+
self,
202+
billing_account_id: str,
203+
customer_id: str,
204+
filter: Optional[str] = None,
205+
**kwargs: Any
206+
) -> AsyncIterable["_models.Lots"]:
207+
"""Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a
208+
billing profile and a customer. Microsoft Azure consumption commitments are only supported for
209+
the billing account scope.
210+
211+
:param billing_account_id: BillingAccount ID.
212+
:type billing_account_id: str
213+
:param customer_id: Customer ID.
214+
:type customer_id: str
215+
:param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq',
216+
'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is
217+
separated by a colon (:).
218+
:type filter: str
219+
:keyword callable cls: A custom type or function that will be passed the direct response
220+
:return: An iterator like instance of either Lots or the result of cls(response)
221+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Lots]
222+
:raises: ~azure.core.exceptions.HttpResponseError
223+
"""
224+
cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"]
225+
error_map = {
226+
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
227+
}
228+
error_map.update(kwargs.pop('error_map', {}))
229+
def prepare_request(next_link=None):
230+
if not next_link:
231+
232+
request = build_list_by_customer_request(
233+
billing_account_id=billing_account_id,
234+
customer_id=customer_id,
235+
filter=filter,
236+
template_url=self.list_by_customer.metadata['url'],
237+
)
238+
request = _convert_request(request)
239+
request.url = self._client.format_url(request.url)
240+
241+
else:
242+
243+
request = build_list_by_customer_request(
244+
billing_account_id=billing_account_id,
245+
customer_id=customer_id,
246+
filter=filter,
247+
template_url=next_link,
248+
)
249+
request = _convert_request(request)
250+
request.url = self._client.format_url(request.url)
251+
request.method = "GET"
252+
return request
253+
254+
async def extract_data(pipeline_response):
255+
deserialized = self._deserialize("Lots", pipeline_response)
256+
list_of_elem = deserialized.value
257+
if cls:
258+
list_of_elem = cls(list_of_elem)
259+
return deserialized.next_link or None, AsyncList(list_of_elem)
260+
261+
async def get_next(next_link=None):
262+
request = prepare_request(next_link)
263+
264+
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
265+
response = pipeline_response.http_response
266+
267+
if response.status_code not in [200]:
268+
map_error(status_code=response.status_code, response=response, error_map=error_map)
269+
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
270+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
271+
272+
return pipeline_response
273+
274+
275+
return AsyncItemPaged(
276+
get_next, extract_data
277+
)
278+
list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots'} # type: ignore

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,6 @@ class BudgetFilter(msrest.serialization.Model):
533533
534534
:ivar and_property: The logical "AND" expression. Must have at least 2 items.
535535
:vartype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties]
536-
:ivar not_property: The logical "NOT" expression.
537-
:vartype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties
538536
:ivar dimensions: Has comparison expression for a dimension.
539537
:vartype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression
540538
:ivar tags: A set of tags. Has comparison expression for a tag.
@@ -543,7 +541,6 @@ class BudgetFilter(msrest.serialization.Model):
543541

544542
_attribute_map = {
545543
'and_property': {'key': 'and', 'type': '[BudgetFilterProperties]'},
546-
'not_property': {'key': 'not', 'type': 'BudgetFilterProperties'},
547544
'dimensions': {'key': 'dimensions', 'type': 'BudgetComparisonExpression'},
548545
'tags': {'key': 'tags', 'type': 'BudgetComparisonExpression'},
549546
}
@@ -552,24 +549,20 @@ def __init__(
552549
self,
553550
*,
554551
and_property: Optional[List["BudgetFilterProperties"]] = None,
555-
not_property: Optional["BudgetFilterProperties"] = None,
556552
dimensions: Optional["BudgetComparisonExpression"] = None,
557553
tags: Optional["BudgetComparisonExpression"] = None,
558554
**kwargs
559555
):
560556
"""
561557
:keyword and_property: The logical "AND" expression. Must have at least 2 items.
562558
:paramtype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties]
563-
:keyword not_property: The logical "NOT" expression.
564-
:paramtype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties
565559
:keyword dimensions: Has comparison expression for a dimension.
566560
:paramtype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression
567561
:keyword tags: A set of tags. Has comparison expression for a tag.
568562
:paramtype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression
569563
"""
570564
super(BudgetFilter, self).__init__(**kwargs)
571565
self.and_property = and_property
572-
self.not_property = not_property
573566
self.dimensions = dimensions
574567
self.tags = tags
575568

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,43 @@ def build_list_by_billing_account_request(
9393
**kwargs
9494
)
9595

96+
97+
def build_list_by_customer_request(
98+
billing_account_id: str,
99+
customer_id: str,
100+
*,
101+
filter: Optional[str] = None,
102+
**kwargs: Any
103+
) -> HttpRequest:
104+
api_version = "2021-10-01"
105+
accept = "application/json"
106+
# Construct URL
107+
url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots')
108+
path_format_arguments = {
109+
"billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'),
110+
"customerId": _SERIALIZER.url("customer_id", customer_id, 'str'),
111+
}
112+
113+
url = _format_url_section(url, **path_format_arguments)
114+
115+
# Construct parameters
116+
query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any]
117+
query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')
118+
if filter is not None:
119+
query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str')
120+
121+
# Construct headers
122+
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
123+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
124+
125+
return HttpRequest(
126+
method="GET",
127+
url=url,
128+
params=query_parameters,
129+
headers=header_parameters,
130+
**kwargs
131+
)
132+
96133
class LotsOperations(object):
97134
"""LotsOperations operations.
98135
@@ -264,3 +301,84 @@ def get_next(next_link=None):
264301
get_next, extract_data
265302
)
266303
list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore
304+
305+
@distributed_trace
306+
def list_by_customer(
307+
self,
308+
billing_account_id: str,
309+
customer_id: str,
310+
filter: Optional[str] = None,
311+
**kwargs: Any
312+
) -> Iterable["_models.Lots"]:
313+
"""Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a
314+
billing profile and a customer. Microsoft Azure consumption commitments are only supported for
315+
the billing account scope.
316+
317+
:param billing_account_id: BillingAccount ID.
318+
:type billing_account_id: str
319+
:param customer_id: Customer ID.
320+
:type customer_id: str
321+
:param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq',
322+
'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is
323+
separated by a colon (:).
324+
:type filter: str
325+
:keyword callable cls: A custom type or function that will be passed the direct response
326+
:return: An iterator like instance of either Lots or the result of cls(response)
327+
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Lots]
328+
:raises: ~azure.core.exceptions.HttpResponseError
329+
"""
330+
cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"]
331+
error_map = {
332+
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
333+
}
334+
error_map.update(kwargs.pop('error_map', {}))
335+
def prepare_request(next_link=None):
336+
if not next_link:
337+
338+
request = build_list_by_customer_request(
339+
billing_account_id=billing_account_id,
340+
customer_id=customer_id,
341+
filter=filter,
342+
template_url=self.list_by_customer.metadata['url'],
343+
)
344+
request = _convert_request(request)
345+
request.url = self._client.format_url(request.url)
346+
347+
else:
348+
349+
request = build_list_by_customer_request(
350+
billing_account_id=billing_account_id,
351+
customer_id=customer_id,
352+
filter=filter,
353+
template_url=next_link,
354+
)
355+
request = _convert_request(request)
356+
request.url = self._client.format_url(request.url)
357+
request.method = "GET"
358+
return request
359+
360+
def extract_data(pipeline_response):
361+
deserialized = self._deserialize("Lots", pipeline_response)
362+
list_of_elem = deserialized.value
363+
if cls:
364+
list_of_elem = cls(list_of_elem)
365+
return deserialized.next_link or None, iter(list_of_elem)
366+
367+
def get_next(next_link=None):
368+
request = prepare_request(next_link)
369+
370+
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
371+
response = pipeline_response.http_response
372+
373+
if response.status_code not in [200]:
374+
map_error(status_code=response.status_code, response=response, error_map=error_map)
375+
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
376+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
377+
378+
return pipeline_response
379+
380+
381+
return ItemPaged(
382+
get_next, extract_data
383+
)
384+
list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots'} # type: ignore

0 commit comments

Comments
 (0)