Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR track2_azure-mgmt-consumption] Lots API Description Update #9935

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/consumption/azure-mgmt-consumption/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@autorest/[email protected]",
"@autorest/[email protected]"
],
"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/[email protected] --use=@autorest/[email protected] --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/[email protected] --use=@autorest/[email protected] --version=3.7.2",
"readme": "specification/consumption/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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]]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'},
}
Expand All @@ -552,24 +549,20 @@ def __init__(
self,
*,
and_property: Optional[List["BudgetFilterProperties"]] = None,
not_property: Optional["BudgetFilterProperties"] = None,
dimensions: Optional["BudgetComparisonExpression"] = None,
tags: Optional["BudgetComparisonExpression"] = None,
**kwargs
):
"""
: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.
:paramtype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression
"""
super(BudgetFilter, self).__init__(**kwargs)
self.and_property = and_property
self.not_property = not_property
self.dimensions = dimensions
self.tags = tags

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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