Skip to content

Commit

Permalink
[AutoPR commerce/resource-manager] Add type and format specifiers on …
Browse files Browse the repository at this point in the history
…quantity property. (Azure#1975) (Azure#2039)

* Generated from d99a6326aac1fd99d9db17616669eba2f188b7ff

Add type and format specifiers on quantity property.

* Rebuild by Azure#1975

* Update packaging for azure-mgmt-commerce

* Migrate tests of azure-mgmt-commerce to new framework
  • Loading branch information
lmazuel authored Feb 22, 2018
1 parent 6a79793 commit f896c05
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 52 deletions.
6 changes: 6 additions & 0 deletions azure-mgmt-commerce/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

1.0.1 (2018-02-21)
++++++++++++++++++

- usage_aggregation.quantity is now correctly declared as float
- All operation groups have now a "models" attribute

1.0.0 (2017-06-23)
++++++++++++++++++

Expand Down
6 changes: 3 additions & 3 deletions azure-mgmt-commerce/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is the Microsoft Azure Commerce Client Library.
Azure Resource Manager (ARM) is the next generation of management APIs that
replace the old Azure Service Management (ASM).

This package has been tested with Python 2.7, 3.3, 3.4, 3.5 and 3.6.
This package has been tested with Python 2.7, 3.4, 3.5 and 3.6.

For the older Azure Service Management (ASM) libraries, see
`azure-servicemanagement-legacy <https://pypi.python.org/pypi/azure-servicemanagement-legacy>`__ library.
Expand Down Expand Up @@ -37,8 +37,8 @@ Usage
=====

For code examples, see `Commerce
<https://azure-sdk-for-python.readthedocs.org/en/latest/sample_azure-mgmt-commerce.html>`__
on readthedocs.org.
<https://docs.microsoft.com/python/api/overview/azure/commerce>`__
on docs.microsoft.com.


Provide Feedback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ErrorResponse(Model):
}

def __init__(self, code=None, message=None):
super(ErrorResponse, self).__init__()
self.code = code
self.message = message

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ class InfoField(Model):
}

def __init__(self, project=None):
super(InfoField, self).__init__()
self.project = project
5 changes: 3 additions & 2 deletions azure-mgmt-commerce/azure/mgmt/commerce/models/meter_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class MeterInfo(Model):
:type unit: str
:param meter_tags: Provides additional meter data. 'Third Party' indicates
a meter with no discount. Blanks indicate First Party.
:type meter_tags: list of str
:type meter_tags: list[str]
:param meter_region: The region in which the Azure service is available.
:type meter_region: str
:param meter_rates: The list of key/value pairs for the meter rates, in
the format 'key':'value' where key = the meter quantity, and value = the
corresponding price
:type meter_rates: dict
:type meter_rates: dict[str, float]
:param effective_date: Indicates the date from which the meter rate is
effective.
:type effective_date: datetime
Expand All @@ -59,6 +59,7 @@ class MeterInfo(Model):
}

def __init__(self, meter_id=None, meter_name=None, meter_category=None, meter_sub_category=None, unit=None, meter_tags=None, meter_region=None, meter_rates=None, effective_date=None, included_quantity=None):
super(MeterInfo, self).__init__()
self.meter_id = meter_id
self.meter_name = meter_name
self.meter_category = meter_category
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class MonetaryCommitment(OfferTermInfo):
:param effective_date: Indicates the date from which the offer term is
effective.
:type effective_date: datetime
:param name: Polymorphic Discriminator
:param name: Constant filled by server.
:type name: str
:param tiered_discount: The list of key/value pairs for the tiered meter
rates, in the format 'key':'value' where key = price, and value = the
corresponding discount percentage. This field is used only by offer terms
of type 'Monetary Commitment'.
:type tiered_discount: dict
:type tiered_discount: dict[str, decimal.Decimal]
:param excluded_meter_ids: An array of meter ids that are excluded from
the given offer terms.
:type excluded_meter_ids: list of str
:type excluded_meter_ids: list[str]
"""

_validation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class MonetaryCredit(OfferTermInfo):
:param effective_date: Indicates the date from which the offer term is
effective.
:type effective_date: datetime
:param name: Polymorphic Discriminator
:param name: Constant filled by server.
:type name: str
:param credit: The amount of credit provided under the terms of the given
offer level.
:type credit: decimal.Decimal
:param excluded_meter_ids: An array of meter ids that are excluded from
the given offer terms.
:type excluded_meter_ids: list of str
:type excluded_meter_ids: list[str]
"""

_validation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
class OfferTermInfo(Model):
"""Describes the offer term.
You probably want to use the sub-classes and not this class directly. Known
sub-classes are: MonetaryCredit, MonetaryCommitment, RecurringCharge
:param effective_date: Indicates the date from which the offer term is
effective.
:type effective_date: datetime
:param name: Polymorphic Discriminator
:param name: Constant filled by server.
:type name: str
"""

Expand All @@ -36,5 +39,6 @@ class OfferTermInfo(Model):
}

def __init__(self, effective_date=None):
super(OfferTermInfo, self).__init__()
self.effective_date = effective_date
self.name = None
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class RateCardQueryParameters(Model):
}

def __init__(self, offer_durable_id, currency, locale, region_info):
super(RateCardQueryParameters, self).__init__()
self.offer_durable_id = offer_durable_id
self.currency = currency
self.locale = locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RecurringCharge(OfferTermInfo):
:param effective_date: Indicates the date from which the offer term is
effective.
:type effective_date: datetime
:param name: Polymorphic Discriminator
:param name: Constant filled by server.
:type name: str
:param recurring_charge: The amount of recurring charge as per the offer
term.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ class ResourceRateCardInfo(Model):
returned as 'false'.
:type is_tax_included: bool
:param offer_terms: A list of offer terms.
:type offer_terms: list of :class:`OfferTermInfo
<azure.mgmt.commerce.models.OfferTermInfo>`
:type offer_terms: list[~azure.mgmt.commerce.models.OfferTermInfo]
:param meters: A list of meters.
:type meters: list of :class:`MeterInfo
<azure.mgmt.commerce.models.MeterInfo>`
:type meters: list[~azure.mgmt.commerce.models.MeterInfo]
"""

_attribute_map = {
Expand All @@ -39,6 +37,7 @@ class ResourceRateCardInfo(Model):
}

def __init__(self, currency=None, locale=None, is_tax_included=None, offer_terms=None, meters=None):
super(ResourceRateCardInfo, self).__init__()
self.currency = currency
self.locale = locale
self.is_tax_included = is_tax_included
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UsageAggregation(Model):
:type usage_end_time: datetime
:param quantity: The amount of the resource consumption that occurred in
this time frame.
:type quantity: object
:type quantity: float
:param unit: The unit in which the usage for this resource is being
counted, e.g. Hours, GB.
:type unit: str
Expand All @@ -47,8 +47,7 @@ class UsageAggregation(Model):
:param meter_region: Region of the meterId used for billing purposes
:type meter_region: str
:param info_fields: Key-value pairs of instance details (legacy format).
:type info_fields: :class:`InfoField
<azure.mgmt.commerce.models.InfoField>`
:type info_fields: ~azure.mgmt.commerce.models.InfoField
:param instance_data: Key-value pairs of instance details represented as a
string.
:type instance_data: str
Expand All @@ -62,7 +61,7 @@ class UsageAggregation(Model):
'meter_id': {'key': 'properties.meterId', 'type': 'str'},
'usage_start_time': {'key': 'properties.usageStartTime', 'type': 'iso-8601'},
'usage_end_time': {'key': 'properties.usageEndTime', 'type': 'iso-8601'},
'quantity': {'key': 'properties.quantity', 'type': 'object'},
'quantity': {'key': 'properties.quantity', 'type': 'float'},
'unit': {'key': 'properties.unit', 'type': 'str'},
'meter_name': {'key': 'properties.meterName', 'type': 'str'},
'meter_category': {'key': 'properties.meterCategory', 'type': 'str'},
Expand All @@ -73,6 +72,7 @@ class UsageAggregation(Model):
}

def __init__(self, id=None, name=None, type=None, subscription_id=None, meter_id=None, usage_start_time=None, usage_end_time=None, quantity=None, unit=None, meter_name=None, meter_category=None, meter_sub_category=None, meter_region=None, info_fields=None, instance_data=None):
super(UsageAggregation, self).__init__()
self.id = id
self.name = name
self.type = type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class RateCardOperations(object):
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An objec model deserializer.
:param deserializer: An object model deserializer.
:ivar api_version: Client Api Version. Constant value: "2015-06-01-preview".
"""

models = models

def __init__(self, client, config, serializer, deserializer):

self._client = client
Expand Down Expand Up @@ -56,18 +58,14 @@ def get(
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: :class:`ResourceRateCardInfo
<azure.mgmt.commerce.models.ResourceRateCardInfo>` or
:class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
raw=true
:rtype: :class:`ResourceRateCardInfo
<azure.mgmt.commerce.models.ResourceRateCardInfo>` or
:class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
:return: ResourceRateCardInfo or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.commerce.models.ResourceRateCardInfo or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.commerce.models.ErrorResponseException>`
"""
# Construct URL
url = '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/RateCard'
url = self.get.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
}
Expand All @@ -90,7 +88,7 @@ def get(

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, **operation_config)
response = self._client.send(request, header_parameters, stream=False, **operation_config)

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)
Expand All @@ -105,3 +103,4 @@ def get(
return client_raw_response

return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/RateCard'}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class UsageAggregatesOperations(object):
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An objec model deserializer.
:param deserializer: An object model deserializer.
:ivar api_version: Client Api Version. Constant value: "2015-06-01-preview".
"""

models = models

def __init__(self, client, config, serializer, deserializer):

self._client = client
Expand Down Expand Up @@ -55,8 +57,8 @@ def list(
:param aggregation_granularity: `Daily` (default) returns the data in
daily granularity, `Hourly` returns the data in hourly granularity.
Possible values include: 'Daily', 'Hourly'
:type aggregation_granularity: str or :class:`AggregationGranularity
<azure.mgmt.commerce.models.AggregationGranularity>`
:type aggregation_granularity: str or
~azure.mgmt.commerce.models.AggregationGranularity
:param continuation_token: Used when a continuation token string is
provided in the response body of the previous call, enabling paging
through a large result set. If not present, the data is retrieved from
Expand All @@ -67,18 +69,17 @@ def list(
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: An iterator like instance of :class:`UsageAggregation
<azure.mgmt.commerce.models.UsageAggregation>`
:rtype: :class:`UsageAggregationPaged
<azure.mgmt.commerce.models.UsageAggregationPaged>`
:return: An iterator like instance of UsageAggregation
:rtype:
~azure.mgmt.commerce.models.UsageAggregationPaged[~azure.mgmt.commerce.models.UsageAggregation]
:raises:
:class:`ErrorResponseException<azure.mgmt.commerce.models.ErrorResponseException>`
"""
def internal_paging(next_link=None, raw=False):

if not next_link:
# Construct URL
url = '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates'
url = self.list.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
}
Expand Down Expand Up @@ -113,7 +114,7 @@ def internal_paging(next_link=None, raw=False):
# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(
request, header_parameters, **operation_config)
request, header_parameters, stream=False, **operation_config)

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)
Expand All @@ -129,3 +130,4 @@ def internal_paging(next_link=None, raw=False):
return client_raw_response

return deserialized
list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates'}
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ def __init__(
raise ValueError("Parameter 'credentials' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
if not isinstance(subscription_id, str):
raise TypeError("Parameter 'subscription_id' must be str.")
if not base_url:
base_url = 'https://management.azure.com'

super(UsageManagementClientConfiguration, self).__init__(base_url)

self.add_user_agent('usagemanagementclient/{}'.format(VERSION))
self.add_user_agent('azure-mgmt-commerce/{}'.format(VERSION))
self.add_user_agent('Azure-SDK-For-Python')

self.credentials = credentials
Expand Down
2 changes: 1 addition & 1 deletion azure-mgmt-commerce/azure/mgmt/commerce/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "1.0.0"
VERSION = "1.0.1"

9 changes: 4 additions & 5 deletions azure-mgmt-commerce/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,24 @@
long_description=readme + '\n\n' + history,
license='MIT License',
author='Microsoft Corporation',
author_email='ptvshelp@microsoft.com',
author_email='azpysdkhelp@microsoft.com',
url='https://github.com/Azure/azure-sdk-for-python',
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'License :: OSI Approved :: MIT License',
],
zip_safe=False,
packages=find_packages(),
packages=find_packages(exclude=["tests"]),
install_requires=[
'msrestazure~=0.4.8',
'azure-common~=1.1.6',
'msrestazure>=0.4.20,<2.0.0',
'azure-common~=1.1',
],
cmdclass=cmdclass
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

import azure.mgmt.commerce
from datetime import date, timedelta
from testutils.common_recordingtestcase import record
from tests.mgmt_testcase import HttpStatusCode, AzureMgmtTestCase

from devtools_testutils import AzureMgmtTestCase

class MgmtCommerceTest(AzureMgmtTestCase):

Expand All @@ -21,7 +19,6 @@ def setUp(self):
azure.mgmt.commerce.UsageManagementClient
)

@record
def test_commerce(self):
# Test not recorded for privacy concerns
#output = self.commerce_client.usage_aggregates.list(
Expand Down

0 comments on commit f896c05

Please sign in to comment.