Skip to content

Commit

Permalink
CodeGen from PR 22637 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge c80b871abefc9725d7cccc14a0b2f56161629906 into 0b1805b3ce076549ba4e9285a4f0f8727caf53a5
  • Loading branch information
SDKAuto committed Mar 2, 2023
1 parent d33f020 commit 8a421d0
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 31 deletions.
4 changes: 2 additions & 2 deletions sdk/commerce/azure-mgmt-commerce/_meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "18e0a756cd948b08cec7d4264f2dbbbfa53246ac",
"commit": "0fbb62af450af1d1bec07606db3b11d52c5b58ee",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.2",
"use": [
"@autorest/[email protected]",
"@autorest/[email protected]"
],
"autorest_command": "autorest specification/commerce/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.9.2 --version-tolerant=False",
"autorest_command": "autorest specification/commerce/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.9.2 --version-tolerant=False",
"readme": "specification/commerce/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 = "6.1.0b1"
VERSION = "1.0.0b1"
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def get_next(next_link=None):
)
response = pipeline_response.http_response

if response.status_code not in [200]:
if response.status_code not in [200, 202]:
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# --------------------------------------------------------------------------

from ._models_py3 import ErrorResponse
from ._models_py3 import InfoField
from ._models_py3 import MeterInfo
from ._models_py3 import MonetaryCommitment
from ._models_py3 import MonetaryCredit
Expand All @@ -26,7 +25,6 @@

__all__ = [
"ErrorResponse",
"InfoField",
"MeterInfo",
"MonetaryCommitment",
"MonetaryCredit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,6 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None,
self.message = message


class InfoField(_serialization.Model):
"""Key-value pairs of instance details in the legacy format.
:ivar project: Identifies the name of the instance provisioned by the user.
:vartype project: str
"""

_attribute_map = {
"project": {"key": "project", "type": "str"},
}

def __init__(self, *, project: Optional[str] = None, **kwargs: Any) -> None:
"""
:keyword project: Identifies the name of the instance provisioned by the user.
:paramtype project: str
"""
super().__init__(**kwargs)
self.project = project


class MeterInfo(_serialization.Model):
"""Detailed information about the meter.
Expand Down Expand Up @@ -485,7 +465,7 @@ class UsageAggregation(_serialization.Model): # pylint: disable=too-many-instan
:ivar meter_region: Region of the meterId used for billing purposes.
:vartype meter_region: str
:ivar info_fields: Key-value pairs of instance details (legacy format).
:vartype info_fields: ~azure.mgmt.commerce.models.InfoField
:vartype info_fields: any
:ivar instance_data: Key-value pairs of instance details represented as a string.
:vartype instance_data: str
"""
Expand All @@ -504,7 +484,7 @@ class UsageAggregation(_serialization.Model): # pylint: disable=too-many-instan
"meter_category": {"key": "properties.meterCategory", "type": "str"},
"meter_sub_category": {"key": "properties.meterSubCategory", "type": "str"},
"meter_region": {"key": "properties.meterRegion", "type": "str"},
"info_fields": {"key": "properties.infoFields", "type": "InfoField"},
"info_fields": {"key": "properties.infoFields", "type": "object"},
"instance_data": {"key": "properties.instanceData", "type": "str"},
}

Expand All @@ -524,7 +504,7 @@ def __init__(
meter_category: Optional[str] = None,
meter_sub_category: Optional[str] = None,
meter_region: Optional[str] = None,
info_fields: Optional["_models.InfoField"] = None,
info_fields: Optional[Any] = None,
instance_data: Optional[str] = None,
**kwargs: Any
) -> None:
Expand Down Expand Up @@ -558,7 +538,7 @@ def __init__(
:keyword meter_region: Region of the meterId used for billing purposes.
:paramtype meter_region: str
:keyword info_fields: Key-value pairs of instance details (legacy format).
:paramtype info_fields: ~azure.mgmt.commerce.models.InfoField
:paramtype info_fields: any
:keyword instance_data: Key-value pairs of instance details represented as a string.
:paramtype instance_data: str
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_next(next_link=None):
)
response = pipeline_response.http_response

if response.status_code not in [200]:
if response.status_code not in [200, 202]:
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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.
# --------------------------------------------------------------------------

import isodate

from azure.identity import DefaultAzureCredential
from azure.mgmt.commerce import UsageManagementClient

"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-commerce
# USAGE
python get_usage_aggregates_list.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""


def main():
client = UsageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="f68815e6-3c41-45ef-bbd8-5f83303c396b",
)

response = client.usage_aggregates.list(
reported_start_time=isodate.parse_datetime("2014-05-01T00:00:00+00:00"),
reported_end_time=isodate.parse_datetime("2015-06-01T00:00:00+00:00"),
)
for item in response:
print(item)


# x-ms-original-file: specification/commerce/resource-manager/Microsoft.Commerce/preview/2015-06-01-preview/examples/GetUsageAggregatesList.json
if __name__ == "__main__":
main()

0 comments on commit 8a421d0

Please sign in to comment.