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 billing/resource-manager] [DO NOT MERGE] Changes for introduction of transfer products API #4335

Closed
Closed
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
19 changes: 0 additions & 19 deletions azure-mgmt-billing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ For the older Azure Service Management (ASM) libraries, see
For a more complete set of Azure libraries, see the `azure <https://pypi.python.org/pypi/azure>`__ bundle package.


Compatibility
=============

**IMPORTANT**: If you have an earlier version of the azure package
(version < 1.0), you should uninstall it before installing this package.

You can check the version using pip:

.. code:: shell

pip freeze

If you see azure==0.11.0 (or any version below 1.0), uninstall it first:

.. code:: shell

pip uninstall azure


Usage
=====

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .operations.enrollment_accounts_operations import EnrollmentAccountsOperations
from .operations.billing_periods_operations import BillingPeriodsOperations
from .operations.invoices_operations import InvoicesOperations
from .operations.products_operations import ProductsOperations
from .operations.operations import Operations
from . import models

Expand Down Expand Up @@ -64,6 +65,8 @@ class BillingManagementClient(SDKClient):
:vartype billing_periods: azure.mgmt.billing.operations.BillingPeriodsOperations
:ivar invoices: Invoices operations
:vartype invoices: azure.mgmt.billing.operations.InvoicesOperations
:ivar products: Products operations
:vartype products: azure.mgmt.billing.operations.ProductsOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.billing.operations.Operations

Expand All @@ -82,7 +85,7 @@ def __init__(
super(BillingManagementClient, self).__init__(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2018-03-01-preview'
self.api_version = '2018-11-01-preview'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

Expand All @@ -92,5 +95,7 @@ def __init__(
self._client, self.config, self._serialize, self._deserialize)
self.invoices = InvoicesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.products = ProductsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.operations = Operations(
self._client, self.config, self._serialize, self._deserialize)
3 changes: 3 additions & 0 deletions azure-mgmt-billing/azure/mgmt/billing/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# --------------------------------------------------------------------------

try:
from .transfer_product_properties_py3 import TransferProductProperties
from .enrollment_account_py3 import EnrollmentAccount
from .billing_period_py3 import BillingPeriod
from .download_url_py3 import DownloadUrl
Expand All @@ -20,6 +21,7 @@
from .operation_py3 import Operation
from .resource_py3 import Resource
except (SyntaxError, ImportError):
from .transfer_product_properties import TransferProductProperties
from .enrollment_account import EnrollmentAccount
from .billing_period import BillingPeriod
from .download_url import DownloadUrl
Expand All @@ -35,6 +37,7 @@
from .operation_paged import OperationPaged

__all__ = [
'TransferProductProperties',
'EnrollmentAccount',
'BillingPeriod',
'DownloadUrl',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class TransferProductProperties(Model):
"""The properties of the product to initiate a transfer.

:param destination_invoice_section_id: Destination invoice section id.
:type destination_invoice_section_id: str
"""

_attribute_map = {
'destination_invoice_section_id': {'key': 'destinationInvoiceSectionId', 'type': 'str'},
}

def __init__(self, **kwargs):
super(TransferProductProperties, self).__init__(**kwargs)
self.destination_invoice_section_id = kwargs.get('destination_invoice_section_id', None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class TransferProductProperties(Model):
"""The properties of the product to initiate a transfer.

:param destination_invoice_section_id: Destination invoice section id.
:type destination_invoice_section_id: str
"""

_attribute_map = {
'destination_invoice_section_id': {'key': 'destinationInvoiceSectionId', 'type': 'str'},
}

def __init__(self, *, destination_invoice_section_id: str=None, **kwargs) -> None:
super(TransferProductProperties, self).__init__(**kwargs)
self.destination_invoice_section_id = destination_invoice_section_id
2 changes: 2 additions & 0 deletions azure-mgmt-billing/azure/mgmt/billing/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
from .enrollment_accounts_operations import EnrollmentAccountsOperations
from .billing_periods_operations import BillingPeriodsOperations
from .invoices_operations import InvoicesOperations
from .products_operations import ProductsOperations
from .operations import Operations

__all__ = [
'EnrollmentAccountsOperations',
'BillingPeriodsOperations',
'InvoicesOperations',
'ProductsOperations',
'Operations',
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BillingPeriodsOperations(object):
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-03-01-preview. Constant value: "2018-03-01-preview".
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-11-01-preview. Constant value: "2018-11-01-preview".
"""

models = models
Expand All @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.api_version = "2018-03-01-preview"
self.api_version = "2018-11-01-preview"

self.config = config

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EnrollmentAccountsOperations(object):
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-03-01-preview. Constant value: "2018-03-01-preview".
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-11-01-preview. Constant value: "2018-11-01-preview".
"""

models = models
Expand All @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.api_version = "2018-03-01-preview"
self.api_version = "2018-11-01-preview"

self.config = config

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class InvoicesOperations(object):
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-03-01-preview. Constant value: "2018-03-01-preview".
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-11-01-preview. Constant value: "2018-11-01-preview".
"""

models = models
Expand All @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.api_version = "2018-03-01-preview"
self.api_version = "2018-11-01-preview"

self.config = config

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Operations(object):
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-03-01-preview. Constant value: "2018-03-01-preview".
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-11-01-preview. Constant value: "2018-11-01-preview".
"""

models = models
Expand All @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.api_version = "2018-03-01-preview"
self.api_version = "2018-11-01-preview"

self.config = config

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# 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 uuid
from msrest.pipeline import ClientRawResponse

from .. import models


class ProductsOperations(object):
"""ProductsOperations operations.

:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
:ivar api_version: Version of the API to be used with the client request. The current version is 2018-11-01-preview. Constant value: "2018-11-01-preview".
"""

models = models

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

self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.api_version = "2018-11-01-preview"

self.config = config

def transfer(
self, billing_account_id, invoice_section_id, product_name, destination_invoice_section_id=None, custom_headers=None, raw=False, **operation_config):
"""The operation to transfer a Product to another InvoiceSection.

:param billing_account_id: billing Account Id.
:type billing_account_id: str
:param invoice_section_id: Invoice Id.
:type invoice_section_id: str
:param product_name: Product Id.
:type product_name: str
:param destination_invoice_section_id: Destination invoice section id.
:type destination_invoice_section_id: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: None or ClientRawResponse if raw=true
:rtype: None or ~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.billing.models.ErrorResponseException>`
"""
parameters = models.TransferProductProperties(destination_invoice_section_id=destination_invoice_section_id)

# Construct URL
url = self.transfer.metadata['url']
path_format_arguments = {
'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'),
'invoiceSectionId': self._serialize.url("invoice_section_id", invoice_section_id, 'str'),
'productName': self._serialize.url("product_name", product_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
body_content = self._serialize.body(parameters, 'TransferProductProperties')

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

if response.status_code not in [202]:
raise models.ErrorResponseException(self._deserialize, response)

if raw:
client_raw_response = ClientRawResponse(None, response)
client_raw_response.add_headers({
'Location': 'str',
'Retry-After': 'int',
'Azure-AsyncOperation': 'str',
})
return client_raw_response
transfer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/products/{productName}/transfer'}