From 8efc9e4c69fbec2b72ced3458c019d1d35b63395 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 30 Mar 2021 02:01:18 +0000 Subject: [PATCH] CodeGen from PR 13691 in Azure/azure-rest-api-specs Update readme.md (#13691) --- src/billing/HISTORY.rst | 8 + src/billing/README.md | 250 ++ src/billing/azext_billing/__init__.py | 50 + src/billing/azext_billing/action.py | 17 + src/billing/azext_billing/azext_metadata.json | 3 + src/billing/azext_billing/custom.py | 17 + .../azext_billing/generated/__init__.py | 12 + .../generated/_client_factory.py | 80 + src/billing/azext_billing/generated/_help.py | 758 ++++ .../azext_billing/generated/_params.py | 303 ++ .../azext_billing/generated/_validators.py | 9 + src/billing/azext_billing/generated/action.py | 109 + .../azext_billing/generated/commands.py | 173 + src/billing/azext_billing/generated/custom.py | 488 +++ src/billing/azext_billing/manual/__init__.py | 12 + src/billing/azext_billing/tests/__init__.py | 116 + .../azext_billing/tests/latest/__init__.py | 12 + .../tests/latest/example_steps.py | 728 ++++ .../tests/latest/test_billing_scenario.py | 260 ++ .../azext_billing/vendored_sdks/__init__.py | 12 + .../vendored_sdks/billing/__init__.py | 16 + .../billing/_billing_management_client.py | 164 + .../vendored_sdks/billing/_configuration.py | 69 + .../vendored_sdks/billing/aio/__init__.py | 10 + .../billing/aio/_billing_management_client.py | 158 + .../billing/aio/_configuration.py | 65 + .../billing/aio/operations/__init__.py | 51 + .../aio/operations/_address_operations.py | 97 + .../aio/operations/_agreements_operations.py | 180 + .../_available_balances_operations.py | 101 + .../_billing_accounts_operations.py | 364 ++ .../operations/_billing_periods_operations.py | 187 + .../_billing_permissions_operations.py | 338 ++ .../_billing_profiles_operations.py | 315 ++ .../_billing_property_operations.py | 155 + .../_billing_role_assignments_operations.py | 650 +++ .../_billing_role_definitions_operations.py | 456 +++ .../_billing_subscriptions_operations.py | 659 +++ .../aio/operations/_customers_operations.py | 274 ++ .../_enrollment_accounts_operations.py | 159 + .../operations/_instructions_operations.py | 250 ++ .../_invoice_sections_operations.py | 320 ++ .../aio/operations/_invoices_operations.py | 948 +++++ .../billing/aio/operations/_operations.py | 105 + .../aio/operations/_policies_operations.py | 293 ++ .../aio/operations/_products_operations.py | 638 +++ .../operations/_transactions_operations.py | 117 + .../vendored_sdks/billing/models/__init__.py | 294 ++ .../_billing_management_client_enums.py | 327 ++ .../vendored_sdks/billing/models/_models.py | 3371 ++++++++++++++++ .../billing/models/_models_py3.py | 3521 +++++++++++++++++ .../billing/operations/__init__.py | 51 + .../billing/operations/_address_operations.py | 102 + .../operations/_agreements_operations.py | 186 + .../_available_balances_operations.py | 106 + .../_billing_accounts_operations.py | 373 ++ .../operations/_billing_periods_operations.py | 193 + .../_billing_permissions_operations.py | 346 ++ .../_billing_profiles_operations.py | 323 ++ .../_billing_property_operations.py | 161 + .../_billing_role_assignments_operations.py | 663 ++++ .../_billing_role_definitions_operations.py | 466 +++ .../_billing_subscriptions_operations.py | 672 ++++ .../operations/_customers_operations.py | 281 ++ .../_enrollment_accounts_operations.py | 165 + .../operations/_instructions_operations.py | 257 ++ .../_invoice_sections_operations.py | 328 ++ .../operations/_invoices_operations.py | 966 +++++ .../billing/operations/_operations.py | 110 + .../operations/_policies_operations.py | 301 ++ .../operations/_products_operations.py | 650 +++ .../operations/_transactions_operations.py | 122 + .../vendored_sdks/billing/py.typed | 1 + src/billing/report.md | 931 +++++ src/billing/setup.cfg | 1 + src/billing/setup.py | 58 + 76 files changed, 25882 insertions(+) create mode 100644 src/billing/HISTORY.rst create mode 100644 src/billing/README.md create mode 100644 src/billing/azext_billing/__init__.py create mode 100644 src/billing/azext_billing/action.py create mode 100644 src/billing/azext_billing/azext_metadata.json create mode 100644 src/billing/azext_billing/custom.py create mode 100644 src/billing/azext_billing/generated/__init__.py create mode 100644 src/billing/azext_billing/generated/_client_factory.py create mode 100644 src/billing/azext_billing/generated/_help.py create mode 100644 src/billing/azext_billing/generated/_params.py create mode 100644 src/billing/azext_billing/generated/_validators.py create mode 100644 src/billing/azext_billing/generated/action.py create mode 100644 src/billing/azext_billing/generated/commands.py create mode 100644 src/billing/azext_billing/generated/custom.py create mode 100644 src/billing/azext_billing/manual/__init__.py create mode 100644 src/billing/azext_billing/tests/__init__.py create mode 100644 src/billing/azext_billing/tests/latest/__init__.py create mode 100644 src/billing/azext_billing/tests/latest/example_steps.py create mode 100644 src/billing/azext_billing/tests/latest/test_billing_scenario.py create mode 100644 src/billing/azext_billing/vendored_sdks/__init__.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/__init__.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/_billing_management_client.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/_configuration.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/__init__.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/_billing_management_client.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/_configuration.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/__init__.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_address_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_agreements_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_available_balances_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_accounts_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_periods_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_permissions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_profiles_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_property_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_assignments_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_definitions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_subscriptions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_customers_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_enrollment_accounts_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_instructions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoice_sections_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoices_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_policies_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_products_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/aio/operations/_transactions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/models/__init__.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/models/_billing_management_client_enums.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/models/_models.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/models/_models_py3.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/__init__.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_address_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_agreements_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_available_balances_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_accounts_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_periods_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_permissions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_profiles_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_property_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_assignments_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_definitions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_billing_subscriptions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_customers_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_enrollment_accounts_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_instructions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_invoice_sections_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_invoices_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_policies_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_products_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/operations/_transactions_operations.py create mode 100644 src/billing/azext_billing/vendored_sdks/billing/py.typed create mode 100644 src/billing/report.md create mode 100644 src/billing/setup.cfg create mode 100644 src/billing/setup.py diff --git a/src/billing/HISTORY.rst b/src/billing/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /dev/null +++ b/src/billing/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/billing/README.md b/src/billing/README.md new file mode 100644 index 00000000000..548cf04a5fd --- /dev/null +++ b/src/billing/README.md @@ -0,0 +1,250 @@ +# Azure CLI billing Extension # +This is the extension for billing + +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name billing +``` + +### Included Features ### +#### billing account #### +##### List ##### +``` +az billing account list +``` +##### List ##### +``` +az billing account list --expand "soldTo,billingProfiles,billingProfiles/invoiceSections" +``` +##### List ##### +``` +az billing account list --expand "enrollmentDetails,departments,enrollmentAccounts" +``` +##### Show ##### +``` +az billing account show --expand "soldTo,billingProfiles,billingProfiles/invoiceSections" --name "{billingAccountName}" +``` +##### Show ##### +``` +az billing account show --name "{billingAccountName}" +``` +##### Update ##### +``` +az billing account update --name "{billingAccountName}" --display-name "Test Account" \ + --sold-to address-line1="Test Address 1" city="Redmond" company-name="Contoso" country="US" first-name="Test" last-name="User" postal-code="12345" region="WA" +``` +#### billing balance #### +##### Show ##### +``` +az billing balance show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +#### billing instruction #### +##### Create ##### +``` +az billing instruction create --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --name "{instructionName}" --amount 5000 --end-date "2020-12-30T21:26:47.997Z" \ + --start-date "2019-12-30T21:26:47.997Z" +``` +##### Show ##### +``` +az billing instruction show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --name "{instructionName}" +``` +##### List ##### +``` +az billing instruction list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +#### billing profile #### +##### Create ##### +``` +az billing profile create --account-name "{billingAccountName}" --name "{billingProfileName}" \ + --bill-to address-line1="Test Address 1" city="Redmond" country="US" first-name="Test" last-name="User" postal-code="12345" region="WA" \ + --display-name "Finance" --enabled-azure-plans sku-id="0001" --enabled-azure-plans sku-id="0002" \ + --invoice-email-opt-in true --po-number "ABC12345" +``` +##### List ##### +``` +az billing profile list --expand "invoiceSections" --account-name "{billingAccountName}" +``` +##### Show ##### +``` +az billing profile show --account-name "{billingAccountName}" --name "{billingProfileName}" +``` +##### Show ##### +``` +az billing profile show --expand "invoiceSections" --account-name "{billingAccountName}" --name "{billingProfileName}" +``` +##### List ##### +``` +az billing profile list --account-name "{billingAccountName}" +``` +#### billing customer #### +##### List ##### +``` +az billing customer list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Show ##### +``` +az billing customer show --account-name "{billingAccountName}" --name "{customerName}" +``` +##### Show ##### +``` +az billing customer show --expand "enabledAzurePlans,resellers" --account-name "{billingAccountName}" \ + --name "{customerName}" +``` +#### billing invoice section #### +##### Create ##### +``` +az billing invoice section create --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --name "{invoiceSectionName}" --display-name "invoiceSection1" --labels costCategory="Support" pcCode="A123456" +``` +##### Show ##### +``` +az billing invoice section show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --name "{invoiceSectionName}" +``` +##### List ##### +``` +az billing invoice section list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +#### billing permission #### +##### List ##### +``` +az billing permission list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --invoice-section-name "{invoiceSectionName}" +``` +#### billing subscription #### +##### List ##### +``` +az billing subscription list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --invoice-section-name "{invoiceSectionName}" +``` +##### Show ##### +``` +az billing subscription show --account-name "{billingAccountName}" +``` +##### Update ##### +``` +az billing subscription update --account-name "{billingAccountName}" --cost-center "ABC1234" +``` +##### Move ##### +``` +az billing subscription move --account-name "{billingAccountName}" \ + --destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}" +``` +##### Validate-move ##### +``` +az billing subscription validate-move --account-name "{billingAccountName}" \ + --destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}" +``` +##### Validate-move ##### +``` +az billing subscription validate-move --account-name "{billingAccountName}" \ + --destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}" +``` +#### billing product #### +##### List ##### +``` +az billing product list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --invoice-section-name "{invoiceSectionName}" +``` +##### Show ##### +``` +az billing product show --account-name "{billingAccountName}" --name "{productName}" +``` +##### Update ##### +``` +az billing product update --account-name "{billingAccountName}" --auto-renew "Off" --name "{productName}" +``` +##### Move ##### +``` +az billing product move --account-name "{billingAccountName}" \ + --destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}" \ + --name "{productName}" +``` +##### Validate-move ##### +``` +az billing product validate-move --account-name "{billingAccountName}" \ + --destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}" \ + --name "{productName}" +``` +##### Validate-move ##### +``` +az billing product validate-move --account-name "{billingAccountName}" \ + --destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{newInvoiceSectionName}" \ + --name "{productName}" +``` +#### billing invoice #### +##### List ##### +``` +az billing invoice list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --period-end-date "2018-06-30" --period-start-date "2018-01-01" +``` +##### List ##### +``` +az billing invoice list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --period-end-date "2018-06-30" --period-start-date "2018-01-01" +``` +##### Show ##### +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +##### Show ##### +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +##### Show ##### +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +##### Show ##### +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +#### billing transaction #### +##### List ##### +``` +az billing transaction list --account-name "{billingAccountName}" --invoice-name "{invoiceName}" +``` +#### billing policy #### +##### Update ##### +``` +az billing policy update --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --marketplace-purchases "OnlyFreeAllowed" --reservation-purchases "NotAllowed" --view-charges "Allowed" +``` +#### billing property #### +##### Show ##### +``` +az billing property show +``` +##### Update ##### +``` +az billing property update --cost-center "1010" +``` +#### billing role-definition #### +##### List ##### +``` +az billing role-definition list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --invoice-section-name "{invoiceSectionName}" +``` +#### billing role-assignment #### +##### List ##### +``` +az billing role-assignment list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --invoice-section-name "{invoiceSectionName}" +``` +##### Delete ##### +``` +az billing role-assignment delete --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ + --name "{billingRoleAssignmentName}" --invoice-section-name "{invoiceSectionName}" +``` +#### billing agreement #### +##### List ##### +``` +az billing agreement list --account-name "{billingAccountName}" +``` +##### Show ##### +``` +az billing agreement show --name "{agreementName}" --account-name "{billingAccountName}" +``` \ No newline at end of file diff --git a/src/billing/azext_billing/__init__.py b/src/billing/azext_billing/__init__.py new file mode 100644 index 00000000000..e4719b222b7 --- /dev/null +++ b/src/billing/azext_billing/__init__.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core import AzCommandsLoader +from azext_billing.generated._help import helps # pylint: disable=unused-import +try: + from azext_billing.manual._help import helps # pylint: disable=reimported +except ImportError: + pass + + +class BillingManagementClientCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_billing.generated._client_factory import cf_billing_cl + billing_custom = CliCommandType( + operations_tmpl='azext_billing.custom#{}', + client_factory=cf_billing_cl) + parent = super(BillingManagementClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=billing_custom) + + def load_command_table(self, args): + from azext_billing.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_billing.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_billing.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_billing.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = BillingManagementClientCommandsLoader diff --git a/src/billing/azext_billing/action.py b/src/billing/azext_billing/action.py new file mode 100644 index 00000000000..d95d53bf711 --- /dev/null +++ b/src/billing/azext_billing/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/billing/azext_billing/azext_metadata.json b/src/billing/azext_billing/azext_metadata.json new file mode 100644 index 00000000000..3695b0d7077 --- /dev/null +++ b/src/billing/azext_billing/azext_metadata.json @@ -0,0 +1,3 @@ +{ + "azext.minCliCoreVersion": "2.15.0" +} \ No newline at end of file diff --git a/src/billing/azext_billing/custom.py b/src/billing/azext_billing/custom.py new file mode 100644 index 00000000000..dbe9d5f9742 --- /dev/null +++ b/src/billing/azext_billing/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/billing/azext_billing/generated/__init__.py b/src/billing/azext_billing/generated/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/billing/azext_billing/generated/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/billing/azext_billing/generated/_client_factory.py b/src/billing/azext_billing/generated/_client_factory.py new file mode 100644 index 00000000000..6a9c4268d64 --- /dev/null +++ b/src/billing/azext_billing/generated/_client_factory.py @@ -0,0 +1,80 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def cf_billing_cl(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azext_billing.vendored_sdks.billing import BillingManagementClient + return get_mgmt_service_client(cli_ctx, + BillingManagementClient) + + +def cf_billing_account(cli_ctx, *_): + return cf_billing_cl(cli_ctx).billing_accounts + + +def cf_available_balance(cli_ctx, *_): + return cf_billing_cl(cli_ctx).available_balances + + +def cf_instruction(cli_ctx, *_): + return cf_billing_cl(cli_ctx).instructions + + +def cf_billing_profile(cli_ctx, *_): + return cf_billing_cl(cli_ctx).billing_profiles + + +def cf_customer(cli_ctx, *_): + return cf_billing_cl(cli_ctx).customers + + +def cf_invoice_section(cli_ctx, *_): + return cf_billing_cl(cli_ctx).invoice_sections + + +def cf_billing_permission(cli_ctx, *_): + return cf_billing_cl(cli_ctx).billing_permissions + + +def cf_billing_subscription(cli_ctx, *_): + return cf_billing_cl(cli_ctx).billing_subscriptions + + +def cf_product(cli_ctx, *_): + return cf_billing_cl(cli_ctx).products + + +def cf_invoice(cli_ctx, *_): + return cf_billing_cl(cli_ctx).invoices + + +def cf_transaction(cli_ctx, *_): + return cf_billing_cl(cli_ctx).transactions + + +def cf_policy(cli_ctx, *_): + return cf_billing_cl(cli_ctx).policies + + +def cf_billing_property(cli_ctx, *_): + return cf_billing_cl(cli_ctx).billing_property + + +def cf_billing_role_definition(cli_ctx, *_): + return cf_billing_cl(cli_ctx).billing_role_definitions + + +def cf_billing_role_assignment(cli_ctx, *_): + return cf_billing_cl(cli_ctx).billing_role_assignments + + +def cf_agreement(cli_ctx, *_): + return cf_billing_cl(cli_ctx).agreements diff --git a/src/billing/azext_billing/generated/_help.py b/src/billing/azext_billing/generated/_help.py new file mode 100644 index 00000000000..46ce387f73f --- /dev/null +++ b/src/billing/azext_billing/generated/_help.py @@ -0,0 +1,758 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['billing account'] = """ + type: group + short-summary: Manage account with billing +""" + +helps['billing account list'] = """ + type: command + short-summary: "Lists the billing accounts that a user has access to." + examples: + - name: BillingAccountsList + text: |- + az billing account list + - name: BillingAccountsListWithExpand + text: |- + az billing account list --expand "soldTo,billingProfiles,billingProfiles/invoiceSections" + - name: BillingAccountsListWithExpandForEnrollmentDetails + text: |- + az billing account list --expand "enrollmentDetails,departments,enrollmentAccounts" +""" + +helps['billing account show'] = """ + type: command + short-summary: "Gets a billing account by its ID." + examples: + - name: BillingAccountWithExpand + text: |- + az billing account show --expand "soldTo,billingProfiles,billingProfiles/invoiceSections" --name \ +"{billingAccountName}" + - name: BillingAccounts + text: |- + az billing account show --name "{billingAccountName}" +""" + +helps['billing account update'] = """ + type: command + short-summary: "Updates the properties of a billing account. Currently, displayName and address can be updated. \ +The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement." + parameters: + - name: --sold-to + short-summary: "The address of the individual or organization that is responsible for the billing account." + long-summary: | + Usage: --sold-to first-name=XX last-name=XX company-name=XX address-line1=XX address-line2=XX \ +address-line3=XX city=XX district=XX region=XX country=XX postal-code=XX email=XX phone-number=XX + + first-name: First name. + last-name: Last name. + company-name: Company name. + address-line1: Required. Address line 1. + address-line2: Address line 2. + address-line3: Address line 3. + city: Address city. + district: Address district. + region: Address region. + country: Required. Country code uses ISO2, 2-digit format. + postal-code: Postal code. + email: Email address. + phone-number: Phone number. + examples: + - name: UpdateBillingAccount + text: |- + az billing account update --name "{billingAccountName}" --display-name "Test Account" --sold-to \ +address-line1="Test Address 1" city="Redmond" company-name="Contoso" country="US" first-name="Test" last-name="User" \ +postal-code="12345" region="WA" +""" + +helps['billing account wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the billing account is met. + examples: + - name: Pause executing next line of CLI script until the billing account is successfully updated. + text: |- + az billing account wait --name "{billingAccountName}" --updated +""" + +helps['billing balance'] = """ + type: group + short-summary: Manage balance with billing +""" + +helps['billing balance show'] = """ + type: command + short-summary: "The available credit balance for a billing profile. This is the balance that can be used for pay \ +now to settle due or past due invoices. The operation is supported only for billing accounts with agreement type \ +Microsoft Customer Agreement." + examples: + - name: AvailableBalanceByBillingProfile + text: |- + az billing balance show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +""" + +helps['billing instruction'] = """ + type: group + short-summary: Manage instruction with billing +""" + +helps['billing instruction list'] = """ + type: command + short-summary: "Lists the instructions by billing profile id." + examples: + - name: InstructionsListByBillingProfile + text: |- + az billing instruction list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +""" + +helps['billing instruction show'] = """ + type: command + short-summary: "Get the instruction by name. These are custom billing instructions and are only applicable for \ +certain customers." + examples: + - name: Instruction + text: |- + az billing instruction show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--name "{instructionName}" +""" + +helps['billing instruction create'] = """ + type: command + short-summary: "Creates or updates an instruction. These are custom billing instructions and are only applicable \ +for certain customers." + examples: + - name: PutInstruction + text: |- + az billing instruction create --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --name "{instructionName}" --amount 5000 --end-date "2020-12-30T21:26:47.997Z" --start-date \ +"2019-12-30T21:26:47.997Z" +""" + +helps['billing profile'] = """ + type: group + short-summary: Manage profile with billing +""" + +helps['billing profile list'] = """ + type: command + short-summary: "Lists the billing profiles that a user has access to. The operation is supported for billing \ +accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement." + examples: + - name: BillingProfilesListByBillingAccount + text: |- + az billing profile list --account-name "{billingAccountName}" + - name: BillingProfilesListWithExpand + text: |- + az billing profile list --expand "invoiceSections" --account-name "{billingAccountName}" +""" + +helps['billing profile show'] = """ + type: command + short-summary: "Gets a billing profile by its ID. The operation is supported for billing accounts with agreement \ +type Microsoft Customer Agreement or Microsoft Partner Agreement." + examples: + - name: BillingProfile + text: |- + az billing profile show --account-name "{billingAccountName}" --name "{billingProfileName}" + - name: BillingProfileWithExpand + text: |- + az billing profile show --expand "invoiceSections" --account-name "{billingAccountName}" --name \ +"{billingProfileName}" +""" + +helps['billing profile create'] = """ + type: command + short-summary: "Create a billing profile. The operation is supported for billing accounts with agreement type \ +Microsoft Customer Agreement or Microsoft Partner Agreement." + parameters: + - name: --bill-to + short-summary: "Billing address." + long-summary: | + Usage: --bill-to first-name=XX last-name=XX company-name=XX address-line1=XX address-line2=XX \ +address-line3=XX city=XX district=XX region=XX country=XX postal-code=XX email=XX phone-number=XX + + first-name: First name. + last-name: Last name. + company-name: Company name. + address-line1: Required. Address line 1. + address-line2: Address line 2. + address-line3: Address line 3. + city: Address city. + district: Address district. + region: Address region. + country: Required. Country code uses ISO2, 2-digit format. + postal-code: Postal code. + email: Email address. + phone-number: Phone number. + - name: --enabled-azure-plans + short-summary: "Information about the enabled azure plans." + long-summary: | + Usage: --enabled-azure-plans sku-id=XX + + sku-id: The sku id. + + Multiple actions can be specified by using more than one --enabled-azure-plans argument. + examples: + - name: CreateBillingProfile + text: |- + az billing profile create --account-name "{billingAccountName}" --name "{billingProfileName}" --bill-to \ +address-line1="Test Address 1" city="Redmond" country="US" first-name="Test" last-name="User" postal-code="12345" \ +region="WA" --display-name "Finance" --enabled-azure-plans sku-id="0001" --enabled-azure-plans sku-id="0002" \ +--invoice-email-opt-in true --po-number "ABC12345" +""" + +helps['billing profile update'] = """ + type: command + short-summary: "Update a billing profile. The operation is supported for billing accounts with agreement type \ +Microsoft Customer Agreement or Microsoft Partner Agreement." + parameters: + - name: --bill-to + short-summary: "Billing address." + long-summary: | + Usage: --bill-to first-name=XX last-name=XX company-name=XX address-line1=XX address-line2=XX \ +address-line3=XX city=XX district=XX region=XX country=XX postal-code=XX email=XX phone-number=XX + + first-name: First name. + last-name: Last name. + company-name: Company name. + address-line1: Required. Address line 1. + address-line2: Address line 2. + address-line3: Address line 3. + city: Address city. + district: Address district. + region: Address region. + country: Required. Country code uses ISO2, 2-digit format. + postal-code: Postal code. + email: Email address. + phone-number: Phone number. + - name: --enabled-azure-plans + short-summary: "Information about the enabled azure plans." + long-summary: | + Usage: --enabled-azure-plans sku-id=XX + + sku-id: The sku id. + + Multiple actions can be specified by using more than one --enabled-azure-plans argument. +""" + +helps['billing profile wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the billing profile is met. + examples: + - name: Pause executing next line of CLI script until the billing profile is successfully created. + text: |- + az billing profile wait --expand "invoiceSections" --account-name "{billingAccountName}" --name \ +"{billingProfileName}" --created + - name: Pause executing next line of CLI script until the billing profile is successfully updated. + text: |- + az billing profile wait --expand "invoiceSections" --account-name "{billingAccountName}" --name \ +"{billingProfileName}" --updated +""" + +helps['billing customer'] = """ + type: group + short-summary: Manage customer with billing +""" + +helps['billing customer list'] = """ + type: command + short-summary: "Lists the customers that are billed to a billing profile. The operation is supported only for \ +billing accounts with agreement type Microsoft Partner Agreement. And Lists the customers that are billed to a billing \ +account. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement." + examples: + - name: CustomersListByBillingProfile + text: |- + az billing customer list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" + - name: CustomersListByBillingAccount + text: |- + az billing customer list --account-name "{billingAccountName}" +""" + +helps['billing customer show'] = """ + type: command + short-summary: "Gets a customer by its ID. The operation is supported only for billing accounts with agreement \ +type Microsoft Partner Agreement." + examples: + - name: Customer + text: |- + az billing customer show --account-name "{billingAccountName}" --name "{customerName}" + - name: CustomerWithExpand + text: |- + az billing customer show --expand "enabledAzurePlans,resellers" --account-name "{billingAccountName}" \ +--name "{customerName}" +""" + +helps['billing invoice section'] = """ + type: group + short-summary: Manage invoice section with billing +""" + +helps['billing invoice section list'] = """ + type: command + short-summary: "Lists the invoice sections that a user has access to. The operation is supported only for billing \ +accounts with agreement type Microsoft Customer Agreement." + examples: + - name: InvoiceSectionsListByBillingProfile + text: |- + az billing invoice section list --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" +""" + +helps['billing invoice section show'] = """ + type: command + short-summary: "Gets an invoice section by its ID. The operation is supported only for billing accounts with \ +agreement type Microsoft Customer Agreement." + examples: + - name: InvoiceSection + text: |- + az billing invoice section show --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --name "{invoiceSectionName}" +""" + +helps['billing invoice section create'] = """ + type: command + short-summary: "Create an invoice section. The operation is supported only for billing accounts with agreement \ +type Microsoft Customer Agreement." + examples: + - name: PutInvoiceSection + text: |- + az billing invoice section create --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --name "{invoiceSectionName}" --display-name "invoiceSection1" --labels costCategory="Support" \ +pcCode="A123456" +""" + +helps['billing invoice section update'] = """ + type: command + short-summary: "Update an invoice section. The operation is supported only for billing accounts with agreement \ +type Microsoft Customer Agreement." +""" + +helps['billing invoice section wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the billing invoice section is met. + examples: + - name: Pause executing next line of CLI script until the billing invoice section is successfully created. + text: |- + az billing invoice section wait --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --name "{invoiceSectionName}" --created + - name: Pause executing next line of CLI script until the billing invoice section is successfully updated. + text: |- + az billing invoice section wait --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --name "{invoiceSectionName}" --updated +""" + +helps['billing permission'] = """ + type: group + short-summary: Manage permission with billing +""" + +helps['billing permission list'] = """ + type: command + short-summary: "Lists the billing permissions the caller has on an invoice section. And Lists the billing \ +permissions the caller has for a customer. And Lists the billing permissions the caller has on a billing profile. And \ +Lists the billing permissions the caller has on a billing account." + examples: + - name: InvoiceSectionPermissionsList + text: |- + az billing permission list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--invoice-section-name "{invoiceSectionName}" + - name: BillingProfilePermissionsList + text: |- + az billing permission list --account-name "{billingAccountName}" --customer-name "{customerName}" + - name: BillingProfilePermissionsList + text: |- + az billing permission list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" + - name: BillingAccountPermissionsList + text: |- + az billing permission list --account-name "{billingAccountName}" +""" + +helps['billing subscription'] = """ + type: group + short-summary: Manage subscription with billing +""" + +helps['billing subscription list'] = """ + type: command + short-summary: "Lists the subscriptions that are billed to an invoice section. The operation is supported only for \ +billing accounts with agreement type Microsoft Customer Agreement. And Lists the subscriptions for a customer. The \ +operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. And Lists the \ +subscriptions that are billed to a billing profile. The operation is supported for billing accounts with agreement \ +type Microsoft Customer Agreement or Microsoft Partner Agreement. And Lists the subscriptions for a billing account. \ +The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner \ +Agreement." + examples: + - name: BillingSubscriptionsListByInvoiceSection + text: |- + az billing subscription list --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --invoice-section-name "{invoiceSectionName}" + - name: BillingSubscriptionsListByCustomer + text: |- + az billing subscription list --account-name "{billingAccountName}" --customer-name "{customerName}" + - name: BillingSubscriptionsListByBillingProfile + text: |- + az billing subscription list --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" + - name: BillingSubscriptionsListByBillingAccount + text: |- + az billing subscription list --account-name "{billingAccountName}" +""" + +helps['billing subscription show'] = """ + type: command + short-summary: "Gets a subscription by its ID. The operation is supported for billing accounts with agreement type \ +Microsoft Customer Agreement and Microsoft Partner Agreement." + examples: + - name: BillingSubscription + text: |- + az billing subscription show --account-name "{billingAccountName}" +""" + +helps['billing subscription update'] = """ + type: command + short-summary: "Updates the properties of a billing subscription. Currently, cost center can be updated. The \ +operation is supported only for billing accounts with agreement type Microsoft Customer Agreement." + examples: + - name: UpdateBillingProperty + text: |- + az billing subscription update --account-name "{billingAccountName}" --cost-center "ABC1234" +""" + +helps['billing subscription move'] = """ + type: command + short-summary: "Moves a subscription's charges to a new invoice section. The new invoice section must belong to \ +the same billing profile as the existing invoice section. This operation is supported for billing accounts with \ +agreement type Microsoft Customer Agreement." + examples: + - name: MoveBillingSubscription + text: |- + az billing subscription move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" +""" + +helps['billing subscription validate-move'] = """ + type: command + short-summary: "Validates if a subscription's charges can be moved to a new invoice section. This operation is \ +supported for billing accounts with agreement type Microsoft Customer Agreement." + examples: + - name: SubscriptionMoveValidateFailure + text: |- + az billing subscription validate-move --account-name "{billingAccountName}" \ +--destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{bi\ +llingProfileName}/invoiceSections/{newInvoiceSectionName}" + - name: SubscriptionMoveValidateSuccess + text: |- + az billing subscription validate-move --account-name "{billingAccountName}" \ +--destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{bi\ +llingProfileName}/invoiceSections/{newInvoiceSectionName}" +""" + +helps['billing subscription wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the billing subscription is met. + examples: + - name: Pause executing next line of CLI script until the billing subscription is successfully created. + text: |- + az billing subscription wait --account-name "{billingAccountName}" --created +""" + +helps['billing product'] = """ + type: group + short-summary: Manage product with billing +""" + +helps['billing product list'] = """ + type: command + short-summary: "Lists the products for an invoice section. These don't include products billed based on usage. The \ +operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. And Lists the \ +products for a billing profile. These don't include products billed based on usage. The operation is supported for \ +billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. And Lists the \ +products for a customer. These don't include products billed based on usage.The operation is supported only for \ +billing accounts with agreement type Microsoft Partner Agreement. And Lists the products for a billing account. These \ +don't include products billed based on usage. The operation is supported for billing accounts with agreement type \ +Microsoft Customer Agreement or Microsoft Partner Agreement." + examples: + - name: ProductsListByInvoiceSection + text: |- + az billing product list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--invoice-section-name "{invoiceSectionName}" + - name: ProductsListByBillingProfile + text: |- + az billing product list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" + - name: ProductsListByInvoiceSection + text: |- + az billing product list --account-name "{billingAccountName}" --customer-name "{customerName}" + - name: ProductsListByBillingAccount + text: |- + az billing product list --account-name "{billingAccountName}" +""" + +helps['billing product show'] = """ + type: command + short-summary: "Gets a product by ID. The operation is supported only for billing accounts with agreement type \ +Microsoft Customer Agreement." + examples: + - name: Product + text: |- + az billing product show --account-name "{billingAccountName}" --name "{productName}" +""" + +helps['billing product update'] = """ + type: command + short-summary: "Updates the properties of a Product. Currently, auto renew can be updated. The operation is \ +supported only for billing accounts with agreement type Microsoft Customer Agreement." + examples: + - name: UpdateBillingProperty + text: |- + az billing product update --account-name "{billingAccountName}" --auto-renew "Off" --name \ +"{productName}" +""" + +helps['billing product move'] = """ + type: command + short-summary: "Moves a product's charges to a new invoice section. The new invoice section must belong to the \ +same billing profile as the existing invoice section. This operation is supported only for products that are purchased \ +with a recurring charge and for billing accounts with agreement type Microsoft Customer Agreement." + examples: + - name: MoveProduct + text: |- + az billing product move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" --name "{productName}" +""" + +helps['billing product validate-move'] = """ + type: command + short-summary: "Validates if a product's charges can be moved to a new invoice section. This operation is \ +supported only for products that are purchased with a recurring charge and for billing accounts with agreement type \ +Microsoft Customer Agreement." + examples: + - name: SubscriptionMoveValidateFailure + text: |- + az billing product validate-move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" --name "{productName}" + - name: SubscriptionMoveValidateSuccess + text: |- + az billing product validate-move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" --name "{productName}" +""" + +helps['billing invoice'] = """ + type: group + short-summary: Manage invoice with billing +""" + +helps['billing invoice list'] = """ + type: command + short-summary: "Lists the invoices for a billing profile for a given start date and end date. The operation is \ +supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. And \ +Lists the invoices for a billing account for a given start date and end date. The operation is supported for billing \ +accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. And Lists the invoices for a \ +subscription." + examples: + - name: InvoicesListByBillingProfile + text: |- + az billing invoice list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--period-end-date "2018-06-30" --period-start-date "2018-01-01" + - name: InvoicesListByBillingProfileWithRebillDetails + text: |- + az billing invoice list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--period-end-date "2018-06-30" --period-start-date "2018-01-01" + - name: BillingAccountInvoicesList + text: |- + az billing invoice list --account-name "{billingAccountName}" --period-end-date "2018-06-30" \ +--period-start-date "2018-01-01" + - name: BillingAccountInvoicesListWithRebillDetails + text: |- + az billing invoice list --account-name "{billingAccountName}" --period-end-date "2018-06-30" \ +--period-start-date "2018-01-01" + - name: BillingSubscriptionsListByBillingAccount + text: |- + az billing invoice list --period-end-date "2018-06-30" --period-start-date "2018-01-01" +""" + +helps['billing invoice show'] = """ + type: command + short-summary: "Gets an invoice by billing account name and ID. The operation is supported for billing accounts \ +with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement." + examples: + - name: CreditNote + text: |- + az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" + - name: Invoice + text: |- + az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" + - name: InvoiceWithRebillDetails + text: |- + az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" + - name: VoidInvoice + text: |- + az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +""" + +helps['billing transaction'] = """ + type: group + short-summary: Manage transaction with billing +""" + +helps['billing transaction list'] = """ + type: command + short-summary: "Lists the transactions for an invoice. Transactions include purchases, refunds and Azure usage \ +charges." + examples: + - name: TransactionsListByInvoice + text: |- + az billing transaction list --account-name "{billingAccountName}" --invoice-name "{invoiceName}" +""" + +helps['billing policy'] = """ + type: group + short-summary: Manage policy with billing +""" + +helps['billing policy update'] = """ + type: command + short-summary: "Updates the policies for a billing profile. This operation is supported only for billing accounts \ +with agreement type Microsoft Customer Agreement." + examples: + - name: UpdatePolicy + text: |- + az billing policy update --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--marketplace-purchases "OnlyFreeAllowed" --reservation-purchases "NotAllowed" --view-charges "Allowed" +""" + +helps['billing property'] = """ + type: group + short-summary: Manage property with billing +""" + +helps['billing property show'] = """ + type: command + short-summary: "Get the billing properties for a subscription. This operation is not supported for billing \ +accounts with agreement type Enterprise Agreement." + examples: + - name: BillingProperty + text: |- + az billing property show +""" + +helps['billing property update'] = """ + type: command + short-summary: "Updates the billing property of a subscription. Currently, cost center can be updated. The \ +operation is supported only for billing accounts with agreement type Microsoft Customer Agreement." + examples: + - name: UpdateBillingProperty + text: |- + az billing property update --cost-center "1010" +""" + +helps['billing role-definition'] = """ + type: group + short-summary: Manage role definition with billing +""" + +helps['billing role-definition list'] = """ + type: command + short-summary: "Lists the role definitions for an invoice section. The operation is supported for billing accounts \ +with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. And Lists the role definitions for a \ +billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or \ +Microsoft Customer Agreement. And Lists the role definitions for a billing account. The operation is supported for \ +billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement." + examples: + - name: InvoiceSectionRoleDefinitionsList + text: |- + az billing role-definition list --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --invoice-section-name "{invoiceSectionName}" + - name: BillingProfileRoleDefinitionsList + text: |- + az billing role-definition list --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" + - name: BillingAccountRoleDefinitionsList + text: |- + az billing role-definition list --account-name "{billingAccountName}" +""" + +helps['billing role-assignment'] = """ + type: group + short-summary: Manage role assignment with billing +""" + +helps['billing role-assignment list'] = """ + type: command + short-summary: "Lists the role assignments for the caller on an invoice section. The operation is supported for \ +billing accounts with agreement type Microsoft Customer Agreement. And Lists the role assignments for the caller on a \ +billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. And \ +Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts with \ +agreement type Microsoft Partner Agreement or Microsoft Customer Agreement." + examples: + - name: InvoiceSectionRoleAssignmentList + text: |- + az billing role-assignment list --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --invoice-section-name "{invoiceSectionName}" + - name: BillingProfileRoleAssignmentList + text: |- + az billing role-assignment list --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" + - name: BillingAccountRoleAssignmentList + text: |- + az billing role-assignment list --account-name "{billingAccountName}" +""" + +helps['billing role-assignment delete'] = """ + type: command + short-summary: "Deletes a role assignment for the caller on an invoice section. The operation is supported for \ +billing accounts with agreement type Microsoft Customer Agreement. And Deletes a role assignment for the caller on a \ +billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or \ +Microsoft Customer Agreement. And Deletes a role assignment for the caller on a billing account. The operation is \ +supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement." + examples: + - name: InvoiceSectionRoleAssignmentDelete + text: |- + az billing role-assignment delete --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --name "{billingRoleAssignmentName}" --invoice-section-name "{invoiceSectionName}" + - name: BillingProfileRoleAssignmentDelete + text: |- + az billing role-assignment delete --account-name "{billingAccountName}" --profile-name \ +"{billingProfileName}" --name "{billingRoleAssignmentName}" + - name: BillingAccountRoleAssignmentDelete + text: |- + az billing role-assignment delete --account-name "{billingAccountName}" --name \ +"{billingRoleAssignmentName}" +""" + +helps['billing agreement'] = """ + type: group + short-summary: Manage agreement with billing +""" + +helps['billing agreement list'] = """ + type: command + short-summary: "Lists the agreements for a billing account." + examples: + - name: AgreementsListByBillingAccount + text: |- + az billing agreement list --account-name "{billingAccountName}" +""" + +helps['billing agreement show'] = """ + type: command + short-summary: "Gets an agreement by ID." + examples: + - name: AgreementByName + text: |- + az billing agreement show --name "{agreementName}" --account-name "{billingAccountName}" +""" diff --git a/src/billing/azext_billing/generated/_params.py b/src/billing/azext_billing/generated/_params.py new file mode 100644 index 00000000000..ebb0c829d1e --- /dev/null +++ b/src/billing/azext_billing/generated/_params.py @@ -0,0 +1,303 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + get_three_state_flag, + get_enum_type +) +from azure.cli.core.commands.validators import validate_file_or_dict +from azext_billing.action import ( + AddSoldTo, + AddEnabledAzurePlans, + AddLabels +) + + +def load_arguments(self, _): + + with self.argument_context('billing account list') as c: + c.argument('expand', type=str, + help='May be used to expand the soldTo, invoice sections and billing profiles.') + + with self.argument_context('billing account show') as c: + c.argument('account_name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a ' + 'billing account.') + c.argument('expand', type=str, + help='May be used to expand the soldTo, invoice sections and billing profiles.') + + with self.argument_context('billing account update') as c: + c.argument('account_name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a ' + 'billing account.') + c.argument('display_name', type=str, help='The billing account name.') + c.argument('sold_to', action=AddSoldTo, nargs='+', help='The address of the individual or organization that is ' + 'responsible for the billing account.') + c.argument('departments', type=validate_file_or_dict, help='The departments associated to the enrollment. ' + 'Expected value: json-string/@json-file.') + c.argument('enrollment_accounts', type=validate_file_or_dict, help='The accounts associated to the enrollment. ' + 'Expected value: json-string/@json-file.') + c.argument('value', type=validate_file_or_dict, help='The billing profiles associated with the billing ' + 'account. Expected value: json-string/@json-file.', arg_group='Billing Profiles') + + with self.argument_context('billing account wait') as c: + c.argument('account_name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a ' + 'billing account.') + c.argument('expand', type=str, + help='May be used to expand the soldTo, invoice sections and billing profiles.') + + with self.argument_context('billing balance show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + + with self.argument_context('billing instruction list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + + with self.argument_context('billing instruction show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('name', options_list=['--name', '-n'], type=str, help='Instruction Name.') + + with self.argument_context('billing instruction create') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('name', options_list=['--name', '-n'], type=str, help='Instruction Name.') + c.argument('amount', type=float, help='The amount budgeted for this billing instruction.') + c.argument('start_date', help='The date this billing instruction goes into effect.') + c.argument('end_date', help='The date this billing instruction is no longer in effect.') + c.argument('creation_date', help='The date this billing instruction was created.') + + with self.argument_context('billing profile list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('expand', type=str, help='May be used to expand the invoice sections.') + + with self.argument_context('billing profile show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a ' + 'billing profile.') + c.argument('expand', type=str, help='May be used to expand the invoice sections.') + + with self.argument_context('billing profile create') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a ' + 'billing profile.') + c.argument('display_name', type=str, help='The name of the billing profile.') + c.argument('po_number', type=str, help='The purchase order name that will appear on the invoices generated for ' + 'the billing profile.') + c.argument('bill_to', action=AddSoldTo, nargs='+', help='Billing address.') + c.argument('invoice_email_opt_in', arg_type=get_three_state_flag(), help='Flag controlling whether the ' + 'invoices for the billing profile are sent through email.') + c.argument('enabled_azure_plans', action=AddEnabledAzurePlans, nargs='+', help='Information about the enabled ' + 'azure plans.') + c.argument('value', type=validate_file_or_dict, help='The invoice sections associated to the billing profile. ' + 'Expected value: json-string/@json-file.', arg_group='Invoice Sections') + + with self.argument_context('billing profile update') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a ' + 'billing profile.') + c.argument('display_name', type=str, help='The name of the billing profile.') + c.argument('po_number', type=str, help='The purchase order name that will appear on the invoices generated for ' + 'the billing profile.') + c.argument('bill_to', action=AddSoldTo, nargs='+', help='Billing address.') + c.argument('invoice_email_opt_in', arg_type=get_three_state_flag(), help='Flag controlling whether the ' + 'invoices for the billing profile are sent through email.') + c.argument('enabled_azure_plans', action=AddEnabledAzurePlans, nargs='+', help='Information about the enabled ' + 'azure plans.') + c.argument('value', type=validate_file_or_dict, help='The invoice sections associated to the billing profile. ' + 'Expected value: json-string/@json-file.', arg_group='Invoice Sections') + c.ignore('billing_account_name', 'billing_profile_name', 'parameters') + + with self.argument_context('billing profile wait') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a ' + 'billing profile.') + c.argument('expand', type=str, help='May be used to expand the invoice sections.') + + with self.argument_context('billing customer list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('search', type=str, help='Used for searching customers by their name. Any customer with name ' + 'containing the search text will be included in the response') + c.argument('filter_', options_list=['--filter'], type=str, + help='May be used to filter the list of customers.') + + with self.argument_context('billing customer show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('customer_name', options_list=['--name', '-n', '--customer-name'], type=str, help='The ID that ' + 'uniquely identifies a customer.') + c.argument('expand', type=str, help='May be used to expand enabledAzurePlans and resellers') + + with self.argument_context('billing invoice section list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + + with self.argument_context('billing invoice section show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', options_list=['--name', '-n', '--invoice-section-name'], type=str, + help='The ID that uniquely identifies an invoice section.') + + with self.argument_context('billing invoice section create') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', options_list=['--name', '-n', '--invoice-section-name'], type=str, + help='The ID that uniquely identifies an invoice section.') + c.argument('display_name', type=str, help='The name of the invoice section.') + c.argument('labels', action=AddLabels, nargs='+', help='Dictionary of metadata associated with the invoice ' + 'section. Expect value: KEY1=VALUE1 KEY2=VALUE2 ...') + + with self.argument_context('billing invoice section update') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', options_list=['--name', '-n', '--invoice-section-name'], type=str, + help='The ID that uniquely identifies an invoice section.') + c.argument('display_name', type=str, help='The name of the invoice section.') + c.argument('labels', action=AddLabels, nargs='+', help='Dictionary of metadata associated with the invoice ' + 'section. Expect value: KEY1=VALUE1 KEY2=VALUE2 ...') + c.ignore('billing_account_name', 'billing_profile_name', 'parameters') + + with self.argument_context('billing invoice section wait') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', options_list=['--name', '-n', '--invoice-section-name'], type=str, + help='The ID that uniquely identifies an invoice section.') + + with self.argument_context('billing permission list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', type=str, help='The ID that uniquely identifies an invoice section.') + c.argument('customer_name', type=str, help='The ID that uniquely identifies a customer.') + + with self.argument_context('billing subscription list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', type=str, help='The ID that uniquely identifies an invoice section.') + c.argument('customer_name', type=str, help='The ID that uniquely identifies a customer.') + + with self.argument_context('billing subscription show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + + with self.argument_context('billing subscription update') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('subscription_billing_status', arg_type=get_enum_type(['Active', 'Inactive', 'Abandoned', 'Deleted', + 'Warning']), help='The current billing ' + 'status of the subscription.') + c.argument('cost_center', type=str, help='The cost center applied to the subscription.') + c.argument('sku_id', type=str, help='The sku ID of the Azure plan for the subscription.') + + with self.argument_context('billing subscription move') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('destination_invoice_section_id', type=str, help='The destination invoice section id.') + + with self.argument_context('billing subscription validate-move') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('destination_invoice_section_id', type=str, help='The destination invoice section id.') + + with self.argument_context('billing subscription wait') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + + with self.argument_context('billing product list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', type=str, help='The ID that uniquely identifies an invoice section.') + c.argument('filter_', options_list=['--filter'], type=str, help='May be used to filter by product type. The ' + 'filter supports \'eq\', \'lt\', \'gt\', \'le\', \'ge\', and \'and\'. It does not currently support ' + '\'ne\', \'or\', or \'not\'. Tag filter is a key value pair string where key and value are ' + 'separated by a colon (:).') + c.argument('customer_name', type=str, help='The ID that uniquely identifies a customer.') + + with self.argument_context('billing product show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('product_name', options_list=['--name', '-n', '--product-name'], type=str, help='The ID that ' + 'uniquely identifies a product.') + + with self.argument_context('billing product update') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('product_name', options_list=['--name', '-n', '--product-name'], type=str, help='The ID that ' + 'uniquely identifies a product.') + c.argument('auto_renew', arg_type=get_enum_type(['Off', 'On']), help='Indicates whether auto renewal is turned ' + 'on or off for a product.') + c.argument('status', arg_type=get_enum_type(['Active', 'Inactive', 'PastDue', 'Expiring', 'Expired', + 'Disabled', 'Cancelled', 'AutoRenew']), help='The current status ' + 'of the product.') + c.argument('billing_frequency', arg_type=get_enum_type(['OneTime', 'Monthly', 'UsageBased']), help='The ' + 'frequency at which the product will be billed.') + + with self.argument_context('billing product move') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('product_name', options_list=['--name', '-n', '--product-name'], type=str, help='The ID that ' + 'uniquely identifies a product.') + c.argument('destination_invoice_section_id', type=str, help='The destination invoice section id.') + + with self.argument_context('billing product validate-move') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('product_name', options_list=['--name', '-n', '--product-name'], type=str, help='The ID that ' + 'uniquely identifies a product.') + c.argument('destination_invoice_section_id', type=str, help='The destination invoice section id.') + + with self.argument_context('billing invoice list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('period_start_date', type=str, help='The start date to fetch the invoices. The date should be ' + 'specified in MM-DD-YYYY format.') + c.argument('period_end_date', type=str, help='The end date to fetch the invoices. The date should be specified ' + 'in MM-DD-YYYY format.') + + with self.argument_context('billing invoice show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('name', options_list=['--name', '-n'], type=str, + help='The ID that uniquely identifies an invoice.') + + with self.argument_context('billing transaction list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('invoice_name', type=str, help='The ID that uniquely identifies an invoice.') + + with self.argument_context('billing policy update') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('marketplace_purchases', arg_type=get_enum_type(['AllAllowed', 'OnlyFreeAllowed', 'NotAllowed']), + help='The policy that controls whether Azure marketplace purchases are allowed for a billing ' + 'profile.') + c.argument('reservation_purchases', arg_type=get_enum_type(['Allowed', 'NotAllowed']), help='The policy that ' + 'controls whether Azure reservation purchases are allowed for a billing profile.') + c.argument('view_charges', arg_type=get_enum_type(['Allowed', 'NotAllowed']), help='The policy that controls ' + 'whether users with Azure RBAC access to a subscription can view its charges.') + + with self.argument_context('billing property update') as c: + c.argument('cost_center', type=str, help='The cost center applied to the subscription.') + + with self.argument_context('billing role-definition list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', type=str, help='The ID that uniquely identifies an invoice section.') + + with self.argument_context('billing role-assignment list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', type=str, help='The ID that uniquely identifies an invoice section.') + + with self.argument_context('billing role-assignment delete') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('profile_name', type=str, help='The ID that uniquely identifies a billing profile.') + c.argument('invoice_section_name', type=str, help='The ID that uniquely identifies an invoice section.') + c.argument('name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies a role ' + 'assignment.') + + with self.argument_context('billing agreement list') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('expand', type=str, help='May be used to expand the participants.') + + with self.argument_context('billing agreement show') as c: + c.argument('account_name', type=str, help='The ID that uniquely identifies a billing account.') + c.argument('name', options_list=['--name', '-n'], type=str, help='The ID that uniquely identifies an ' + 'agreement.') + c.argument('expand', type=str, help='May be used to expand the participants.') diff --git a/src/billing/azext_billing/generated/_validators.py b/src/billing/azext_billing/generated/_validators.py new file mode 100644 index 00000000000..b33a44c1ebf --- /dev/null +++ b/src/billing/azext_billing/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/src/billing/azext_billing/generated/action.py b/src/billing/azext_billing/generated/action.py new file mode 100644 index 00000000000..0621500a400 --- /dev/null +++ b/src/billing/azext_billing/generated/action.py @@ -0,0 +1,109 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from collections import defaultdict +from knack.util import CLIError + + +class AddSoldTo(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.sold_to = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'first-name': + d['first_name'] = v[0] + elif kl == 'last-name': + d['last_name'] = v[0] + elif kl == 'company-name': + d['company_name'] = v[0] + elif kl == 'address-line1': + d['address_line1'] = v[0] + elif kl == 'address-line2': + d['address_line2'] = v[0] + elif kl == 'address-line3': + d['address_line3'] = v[0] + elif kl == 'city': + d['city'] = v[0] + elif kl == 'district': + d['district'] = v[0] + elif kl == 'region': + d['region'] = v[0] + elif kl == 'country': + d['country'] = v[0] + elif kl == 'postal-code': + d['postal_code'] = v[0] + elif kl == 'email': + d['email'] = v[0] + elif kl == 'phone-number': + d['phone_number'] = v[0] + else: + raise CLIError('Unsupported Key {} is provided for parameter sold_to. All possible keys are: ' + 'first-name, last-name, company-name, address-line1, address-line2, address-line3, ' + 'city, district, region, country, postal-code, email, phone-number'.format(k)) + return d + + +class AddEnabledAzurePlans(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddEnabledAzurePlans, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'sku-id': + d['sku_id'] = v[0] + else: + raise CLIError('Unsupported Key {} is provided for parameter enabled_azure_plans. All possible keys ' + 'are: sku-id'.format(k)) + return d + + +class AddLabels(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.labels = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + v = properties[k] + d[k] = v[0] + return d diff --git a/src/billing/azext_billing/generated/commands.py b/src/billing/azext_billing/generated/commands.py new file mode 100644 index 00000000000..076e869f821 --- /dev/null +++ b/src/billing/azext_billing/generated/commands.py @@ -0,0 +1,173 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals + +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_billing.generated._client_factory import cf_billing_account + billing_billing_account = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._billing_accounts_operations#BillingAccountsOpe' + 'rations.{}', + client_factory=cf_billing_account) + with self.command_group('billing account', billing_billing_account, client_factory=cf_billing_account) as g: + g.custom_command('list', 'billing_account_list') + g.custom_show_command('show', 'billing_account_show') + g.custom_command('update', 'billing_account_update', supports_no_wait=True) + g.custom_wait_command('wait', 'billing_account_show') + + from azext_billing.generated._client_factory import cf_available_balance + billing_available_balance = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._available_balances_operations#AvailableBalance' + 'sOperations.{}', + client_factory=cf_available_balance) + with self.command_group('billing balance', billing_available_balance, client_factory=cf_available_balance) as g: + g.custom_show_command('show', 'billing_balance_show') + + from azext_billing.generated._client_factory import cf_instruction + billing_instruction = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._instructions_operations#InstructionsOperations' + '.{}', + client_factory=cf_instruction) + with self.command_group('billing instruction', billing_instruction, client_factory=cf_instruction) as g: + g.custom_command('list', 'billing_instruction_list') + g.custom_show_command('show', 'billing_instruction_show') + g.custom_command('create', 'billing_instruction_create') + + from azext_billing.generated._client_factory import cf_billing_profile + billing_billing_profile = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._billing_profiles_operations#BillingProfilesOpe' + 'rations.{}', + client_factory=cf_billing_profile) + with self.command_group('billing profile', billing_billing_profile, client_factory=cf_billing_profile) as g: + g.custom_command('list', 'billing_profile_list') + g.custom_show_command('show', 'billing_profile_show') + g.custom_command('create', 'billing_profile_create', supports_no_wait=True) + g.generic_update_command('update', setter_name='begin_create_or_update', + custom_func_name='billing_profile_update', supports_no_wait=True) + g.custom_wait_command('wait', 'billing_profile_show') + + from azext_billing.generated._client_factory import cf_customer + billing_customer = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._customers_operations#CustomersOperations.{}', + client_factory=cf_customer) + with self.command_group('billing customer', billing_customer, client_factory=cf_customer) as g: + g.custom_command('list', 'billing_customer_list') + g.custom_show_command('show', 'billing_customer_show') + + from azext_billing.generated._client_factory import cf_invoice_section + billing_invoice_section = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._invoice_sections_operations#InvoiceSectionsOpe' + 'rations.{}', + client_factory=cf_invoice_section) + with self.command_group('billing invoice section', billing_invoice_section, + client_factory=cf_invoice_section) as g: + g.custom_command('list', 'billing_invoice_section_list') + g.custom_show_command('show', 'billing_invoice_section_show') + g.custom_command('create', 'billing_invoice_section_create', supports_no_wait=True) + g.generic_update_command('update', setter_name='begin_create_or_update', + custom_func_name='billing_invoice_section_update', supports_no_wait=True) + g.custom_wait_command('wait', 'billing_invoice_section_show') + + from azext_billing.generated._client_factory import cf_billing_permission + billing_billing_permission = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._billing_permissions_operations#BillingPermissi' + 'onsOperations.{}', + client_factory=cf_billing_permission) + with self.command_group('billing permission', billing_billing_permission, + client_factory=cf_billing_permission) as g: + g.custom_command('list', 'billing_permission_list') + + from azext_billing.generated._client_factory import cf_billing_subscription + billing_billing_subscription = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._billing_subscriptions_operations#BillingSubscr' + 'iptionsOperations.{}', + client_factory=cf_billing_subscription) + with self.command_group('billing subscription', billing_billing_subscription, + client_factory=cf_billing_subscription) as g: + g.custom_command('list', 'billing_subscription_list') + g.custom_show_command('show', 'billing_subscription_show') + g.custom_command('update', 'billing_subscription_update') + g.custom_command('move', 'billing_subscription_move', supports_no_wait=True) + g.custom_command('validate-move', 'billing_subscription_validate_move') + g.custom_wait_command('wait', 'billing_subscription_show') + + from azext_billing.generated._client_factory import cf_product + billing_product = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._products_operations#ProductsOperations.{}', + client_factory=cf_product) + with self.command_group('billing product', billing_product, client_factory=cf_product) as g: + g.custom_command('list', 'billing_product_list') + g.custom_show_command('show', 'billing_product_show') + g.custom_command('update', 'billing_product_update') + g.custom_command('move', 'billing_product_move') + g.custom_command('validate-move', 'billing_product_validate_move') + + from azext_billing.generated._client_factory import cf_invoice + billing_invoice = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._invoices_operations#InvoicesOperations.{}', + client_factory=cf_invoice) + with self.command_group('billing invoice', billing_invoice, client_factory=cf_invoice) as g: + g.custom_command('list', 'billing_invoice_list') + g.custom_show_command('show', 'billing_invoice_show') + + from azext_billing.generated._client_factory import cf_transaction + billing_transaction = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._transactions_operations#TransactionsOperations' + '.{}', + client_factory=cf_transaction) + with self.command_group('billing transaction', billing_transaction, client_factory=cf_transaction) as g: + g.custom_command('list', 'billing_transaction_list') + + from azext_billing.generated._client_factory import cf_policy + billing_policy = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._policies_operations#PoliciesOperations.{}', + client_factory=cf_policy) + with self.command_group('billing policy', billing_policy, client_factory=cf_policy) as g: + g.custom_command('update', 'billing_policy_update') + + from azext_billing.generated._client_factory import cf_billing_property + billing_billing_property = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._billing_property_operations#BillingPropertyOpe' + 'rations.{}', + client_factory=cf_billing_property) + with self.command_group('billing property', billing_billing_property, client_factory=cf_billing_property) as g: + g.custom_show_command('show', 'billing_property_show') + g.custom_command('update', 'billing_property_update') + + from azext_billing.generated._client_factory import cf_billing_role_definition + billing_billing_role_definition = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._billing_role_definitions_operations#BillingRol' + 'eDefinitionsOperations.{}', + client_factory=cf_billing_role_definition) + with self.command_group('billing role-definition', billing_billing_role_definition, + client_factory=cf_billing_role_definition) as g: + g.custom_command('list', 'billing_role_definition_list') + + from azext_billing.generated._client_factory import cf_billing_role_assignment + billing_billing_role_assignment = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._billing_role_assignments_operations#BillingRol' + 'eAssignmentsOperations.{}', + client_factory=cf_billing_role_assignment) + with self.command_group('billing role-assignment', billing_billing_role_assignment, + client_factory=cf_billing_role_assignment) as g: + g.custom_command('list', 'billing_role_assignment_list') + g.custom_command('delete', 'billing_role_assignment_delete', confirmation=True) + + from azext_billing.generated._client_factory import cf_agreement + billing_agreement = CliCommandType( + operations_tmpl='azext_billing.vendored_sdks.billing.operations._agreements_operations#AgreementsOperations.{}', + client_factory=cf_agreement) + with self.command_group('billing agreement', billing_agreement, client_factory=cf_agreement) as g: + g.custom_command('list', 'billing_agreement_list') + g.custom_show_command('show', 'billing_agreement_show') diff --git a/src/billing/azext_billing/generated/custom.py b/src/billing/azext_billing/generated/custom.py new file mode 100644 index 00000000000..a149b5ab03b --- /dev/null +++ b/src/billing/azext_billing/generated/custom.py @@ -0,0 +1,488 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=line-too-long +# pylint: disable=too-many-lines +# pylint: disable=unused-argument + +from azure.cli.core.util import sdk_no_wait + + +def billing_account_list(client, + expand=None): + return client.list(expand=expand) + + +def billing_account_show(client, + account_name, + expand=None): + return client.get(billing_account_name=account_name, + expand=expand) + + +def billing_account_update(client, + account_name, + display_name=None, + sold_to=None, + departments=None, + enrollment_accounts=None, + value=None, + no_wait=False): + parameters = {} + parameters['display_name'] = display_name + parameters['sold_to'] = sold_to + parameters['departments'] = departments + parameters['enrollment_accounts'] = enrollment_accounts + parameters['billing_profiles'] = {} + parameters['billing_profiles']['value'] = value + return sdk_no_wait(no_wait, + client.begin_update, + billing_account_name=account_name, + parameters=parameters) + + +def billing_balance_show(client, + account_name, + profile_name): + return client.get(billing_account_name=account_name, + billing_profile_name=profile_name) + + +def billing_instruction_list(client, + account_name, + profile_name): + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name) + + +def billing_instruction_show(client, + account_name, + profile_name, + name): + return client.get(billing_account_name=account_name, + billing_profile_name=profile_name, + instruction_name=name) + + +def billing_instruction_create(client, + account_name, + profile_name, + name, + amount=None, + start_date=None, + end_date=None, + creation_date=None): + parameters = {} + parameters['amount'] = amount + parameters['start_date'] = start_date + parameters['end_date'] = end_date + parameters['creation_date'] = creation_date + return client.put(billing_account_name=account_name, + billing_profile_name=profile_name, + instruction_name=name, + parameters=parameters) + + +def billing_profile_list(client, + account_name, + expand=None): + return client.list_by_billing_account(billing_account_name=account_name, + expand=expand) + + +def billing_profile_show(client, + account_name, + profile_name, + expand=None): + return client.get(billing_account_name=account_name, + billing_profile_name=profile_name, + expand=expand) + + +def billing_profile_create(client, + account_name, + profile_name, + display_name=None, + po_number=None, + bill_to=None, + invoice_email_opt_in=None, + enabled_azure_plans=None, + value=None, + no_wait=False): + parameters = {} + parameters['display_name'] = display_name + parameters['po_number'] = po_number + parameters['bill_to'] = bill_to + parameters['invoice_email_opt_in'] = invoice_email_opt_in + parameters['enabled_azure_plans'] = enabled_azure_plans + parameters['invoice_sections'] = {} + parameters['invoice_sections']['value'] = value + return sdk_no_wait(no_wait, + client.begin_create_or_update, + billing_account_name=account_name, + billing_profile_name=profile_name, + parameters=parameters) + + +def billing_profile_update(instance, + account_name, + profile_name, + display_name=None, + po_number=None, + bill_to=None, + invoice_email_opt_in=None, + enabled_azure_plans=None, + value=None, + no_wait=False): + if display_name is not None: + instance.display_name = display_name + if po_number is not None: + instance.po_number = po_number + if bill_to is not None: + instance.bill_to = bill_to + if invoice_email_opt_in is not None: + instance.invoice_email_opt_in = invoice_email_opt_in + if enabled_azure_plans is not None: + instance.enabled_azure_plans = enabled_azure_plans + if value is not None: + instance.invoice_sections.value = value + return instance + + +def billing_customer_list(client, + account_name, + profile_name=None, + search=None, + filter_=None): + if account_name is not None and profile_name is not None: + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name, + search=search, + filter=filter_) + return client.list_by_billing_account(billing_account_name=account_name, + search=search, + filter=filter_) + + +def billing_customer_show(client, + account_name, + customer_name, + expand=None): + return client.get(billing_account_name=account_name, + customer_name=customer_name, + expand=expand) + + +def billing_invoice_section_list(client, + account_name, + profile_name): + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name) + + +def billing_invoice_section_show(client, + account_name, + profile_name, + invoice_section_name): + return client.get(billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name) + + +def billing_invoice_section_create(client, + account_name, + profile_name, + invoice_section_name, + display_name=None, + labels=None, + no_wait=False): + parameters = {} + parameters['display_name'] = display_name + parameters['labels'] = labels + return sdk_no_wait(no_wait, + client.begin_create_or_update, + billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name, + parameters=parameters) + + +def billing_invoice_section_update(instance, + account_name, + profile_name, + invoice_section_name, + display_name=None, + labels=None, + no_wait=False): + if display_name is not None: + instance.display_name = display_name + if labels is not None: + instance.labels = labels + return instance + + +def billing_permission_list(client, + account_name, + profile_name=None, + invoice_section_name=None, + customer_name=None): + if account_name is not None and profile_name is not None and invoice_section_name is not None: + return client.list_by_invoice_sections(billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name) + elif account_name is not None and customer_name is not None: + return client.list_by_customer(billing_account_name=account_name, + customer_name=customer_name) + elif account_name is not None and profile_name is not None: + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name) + return client.list_by_billing_account(billing_account_name=account_name) + + +def billing_subscription_list(client, + account_name, + profile_name=None, + invoice_section_name=None, + customer_name=None): + if account_name is not None and profile_name is not None and invoice_section_name is not None: + return client.list_by_invoice_section(billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name) + elif account_name is not None and customer_name is not None: + return client.list_by_customer(billing_account_name=account_name, + customer_name=customer_name) + elif account_name is not None and profile_name is not None: + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name) + return client.list_by_billing_account(billing_account_name=account_name) + + +def billing_subscription_show(client, + account_name): + return client.get(billing_account_name=account_name) + + +def billing_subscription_update(client, + account_name, + subscription_billing_status=None, + cost_center=None, + sku_id=None): + parameters = {} + parameters['subscription_billing_status'] = subscription_billing_status + parameters['cost_center'] = cost_center + parameters['sku_id'] = sku_id + return client.update(billing_account_name=account_name, + parameters=parameters) + + +def billing_subscription_move(client, + account_name, + destination_invoice_section_id, + no_wait=False): + parameters = {} + parameters['destination_invoice_section_id'] = destination_invoice_section_id + return sdk_no_wait(no_wait, + client.begin_move, + billing_account_name=account_name, + parameters=parameters) + + +def billing_subscription_validate_move(client, + account_name, + destination_invoice_section_id): + parameters = {} + parameters['destination_invoice_section_id'] = destination_invoice_section_id + return client.validate_move(billing_account_name=account_name, + parameters=parameters) + + +def billing_product_list(client, + account_name, + profile_name=None, + invoice_section_name=None, + filter_=None, + customer_name=None): + if account_name is not None and profile_name is not None and invoice_section_name is not None: + return client.list_by_invoice_section(billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name, + filter=filter_) + elif account_name is not None and profile_name is not None: + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name, + filter=filter_) + elif account_name is not None and customer_name is not None: + return client.list_by_customer(billing_account_name=account_name, + customer_name=customer_name) + return client.list_by_billing_account(billing_account_name=account_name, + filter=filter_) + + +def billing_product_show(client, + account_name, + product_name): + return client.get(billing_account_name=account_name, + product_name=product_name) + + +def billing_product_update(client, + account_name, + product_name, + auto_renew=None, + status=None, + billing_frequency=None): + parameters = {} + parameters['auto_renew'] = auto_renew + parameters['status'] = status + parameters['billing_frequency'] = billing_frequency + return client.update(billing_account_name=account_name, + product_name=product_name, + parameters=parameters) + + +def billing_product_move(client, + account_name, + product_name, + destination_invoice_section_id=None): + parameters = {} + parameters['destination_invoice_section_id'] = destination_invoice_section_id + return client.move(billing_account_name=account_name, + product_name=product_name, + parameters=parameters) + + +def billing_product_validate_move(client, + account_name, + product_name, + destination_invoice_section_id=None): + parameters = {} + parameters['destination_invoice_section_id'] = destination_invoice_section_id + return client.validate_move(billing_account_name=account_name, + product_name=product_name, + parameters=parameters) + + +def billing_invoice_list(client, + period_start_date, + period_end_date, + account_name=None, + profile_name=None): + if account_name is not None and profile_name is not None and period_start_date is not None and period_end_date is not None: + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name, + period_start_date=period_start_date, + period_end_date=period_end_date) + elif account_name is not None and period_start_date is not None and period_end_date is not None: + return client.list_by_billing_account(billing_account_name=account_name, + period_start_date=period_start_date, + period_end_date=period_end_date) + return client.list_by_billing_subscription(period_start_date=period_start_date, + period_end_date=period_end_date) + + +def billing_invoice_show(client, + account_name, + name): + return client.get(billing_account_name=account_name, + invoice_name=name) + + +def billing_transaction_list(client, + account_name, + invoice_name): + return client.list_by_invoice(billing_account_name=account_name, + invoice_name=invoice_name) + + +def billing_policy_update(client, + account_name, + profile_name, + marketplace_purchases=None, + reservation_purchases=None, + view_charges=None): + parameters = {} + parameters['marketplace_purchases'] = marketplace_purchases + parameters['reservation_purchases'] = reservation_purchases + parameters['view_charges'] = view_charges + return client.update(billing_account_name=account_name, + billing_profile_name=profile_name, + parameters=parameters) + + +def billing_property_show(client): + return client.get() + + +def billing_property_update(client, + cost_center=None): + parameters = {} + parameters['cost_center'] = cost_center + return client.update(parameters=parameters) + + +def billing_role_definition_list(client, + account_name, + profile_name=None, + invoice_section_name=None): + if account_name is not None and profile_name is not None and invoice_section_name is not None: + return client.list_by_invoice_section(billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name) + elif account_name is not None and profile_name is not None: + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name) + return client.list_by_billing_account(billing_account_name=account_name) + + +def billing_role_assignment_list(client, + account_name, + profile_name=None, + invoice_section_name=None): + if account_name is not None and profile_name is not None and invoice_section_name is not None: + return client.list_by_invoice_section(billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name) + elif account_name is not None and profile_name is not None: + return client.list_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name) + return client.list_by_billing_account(billing_account_name=account_name) + + +def billing_role_assignment_delete(client, + account_name, + name, + profile_name=None, + invoice_section_name=None): + if account_name is not None and profile_name is not None and invoice_section_name is not None and name is not None: + return client.delete_by_invoice_section(billing_account_name=account_name, + billing_profile_name=profile_name, + invoice_section_name=invoice_section_name, + billing_role_assignment_name=name) + elif account_name is not None and profile_name is not None and name is not None: + return client.delete_by_billing_profile(billing_account_name=account_name, + billing_profile_name=profile_name, + billing_role_assignment_name=name) + return client.delete_by_billing_account(billing_account_name=account_name, + billing_role_assignment_name=name) + + +def billing_agreement_list(client, + account_name, + expand=None): + return client.list_by_billing_account(billing_account_name=account_name, + expand=expand) + + +def billing_agreement_show(client, + account_name, + name, + expand=None): + return client.get(billing_account_name=account_name, + agreement_name=name, + expand=expand) diff --git a/src/billing/azext_billing/manual/__init__.py b/src/billing/azext_billing/manual/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/billing/azext_billing/manual/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/billing/azext_billing/tests/__init__.py b/src/billing/azext_billing/tests/__init__.py new file mode 100644 index 00000000000..70488e93851 --- /dev/null +++ b/src/billing/azext_billing/tests/__init__.py @@ -0,0 +1,116 @@ +# 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 inspect +import logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func).lower() + module_path = __path__[0].lower() + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE") + if use_exception_cache is None or use_exception_cache.lower() != "true": + raise + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/billing/azext_billing/tests/latest/__init__.py b/src/billing/azext_billing/tests/latest/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/billing/azext_billing/tests/latest/example_steps.py b/src/billing/azext_billing/tests/latest/example_steps.py new file mode 100644 index 00000000000..a662dda9875 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/example_steps.py @@ -0,0 +1,728 @@ +# -------------------------------------------------------------------------- +# 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 .. import try_manual + + +# EXAMPLE: /BillingAccounts/get/BillingAccounts +@try_manual +def step_account_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing account show ' + '--name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingAccounts/get/BillingAccountsList +@try_manual +def step_account_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing account list', + checks=checks) + + +# EXAMPLE: /BillingAccounts/get/BillingAccountsListWithExpand +@try_manual +def step_account_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing account list ' + '--expand "soldTo,billingProfiles,billingProfiles/invoiceSections"', + checks=checks) + + +# EXAMPLE: /BillingAccounts/get/BillingAccountsListWithExpandForEnrollmentDetails +@try_manual +def step_account_list3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing account list ' + '--expand "enrollmentDetails,departments,enrollmentAccounts"', + checks=checks) + + +# EXAMPLE: /BillingAccounts/get/BillingAccountWithExpand +@try_manual +def step_account_show2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing account show ' + '--expand "soldTo,billingProfiles,billingProfiles/invoiceSections" ' + '--name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingAccounts/patch/UpdateBillingAccount +@try_manual +def step_account_update(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing account update ' + '--name "{myBillingAccount}" ' + '--display-name "Test Account" ' + '--sold-to address-line1="Test Address 1" city="Redmond" company-name="Contoso" country="US" ' + 'first-name="Test" last-name="User" postal-code="12345" region="WA"', + checks=checks) + + +# EXAMPLE: /Agreements/get/AgreementByName +@try_manual +def step_agreement_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing agreement show ' + '--name "{myAgreement}" ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /Agreements/get/AgreementsListByBillingAccount +@try_manual +def step_agreement_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing agreement list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingProfiles/put/CreateBillingProfile +@try_manual +def step_profile_create(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing profile create ' + '--account-name "{myBillingAccount}" ' + '--name "{myBillingProfile}" ' + '--bill-to address-line1="Test Address 1" city="Redmond" country="US" first-name="Test" last-name="User" ' + 'postal-code="12345" region="WA" ' + '--display-name "Finance" ' + '--enabled-azure-plans sku-id="0001" ' + '--enabled-azure-plans sku-id="0002" ' + '--invoice-email-opt-in true ' + '--po-number "ABC12345"', + checks=checks) + + +# EXAMPLE: /BillingProfiles/get/BillingProfile +@try_manual +def step_profile_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing profile show ' + '--account-name "{myBillingAccount}" ' + '--name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /BillingProfiles/get/BillingProfilesListByBillingAccount +@try_manual +def step_profile_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing profile list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingProfiles/get/BillingProfilesListWithExpand +@try_manual +def step_profile_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing profile list ' + '--expand "invoiceSections" ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingProfiles/get/BillingProfileWithExpand +@try_manual +def step_profile_show2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing profile show ' + '--expand "invoiceSections" ' + '--account-name "{myBillingAccount}" ' + '--name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /AvailableBalances/get/AvailableBalanceByBillingProfile +@try_manual +def step_balance_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing balance show ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /BillingRoleAssignments/get/BillingAccountRoleAssignmentList +@try_manual +def step_role_assignment_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-assignment list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingRoleAssignments/get/BillingProfileRoleAssignmentList +@try_manual +def step_role_assignment_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-assignment list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /BillingRoleAssignments/get/InvoiceSectionRoleAssignmentList +@try_manual +def step_role_assignment_list3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-assignment list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--invoice-section-name "{myInvoiceSection}"', + checks=checks) + + +# EXAMPLE: /BillingRoleAssignments/delete/BillingProfileRoleAssignmentDelete +@try_manual +def step_role_assignment_delete(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-assignment delete -y ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--name "{myBillingRoleAssignment}"', + checks=checks) + + +# EXAMPLE: /BillingRoleAssignments/delete/InvoiceSectionRoleAssignmentDelete +@try_manual +def step_role_assignment_delete2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-assignment delete -y ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--name "{myBillingRoleAssignment}" ' + '--invoice-section-name "{myInvoiceSection}"', + checks=checks) + + +# EXAMPLE: /BillingRoleDefinitions/get/BillingAccountRoleDefinitionsList +@try_manual +def step_role_definition_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-definition list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingRoleDefinitions/get/BillingProfileRoleDefinitionsList +@try_manual +def step_role_definition_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-definition list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /BillingRoleDefinitions/get/InvoiceSectionRoleDefinitionsList +@try_manual +def step_role_definition_list3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-definition list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--invoice-section-name "{myInvoiceSection}"', + checks=checks) + + +# EXAMPLE: /Customers/get/Customer +@try_manual +def step_customer_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing customer show ' + '--account-name "{myBillingAccount}" ' + '--name "{myCustomer}"', + checks=checks) + + +# EXAMPLE: /Customers/get/CustomersListByBillingAccount +@try_manual +def step_customer_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing customer list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /Customers/get/CustomersListByBillingProfile +@try_manual +def step_customer_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing customer list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /Customers/get/CustomerWithExpand +@try_manual +def step_customer_show2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing customer show ' + '--expand "enabledAzurePlans,resellers" ' + '--account-name "{myBillingAccount}" ' + '--name "{myCustomer}"', + checks=checks) + + +# EXAMPLE: /BillingPermissions/get/BillingAccountPermissionsList +@try_manual +def step_permission_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing permission list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingPermissions/get/BillingProfilePermissionsList +@try_manual +def step_permission_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing permission list ' + '--account-name "{myBillingAccount}" ' + '--customer-name "{myCustomer}"', + checks=checks) + + +# EXAMPLE: /BillingPermissions/get/InvoiceSectionPermissionsList +@try_manual +def step_permission_list3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing permission list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--invoice-section-name "{myInvoiceSection}"', + checks=checks) + + +# EXAMPLE: /BillingProperty/get/BillingProperty +@try_manual +def step_property_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing property show', + checks=checks) + + +# EXAMPLE: /BillingProperty/patch/UpdateBillingProperty +@try_manual +def step_property_update(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing property update ' + '--cost-center "1010"', + checks=checks) + + +# EXAMPLE: /BillingRoleAssignments/delete/BillingAccountRoleAssignmentDelete +@try_manual +def step_role_assignment_delete3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing role-assignment delete -y ' + '--account-name "{myBillingAccount}" ' + '--name "{myBillingRoleAssignment}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/get/BillingSubscription +@try_manual +def step_subscription_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription show ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/get/BillingSubscriptionsListByBillingAccount +@try_manual +def step_subscription_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/get/BillingSubscriptionsListByBillingProfile +@try_manual +def step_subscription_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/get/BillingSubscriptionsListByCustomer +@try_manual +def step_subscription_list3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription list ' + '--account-name "{myBillingAccount}" ' + '--customer-name "{myCustomer}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/get/BillingSubscriptionsListByInvoiceSection +@try_manual +def step_subscription_list4(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--invoice-section-name "{myInvoiceSection}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/patch/UpdateBillingProperty +@try_manual +def step_subscription_update(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription update ' + '--account-name "{myBillingAccount}" ' + '--cost-center "ABC1234"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/post/MoveBillingSubscription +@try_manual +def step_subscription_move(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription move ' + '--account-name "{myBillingAccount}" ' + '--destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{{billingAccountName}}/bil' + 'lingProfiles/{{billingProfileName}}/invoiceSections/{{newInvoiceSectionName}}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/post/SubscriptionMoveValidateFailure +@try_manual +def step_subscription_validate_move(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing subscription validate-move ' + '--account-name "{myBillingAccount}" ' + '--destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{{billingAccountName}}/bil' + 'lingProfiles/{{billingProfileName}}/invoiceSections/{{newInvoiceSectionName}}"', + checks=checks) + + +# EXAMPLE: /BillingSubscriptions/post/SubscriptionMoveValidateSuccess +@try_manual +def step_subscription_validate_move2(test, checks=None): + return step_subscription_validate_move(test, checks) + + +# EXAMPLE: /Instructions/put/PutInstruction +@try_manual +def step_instruction_create(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing instruction create ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--name "{myInstruction}" ' + '--amount 5000 ' + '--end-date "2020-12-30T21:26:47.997Z" ' + '--start-date "2019-12-30T21:26:47.997Z"', + checks=checks) + + +# EXAMPLE: /Instructions/get/Instruction +@try_manual +def step_instruction_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing instruction show ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--name "{myInstruction}"', + checks=checks) + + +# EXAMPLE: /Instructions/get/InstructionsListByBillingProfile +@try_manual +def step_instruction_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing instruction list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /Invoices/get/BillingAccountInvoicesList +@try_manual +def step_invoice_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing invoice list ' + '--account-name "{myBillingAccount}" ' + '--period-end-date "2018-06-30" ' + '--period-start-date "2018-01-01"', + checks=checks) + + +# EXAMPLE: /Invoices/get/BillingAccountInvoicesListWithRebillDetails +@try_manual +def step_invoice_list2(test, checks=None): + return step_invoice_list(test, checks) + + +# EXAMPLE: /Invoices/get/BillingSubscriptionsListByBillingAccount +@try_manual +def step_invoice_list3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing invoice list ' + '--period-end-date "2018-06-30" ' + '--period-start-date "2018-01-01"', + checks=checks) + + +# EXAMPLE: /Invoices/get/CreditNote +@try_manual +def step_invoice_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing invoice show ' + '--account-name "{myBillingAccount}" ' + '--name "{myInvoice}"', + checks=checks) + + +# EXAMPLE: /Invoices/get/Invoice +@try_manual +def step_invoice_show2(test, checks=None): + return step_invoice_show(test, checks) + + +# EXAMPLE: /Invoices/get/InvoicesListByBillingProfile +@try_manual +def step_invoice_list4(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing invoice list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--period-end-date "2018-06-30" ' + '--period-start-date "2018-01-01"', + checks=checks) + + +# EXAMPLE: /Invoices/get/InvoicesListByBillingProfileWithRebillDetails +@try_manual +def step_invoice_list5(test, checks=None): + return step_invoice_list4(test, checks) + + +# EXAMPLE: /Invoices/get/InvoiceWithRebillDetails +@try_manual +def step_invoice_show3(test, checks=None): + return step_invoice_show(test, checks) + + +# EXAMPLE: /Invoices/get/VoidInvoice +@try_manual +def step_invoice_show4(test, checks=None): + return step_invoice_show(test, checks) + + +# EXAMPLE: /InvoiceSections/put/PutInvoiceSection +@try_manual +def step_invoice_section_create(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing invoice section create ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--name "{myInvoiceSection}" ' + '--display-name "invoiceSection1" ' + '--labels costCategory="Support" pcCode="A123456"', + checks=checks) + + +# EXAMPLE: /InvoiceSections/get/InvoiceSection +@try_manual +def step_invoice_section_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing invoice section show ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--name "{myInvoiceSection}"', + checks=checks) + + +# EXAMPLE: /InvoiceSections/get/InvoiceSectionsListByBillingProfile +@try_manual +def step_invoice_section_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing invoice section list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /Policies/put/UpdatePolicy +@try_manual +def step_policy_update(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing policy update ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--marketplace-purchases "OnlyFreeAllowed" ' + '--reservation-purchases "NotAllowed" ' + '--view-charges "Allowed"', + checks=checks) + + +# EXAMPLE: /Products/get/Product +@try_manual +def step_product_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing product show ' + '--account-name "{myBillingAccount}" ' + '--name "{myProduct}"', + checks=checks) + + +# EXAMPLE: /Products/get/ProductsListByBillingAccount +@try_manual +def step_product_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing product list ' + '--account-name "{myBillingAccount}"', + checks=checks) + + +# EXAMPLE: /Products/get/ProductsListByBillingProfile +@try_manual +def step_product_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing product list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}"', + checks=checks) + + +# EXAMPLE: /Products/get/ProductsListByInvoiceSection +@try_manual +def step_product_list3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing product list ' + '--account-name "{myBillingAccount}" ' + '--profile-name "{myBillingProfile}" ' + '--invoice-section-name "{myInvoiceSection}"', + checks=checks) + + +# EXAMPLE: /Products/patch/UpdateBillingProperty +@try_manual +def step_product_update(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing product update ' + '--account-name "{myBillingAccount}" ' + '--auto-renew "Off" ' + '--name "{myProduct}"', + checks=checks) + + +# EXAMPLE: /Products/post/MoveProduct +@try_manual +def step_product_move(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing product move ' + '--account-name "{myBillingAccount}" ' + '--destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{{billingAccountName}}/bil' + 'lingProfiles/{{billingProfileName}}/invoiceSections/{{newInvoiceSectionName}}" ' + '--name "{myProduct}"', + checks=checks) + + +# EXAMPLE: /Products/post/SubscriptionMoveValidateFailure +@try_manual +def step_product_validate_move(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing product validate-move ' + '--account-name "{myBillingAccount}" ' + '--destination-invoice-section-id "/providers/Microsoft.Billing/billingAccounts/{{billingAccountName}}/bil' + 'lingProfiles/{{billingProfileName}}/invoiceSections/{{newInvoiceSectionName}}" ' + '--name "{myProduct}"', + checks=checks) + + +# EXAMPLE: /Products/post/SubscriptionMoveValidateSuccess +@try_manual +def step_product_validate_move2(test, checks=None): + return step_product_validate_move(test, checks) + + +# EXAMPLE: /Transactions/get/TransactionsListByInvoice +@try_manual +def step_transaction_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az billing transaction list ' + '--account-name "{myBillingAccount}" ' + '--invoice-name "{myInvoice}"', + checks=checks) + diff --git a/src/billing/azext_billing/tests/latest/test_billing_scenario.py b/src/billing/azext_billing/tests/latest/test_billing_scenario.py new file mode 100644 index 00000000000..6cb7b7d768e --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_billing_scenario.py @@ -0,0 +1,260 @@ +# -------------------------------------------------------------------------- +# 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 os +from azure.cli.testsdk import ScenarioTest +from .example_steps import step_account_show +from .example_steps import step_account_list +from .example_steps import step_account_list2 +from .example_steps import step_account_list3 +from .example_steps import step_account_show2 +from .example_steps import step_account_update +from .example_steps import step_agreement_show +from .example_steps import step_agreement_list +from .example_steps import step_profile_create +from .example_steps import step_profile_show +from .example_steps import step_profile_list +from .example_steps import step_profile_list2 +from .example_steps import step_profile_show2 +from .example_steps import step_balance_show +from .example_steps import step_role_assignment_list +from .example_steps import step_role_assignment_list2 +from .example_steps import step_role_assignment_list3 +from .example_steps import step_role_assignment_delete +from .example_steps import step_role_assignment_delete2 +from .example_steps import step_role_definition_list +from .example_steps import step_role_definition_list2 +from .example_steps import step_role_definition_list3 +from .example_steps import step_customer_show +from .example_steps import step_customer_list +from .example_steps import step_customer_list2 +from .example_steps import step_customer_show2 +from .example_steps import step_permission_list +from .example_steps import step_permission_list2 +from .example_steps import step_permission_list3 +from .example_steps import step_property_show +from .example_steps import step_property_update +from .example_steps import step_role_assignment_delete3 +from .example_steps import step_subscription_show +from .example_steps import step_subscription_list +from .example_steps import step_subscription_list2 +from .example_steps import step_subscription_list3 +from .example_steps import step_subscription_list4 +from .example_steps import step_subscription_update +from .example_steps import step_subscription_move +from .example_steps import step_subscription_validate_move +from .example_steps import step_subscription_validate_move2 +from .example_steps import step_instruction_create +from .example_steps import step_instruction_show +from .example_steps import step_instruction_list +from .example_steps import step_invoice_list +from .example_steps import step_invoice_list2 +from .example_steps import step_invoice_list3 +from .example_steps import step_invoice_show +from .example_steps import step_invoice_show2 +from .example_steps import step_invoice_list4 +from .example_steps import step_invoice_list5 +from .example_steps import step_invoice_show3 +from .example_steps import step_invoice_show4 +from .example_steps import step_invoice_section_create +from .example_steps import step_invoice_section_show +from .example_steps import step_invoice_section_list +from .example_steps import step_policy_update +from .example_steps import step_product_show +from .example_steps import step_product_list +from .example_steps import step_product_list2 +from .example_steps import step_product_list3 +from .example_steps import step_product_update +from .example_steps import step_product_move +from .example_steps import step_product_validate_move +from .example_steps import step_product_validate_move2 +from .example_steps import step_transaction_list +from .. import ( + try_manual, + raise_if, + calc_coverage +) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +# Env setup_scenario +@try_manual +def setup_scenario(test): + pass + + +# Env cleanup_scenario +@try_manual +def cleanup_scenario(test): + pass + + +# Testcase: Scenario +@try_manual +def call_scenario(test): + setup_scenario(test) + step_account_show(test, checks=[]) + step_account_list(test, checks=[ + test.check('length(@)', 1), + ]) + step_account_list2(test, checks=[]) + step_account_list3(test, checks=[]) + step_account_show2(test, checks=[]) + step_account_update(test, checks=[ + test.check("name", "{myBillingAccount}", case_sensitive=False), + test.check("displayName", "Test Account", case_sensitive=False), + test.check("soldTo.addressLine1", "Test Address 1", case_sensitive=False), + test.check("soldTo.city", "Redmond", case_sensitive=False), + test.check("soldTo.companyName", "Contoso", case_sensitive=False), + test.check("soldTo.country", "US", case_sensitive=False), + test.check("soldTo.firstName", "Test", case_sensitive=False), + test.check("soldTo.lastName", "User", case_sensitive=False), + test.check("soldTo.postalCode", "12345", case_sensitive=False), + test.check("soldTo.region", "WA", case_sensitive=False), + ]) + step_agreement_show(test, checks=[]) + step_agreement_list(test, checks=[]) + step_profile_create(test, checks=[ + test.check("billTo.addressLine1", "Test Address 1", case_sensitive=False), + test.check("billTo.city", "Redmond", case_sensitive=False), + test.check("billTo.country", "US", case_sensitive=False), + test.check("billTo.firstName", "Test", case_sensitive=False), + test.check("billTo.lastName", "User", case_sensitive=False), + test.check("billTo.postalCode", "12345", case_sensitive=False), + test.check("billTo.region", "WA", case_sensitive=False), + test.check("displayName", "Finance", case_sensitive=False), + test.check("invoiceEmailOptIn", True), + test.check("poNumber", "ABC12345", case_sensitive=False), + ]) + step_profile_show(test, checks=[ + test.check("name", "{myBillingProfile}", case_sensitive=False), + test.check("invoiceEmailOptIn", True), + test.check("poNumber", "ABC12345", case_sensitive=False), + ]) + step_profile_list(test, checks=[ + test.check('length(@)', 1), + ]) + step_profile_list2(test, checks=[]) + step_profile_show2(test, checks=[ + test.check("name", "{myBillingProfile}", case_sensitive=False), + test.check("invoiceEmailOptIn", True), + test.check("poNumber", "ABC12345", case_sensitive=False), + ]) + step_balance_show(test, checks=[]) + step_role_assignment_list(test, checks=[]) + step_role_assignment_list2(test, checks=[]) + step_role_assignment_list3(test, checks=[]) + step_role_assignment_delete(test, checks=[]) + step_role_assignment_delete2(test, checks=[]) + step_role_definition_list(test, checks=[]) + step_role_definition_list2(test, checks=[]) + step_role_definition_list3(test, checks=[]) + step_customer_show(test, checks=[]) + step_customer_list(test, checks=[]) + step_customer_list2(test, checks=[]) + step_customer_show2(test, checks=[]) + step_permission_list(test, checks=[]) + step_permission_list2(test, checks=[]) + step_permission_list2(test, checks=[]) + step_permission_list3(test, checks=[]) + step_property_show(test, checks=[]) + step_property_update(test, checks=[]) + step_role_assignment_delete3(test, checks=[]) + step_subscription_show(test, checks=[]) + step_subscription_list(test, checks=[]) + step_subscription_list2(test, checks=[]) + step_subscription_list3(test, checks=[]) + step_subscription_list4(test, checks=[]) + step_subscription_update(test, checks=[]) + step_subscription_move(test, checks=[]) + step_subscription_validate_move(test, checks=[]) + step_subscription_validate_move2(test, checks=[]) + step_instruction_create(test, checks=[ + test.check("name", "{myInstruction}", case_sensitive=False), + test.check("amount", 5000), + test.check("endDate", "2020-12-30T21:26:47.997Z", case_sensitive=False), + test.check("startDate", "2019-12-30T21:26:47.997Z", case_sensitive=False), + ]) + step_instruction_show(test, checks=[ + test.check("name", "{myInstruction}", case_sensitive=False), + test.check("amount", 5000), + test.check("endDate", "2020-12-30T21:26:47.997Z", case_sensitive=False), + test.check("startDate", "2019-12-30T21:26:47.997Z", case_sensitive=False), + ]) + step_instruction_list(test, checks=[ + test.check('length(@)', 1), + ]) + step_invoice_list(test, checks=[]) + step_invoice_list2(test, checks=[]) + step_invoice_list3(test, checks=[]) + step_invoice_show(test, checks=[]) + step_invoice_show2(test, checks=[]) + step_invoice_list4(test, checks=[]) + step_invoice_list5(test, checks=[]) + step_invoice_show3(test, checks=[]) + step_invoice_show4(test, checks=[]) + step_invoice_section_create(test, checks=[ + test.check("name", "{myInvoiceSection}", case_sensitive=False), + test.check("displayName", "invoiceSection1", case_sensitive=False), + test.check("labels.costCategory", "Support", case_sensitive=False), + test.check("labels.pcCode", "A123456", case_sensitive=False), + ]) + step_invoice_section_show(test, checks=[ + test.check("name", "{myInvoiceSection}", case_sensitive=False), + test.check("displayName", "invoiceSection1", case_sensitive=False), + test.check("labels.costCategory", "Support", case_sensitive=False), + test.check("labels.pcCode", "A123456", case_sensitive=False), + ]) + step_invoice_section_list(test, checks=[ + test.check('length(@)', 1), + ]) + step_policy_update(test, checks=[]) + step_product_show(test, checks=[]) + step_product_list(test, checks=[]) + step_product_list2(test, checks=[]) + step_product_list3(test, checks=[]) + step_product_list3(test, checks=[]) + step_product_update(test, checks=[ + test.check("autoRenew", "Off", case_sensitive=False), + test.check("name", "{myProduct}", case_sensitive=False), + ]) + step_product_move(test, checks=[]) + step_product_validate_move(test, checks=[]) + step_product_validate_move2(test, checks=[]) + step_transaction_list(test, checks=[]) + cleanup_scenario(test) + + +# Test class for Scenario +@try_manual +class BillingScenarioTest(ScenarioTest): + + def __init__(self, *args, **kwargs): + super(BillingScenarioTest, self).__init__(*args, **kwargs) + self.kwargs.update({ + 'myBillingAccount': '{billingAccountName}', + 'myBillingProfile': '{billingProfileName}', + 'myCustomer': '{customerName}', + 'myInvoiceSection': '{invoiceSectionName}', + 'myProduct': '{productName}', + 'myInvoice': '{invoiceName}', + 'myBillingRoleAssignment': '{billingRoleAssignmentName}', + 'myAgreement': '{agreementName}', + 'myInstruction': '{instructionName}', + }) + + + def test_billing_Scenario(self): + call_scenario(self) + calc_coverage(__file__) + raise_if() + diff --git a/src/billing/azext_billing/vendored_sdks/__init__.py b/src/billing/azext_billing/vendored_sdks/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/billing/azext_billing/vendored_sdks/billing/__init__.py b/src/billing/azext_billing/vendored_sdks/billing/__init__.py new file mode 100644 index 00000000000..75a68fbfd68 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/__init__.py @@ -0,0 +1,16 @@ +# 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 ._billing_management_client import BillingManagementClient +__all__ = ['BillingManagementClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/billing/azext_billing/vendored_sdks/billing/_billing_management_client.py b/src/billing/azext_billing/vendored_sdks/billing/_billing_management_client.py new file mode 100644 index 00000000000..901bb318a43 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/_billing_management_client.py @@ -0,0 +1,164 @@ +# 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 typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import BillingManagementClientConfiguration +from .operations import BillingAccountsOperations +from .operations import AddressOperations +from .operations import AvailableBalancesOperations +from .operations import InstructionsOperations +from .operations import BillingProfilesOperations +from .operations import CustomersOperations +from .operations import InvoiceSectionsOperations +from .operations import BillingPermissionsOperations +from .operations import BillingSubscriptionsOperations +from .operations import ProductsOperations +from .operations import InvoicesOperations +from .operations import TransactionsOperations +from .operations import PoliciesOperations +from .operations import BillingPropertyOperations +from .operations import Operations +from .operations import BillingRoleDefinitionsOperations +from .operations import BillingRoleAssignmentsOperations +from .operations import AgreementsOperations +from .operations import EnrollmentAccountsOperations +from .operations import BillingPeriodsOperations +from . import models + + +class BillingManagementClient(object): + """Billing client provides access to billing resources for Azure subscriptions. + + :ivar billing_accounts: BillingAccountsOperations operations + :vartype billing_accounts: billing_management_client.operations.BillingAccountsOperations + :ivar address: AddressOperations operations + :vartype address: billing_management_client.operations.AddressOperations + :ivar available_balances: AvailableBalancesOperations operations + :vartype available_balances: billing_management_client.operations.AvailableBalancesOperations + :ivar instructions: InstructionsOperations operations + :vartype instructions: billing_management_client.operations.InstructionsOperations + :ivar billing_profiles: BillingProfilesOperations operations + :vartype billing_profiles: billing_management_client.operations.BillingProfilesOperations + :ivar customers: CustomersOperations operations + :vartype customers: billing_management_client.operations.CustomersOperations + :ivar invoice_sections: InvoiceSectionsOperations operations + :vartype invoice_sections: billing_management_client.operations.InvoiceSectionsOperations + :ivar billing_permissions: BillingPermissionsOperations operations + :vartype billing_permissions: billing_management_client.operations.BillingPermissionsOperations + :ivar billing_subscriptions: BillingSubscriptionsOperations operations + :vartype billing_subscriptions: billing_management_client.operations.BillingSubscriptionsOperations + :ivar products: ProductsOperations operations + :vartype products: billing_management_client.operations.ProductsOperations + :ivar invoices: InvoicesOperations operations + :vartype invoices: billing_management_client.operations.InvoicesOperations + :ivar transactions: TransactionsOperations operations + :vartype transactions: billing_management_client.operations.TransactionsOperations + :ivar policies: PoliciesOperations operations + :vartype policies: billing_management_client.operations.PoliciesOperations + :ivar billing_property: BillingPropertyOperations operations + :vartype billing_property: billing_management_client.operations.BillingPropertyOperations + :ivar operations: Operations operations + :vartype operations: billing_management_client.operations.Operations + :ivar billing_role_definitions: BillingRoleDefinitionsOperations operations + :vartype billing_role_definitions: billing_management_client.operations.BillingRoleDefinitionsOperations + :ivar billing_role_assignments: BillingRoleAssignmentsOperations operations + :vartype billing_role_assignments: billing_management_client.operations.BillingRoleAssignmentsOperations + :ivar agreements: AgreementsOperations operations + :vartype agreements: billing_management_client.operations.AgreementsOperations + :ivar enrollment_accounts: EnrollmentAccountsOperations operations + :vartype enrollment_accounts: billing_management_client.operations.EnrollmentAccountsOperations + :ivar billing_periods: BillingPeriodsOperations operations + :vartype billing_periods: billing_management_client.operations.BillingPeriodsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID that uniquely identifies an Azure subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = BillingManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.billing_accounts = BillingAccountsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.address = AddressOperations( + self._client, self._config, self._serialize, self._deserialize) + self.available_balances = AvailableBalancesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.instructions = InstructionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_profiles = BillingProfilesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.customers = CustomersOperations( + self._client, self._config, self._serialize, self._deserialize) + self.invoice_sections = InvoiceSectionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_permissions = BillingPermissionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_subscriptions = BillingSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.products = ProductsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.invoices = InvoicesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.transactions = TransactionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_property = BillingPropertyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_role_definitions = BillingRoleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_role_assignments = BillingRoleAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.agreements = AgreementsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.enrollment_accounts = EnrollmentAccountsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_periods = BillingPeriodsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> BillingManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/billing/azext_billing/vendored_sdks/billing/_configuration.py b/src/billing/azext_billing/vendored_sdks/billing/_configuration.py new file mode 100644 index 00000000000..02a72e64441 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/_configuration.py @@ -0,0 +1,69 @@ +# 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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class BillingManagementClientConfiguration(Configuration): + """Configuration for BillingManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID that uniquely identifies an Azure subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(BillingManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'billingmanagementclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/__init__.py b/src/billing/azext_billing/vendored_sdks/billing/aio/__init__.py new file mode 100644 index 00000000000..f07d4ec7455 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._billing_management_client import BillingManagementClient +__all__ = ['BillingManagementClient'] diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/_billing_management_client.py b/src/billing/azext_billing/vendored_sdks/billing/aio/_billing_management_client.py new file mode 100644 index 00000000000..cd4a4db36a1 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/_billing_management_client.py @@ -0,0 +1,158 @@ +# 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 typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import BillingManagementClientConfiguration +from .operations import BillingAccountsOperations +from .operations import AddressOperations +from .operations import AvailableBalancesOperations +from .operations import InstructionsOperations +from .operations import BillingProfilesOperations +from .operations import CustomersOperations +from .operations import InvoiceSectionsOperations +from .operations import BillingPermissionsOperations +from .operations import BillingSubscriptionsOperations +from .operations import ProductsOperations +from .operations import InvoicesOperations +from .operations import TransactionsOperations +from .operations import PoliciesOperations +from .operations import BillingPropertyOperations +from .operations import Operations +from .operations import BillingRoleDefinitionsOperations +from .operations import BillingRoleAssignmentsOperations +from .operations import AgreementsOperations +from .operations import EnrollmentAccountsOperations +from .operations import BillingPeriodsOperations +from .. import models + + +class BillingManagementClient(object): + """Billing client provides access to billing resources for Azure subscriptions. + + :ivar billing_accounts: BillingAccountsOperations operations + :vartype billing_accounts: billing_management_client.aio.operations.BillingAccountsOperations + :ivar address: AddressOperations operations + :vartype address: billing_management_client.aio.operations.AddressOperations + :ivar available_balances: AvailableBalancesOperations operations + :vartype available_balances: billing_management_client.aio.operations.AvailableBalancesOperations + :ivar instructions: InstructionsOperations operations + :vartype instructions: billing_management_client.aio.operations.InstructionsOperations + :ivar billing_profiles: BillingProfilesOperations operations + :vartype billing_profiles: billing_management_client.aio.operations.BillingProfilesOperations + :ivar customers: CustomersOperations operations + :vartype customers: billing_management_client.aio.operations.CustomersOperations + :ivar invoice_sections: InvoiceSectionsOperations operations + :vartype invoice_sections: billing_management_client.aio.operations.InvoiceSectionsOperations + :ivar billing_permissions: BillingPermissionsOperations operations + :vartype billing_permissions: billing_management_client.aio.operations.BillingPermissionsOperations + :ivar billing_subscriptions: BillingSubscriptionsOperations operations + :vartype billing_subscriptions: billing_management_client.aio.operations.BillingSubscriptionsOperations + :ivar products: ProductsOperations operations + :vartype products: billing_management_client.aio.operations.ProductsOperations + :ivar invoices: InvoicesOperations operations + :vartype invoices: billing_management_client.aio.operations.InvoicesOperations + :ivar transactions: TransactionsOperations operations + :vartype transactions: billing_management_client.aio.operations.TransactionsOperations + :ivar policies: PoliciesOperations operations + :vartype policies: billing_management_client.aio.operations.PoliciesOperations + :ivar billing_property: BillingPropertyOperations operations + :vartype billing_property: billing_management_client.aio.operations.BillingPropertyOperations + :ivar operations: Operations operations + :vartype operations: billing_management_client.aio.operations.Operations + :ivar billing_role_definitions: BillingRoleDefinitionsOperations operations + :vartype billing_role_definitions: billing_management_client.aio.operations.BillingRoleDefinitionsOperations + :ivar billing_role_assignments: BillingRoleAssignmentsOperations operations + :vartype billing_role_assignments: billing_management_client.aio.operations.BillingRoleAssignmentsOperations + :ivar agreements: AgreementsOperations operations + :vartype agreements: billing_management_client.aio.operations.AgreementsOperations + :ivar enrollment_accounts: EnrollmentAccountsOperations operations + :vartype enrollment_accounts: billing_management_client.aio.operations.EnrollmentAccountsOperations + :ivar billing_periods: BillingPeriodsOperations operations + :vartype billing_periods: billing_management_client.aio.operations.BillingPeriodsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID that uniquely identifies an Azure subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = BillingManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.billing_accounts = BillingAccountsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.address = AddressOperations( + self._client, self._config, self._serialize, self._deserialize) + self.available_balances = AvailableBalancesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.instructions = InstructionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_profiles = BillingProfilesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.customers = CustomersOperations( + self._client, self._config, self._serialize, self._deserialize) + self.invoice_sections = InvoiceSectionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_permissions = BillingPermissionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_subscriptions = BillingSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.products = ProductsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.invoices = InvoicesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.transactions = TransactionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_property = BillingPropertyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_role_definitions = BillingRoleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_role_assignments = BillingRoleAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.agreements = AgreementsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.enrollment_accounts = EnrollmentAccountsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_periods = BillingPeriodsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "BillingManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/_configuration.py b/src/billing/azext_billing/vendored_sdks/billing/aio/_configuration.py new file mode 100644 index 00000000000..2db622b11d8 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/_configuration.py @@ -0,0 +1,65 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class BillingManagementClientConfiguration(Configuration): + """Configuration for BillingManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID that uniquely identifies an Azure subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(BillingManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'billingmanagementclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/__init__.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/__init__.py new file mode 100644 index 00000000000..34c9bbb2242 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/__init__.py @@ -0,0 +1,51 @@ +# 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 ._billing_accounts_operations import BillingAccountsOperations +from ._address_operations import AddressOperations +from ._available_balances_operations import AvailableBalancesOperations +from ._instructions_operations import InstructionsOperations +from ._billing_profiles_operations import BillingProfilesOperations +from ._customers_operations import CustomersOperations +from ._invoice_sections_operations import InvoiceSectionsOperations +from ._billing_permissions_operations import BillingPermissionsOperations +from ._billing_subscriptions_operations import BillingSubscriptionsOperations +from ._products_operations import ProductsOperations +from ._invoices_operations import InvoicesOperations +from ._transactions_operations import TransactionsOperations +from ._policies_operations import PoliciesOperations +from ._billing_property_operations import BillingPropertyOperations +from ._operations import Operations +from ._billing_role_definitions_operations import BillingRoleDefinitionsOperations +from ._billing_role_assignments_operations import BillingRoleAssignmentsOperations +from ._agreements_operations import AgreementsOperations +from ._enrollment_accounts_operations import EnrollmentAccountsOperations +from ._billing_periods_operations import BillingPeriodsOperations + +__all__ = [ + 'BillingAccountsOperations', + 'AddressOperations', + 'AvailableBalancesOperations', + 'InstructionsOperations', + 'BillingProfilesOperations', + 'CustomersOperations', + 'InvoiceSectionsOperations', + 'BillingPermissionsOperations', + 'BillingSubscriptionsOperations', + 'ProductsOperations', + 'InvoicesOperations', + 'TransactionsOperations', + 'PoliciesOperations', + 'BillingPropertyOperations', + 'Operations', + 'BillingRoleDefinitionsOperations', + 'BillingRoleAssignmentsOperations', + 'AgreementsOperations', + 'EnrollmentAccountsOperations', + 'BillingPeriodsOperations', +] diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_address_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_address_operations.py new file mode 100644 index 00000000000..778c5e2aa72 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_address_operations.py @@ -0,0 +1,97 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AddressOperations: + """AddressOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def validate( + self, + address: "models.AddressDetails", + **kwargs + ) -> "models.ValidateAddressResponse": + """Validates an address. Use the operation to validate an address before using it as soldTo or a + billTo address. + + :param address: + :type address: ~billing_management_client.models.AddressDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ValidateAddressResponse, or the result of cls(response) + :rtype: ~billing_management_client.models.ValidateAddressResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ValidateAddressResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.validate.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(address, 'AddressDetails') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ValidateAddressResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/providers/Microsoft.Billing/validateAddress'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_agreements_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_agreements_operations.py new file mode 100644 index 00000000000..44014c2dc09 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_agreements_operations.py @@ -0,0 +1,180 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AgreementsOperations: + """AgreementsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_account( + self, + billing_account_name: str, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.AgreementListResult"]: + """Lists the agreements for a billing account. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param expand: May be used to expand the participants. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AgreementListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.AgreementListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AgreementListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AgreementListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements'} # type: ignore + + async def get( + self, + billing_account_name: str, + agreement_name: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Agreement": + """Gets an agreement by ID. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param agreement_name: The ID that uniquely identifies an agreement. + :type agreement_name: str + :param expand: May be used to expand the participants. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Agreement, or the result of cls(response) + :rtype: ~billing_management_client.models.Agreement + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Agreement"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'agreementName': self._serialize.url("agreement_name", agreement_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Agreement', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_available_balances_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_available_balances_operations.py new file mode 100644 index 00000000000..068694dde1f --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_available_balances_operations.py @@ -0,0 +1,101 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AvailableBalancesOperations: + """AvailableBalancesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> "models.AvailableBalance": + """The available credit balance for a billing profile. This is the balance that can be used for + pay now to settle due or past due invoices. The operation is supported only for billing + accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailableBalance, or the result of cls(response) + :rtype: ~billing_management_client.models.AvailableBalance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AvailableBalance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AvailableBalance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_accounts_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_accounts_operations.py new file mode 100644 index 00000000000..7ed6bb804b3 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_accounts_operations.py @@ -0,0 +1,364 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingAccountsOperations: + """BillingAccountsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.BillingAccountListResult"]: + """Lists the billing accounts that a user has access to. + + :param expand: May be used to expand the soldTo, invoice sections and billing profiles. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingAccountListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingAccountListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts'} # type: ignore + + async def get( + self, + billing_account_name: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.BillingAccount": + """Gets a billing account by its ID. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param expand: May be used to expand the soldTo, invoice sections and billing profiles. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingAccount, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + async def _update_initial( + self, + billing_account_name: str, + parameters: "models.BillingAccountUpdateRequest", + **kwargs + ) -> Optional["models.BillingAccount"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.BillingAccount"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingAccountUpdateRequest') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('BillingAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + async def begin_update( + self, + billing_account_name: str, + parameters: "models.BillingAccountUpdateRequest", + **kwargs + ) -> AsyncLROPoller["models.BillingAccount"]: + """Updates the properties of a billing account. Currently, displayName and address can be updated. + The operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the update billing account + operation. + :type parameters: ~billing_management_client.models.BillingAccountUpdateRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BillingAccount or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.BillingAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingAccount"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + billing_account_name=billing_account_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('BillingAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + def list_invoice_sections_by_create_subscription_permission( + self, + billing_account_name: str, + **kwargs + ) -> AsyncIterable["models.InvoiceSectionListWithCreateSubPermissionResult"]: + """Lists the invoice sections for which the user has permission to create Azure subscriptions. The + operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceSectionListWithCreateSubPermissionResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.InvoiceSectionListWithCreateSubPermissionResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSectionListWithCreateSubPermissionResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_invoice_sections_by_create_subscription_permission.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceSectionListWithCreateSubPermissionResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_invoice_sections_by_create_subscription_permission.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_periods_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_periods_operations.py new file mode 100644 index 00000000000..e92c5755ef9 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_periods_operations.py @@ -0,0 +1,187 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingPeriodsOperations: + """BillingPeriodsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + filter: Optional[str] = None, + skiptoken: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.BillingPeriodsListResult"]: + """Lists the available billing periods for a subscription in reverse chronological order. This is + only supported for Azure Web-Direct subscriptions. Other subscription types which were not + purchased directly through the Azure web portal are not supported through this preview API. + + :param filter: May be used to filter billing periods by billingPeriodEndDate. The filter + supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + 'not'. + :type filter: str + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: str + :param top: May be used to limit the number of results to the most recent N billing periods. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPeriodsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingPeriodsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPeriodsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=100, minimum=1) + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPeriodsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods'} # type: ignore + + async def get( + self, + billing_period_name: str, + **kwargs + ) -> "models.BillingPeriod": + """Gets a named billing period. This is only supported for Azure Web-Direct subscriptions. Other + subscription types which were not purchased directly through the Azure web portal are not + supported through this preview API. + + :param billing_period_name: The name of a BillingPeriod resource. + :type billing_period_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingPeriod, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingPeriod + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPeriod"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingPeriod', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_permissions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_permissions_operations.py new file mode 100644 index 00000000000..5f0d36d6b25 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_permissions_operations.py @@ -0,0 +1,338 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingPermissionsOperations: + """BillingPermissionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_customer( + self, + billing_account_name: str, + customer_name: str, + **kwargs + ) -> AsyncIterable["models.BillingPermissionsListResult"]: + """Lists the billing permissions the caller has for a customer. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/{billingAccountName}/customers/{customerName}/billingPermissions'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name: str, + **kwargs + ) -> AsyncIterable["models.BillingPermissionsListResult"]: + """Lists the billing permissions the caller has on a billing account. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions'} # type: ignore + + def list_by_invoice_sections( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs + ) -> AsyncIterable["models.BillingPermissionsListResult"]: + """Lists the billing permissions the caller has on an invoice section. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_sections.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_invoice_sections.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> AsyncIterable["models.BillingPermissionsListResult"]: + """Lists the billing permissions the caller has on a billing profile. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingPermissions'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_profiles_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_profiles_operations.py new file mode 100644 index 00000000000..fd315d63df1 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_profiles_operations.py @@ -0,0 +1,315 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingProfilesOperations: + """BillingProfilesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_account( + self, + billing_account_name: str, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.BillingProfileListResult"]: + """Lists the billing profiles that a user has access to. The operation is supported for billing + accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param expand: May be used to expand the invoice sections. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingProfileListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingProfileListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProfileListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingProfileListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles'} # type: ignore + + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.BillingProfile": + """Gets a billing profile by its ID. The operation is supported for billing accounts with + agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param expand: May be used to expand the invoice sections. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingProfile, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + + async def _create_or_update_initial( + self, + billing_account_name: str, + billing_profile_name: str, + parameters: "models.BillingProfile", + **kwargs + ) -> Optional["models.BillingProfile"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.BillingProfile"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingProfile') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('BillingProfile', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + + async def begin_create_or_update( + self, + billing_account_name: str, + billing_profile_name: str, + parameters: "models.BillingProfile", + **kwargs + ) -> AsyncLROPoller["models.BillingProfile"]: + """Creates or updates a billing profile. The operation is supported for billing accounts with + agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param parameters: The new or updated billing profile. + :type parameters: ~billing_management_client.models.BillingProfile + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BillingProfile or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.BillingProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProfile"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('BillingProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_property_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_property_operations.py new file mode 100644 index 00000000000..3f8d827d150 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_property_operations.py @@ -0,0 +1,155 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingPropertyOperations: + """BillingPropertyOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + **kwargs + ) -> "models.BillingProperty": + """Get the billing properties for a subscription. This operation is not supported for billing + accounts with agreement type Enterprise Agreement. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingProperty, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProperty"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingProperty', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore + + async def update( + self, + parameters: "models.BillingProperty", + **kwargs + ) -> "models.BillingProperty": + """Updates the billing property of a subscription. Currently, cost center can be updated. The + operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param parameters: Request parameters that are provided to the update billing property + operation. + :type parameters: ~billing_management_client.models.BillingProperty + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingProperty, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProperty"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingProperty') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingProperty', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_assignments_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_assignments_operations.py new file mode 100644 index 00000000000..318a49daca1 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_assignments_operations.py @@ -0,0 +1,650 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingRoleAssignmentsOperations: + """BillingRoleAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_by_billing_account( + self, + billing_account_name: str, + billing_role_assignment_name: str, + **kwargs + ) -> "models.BillingRoleAssignment": + """Gets a role assignment for the caller on a billing account. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + async def delete_by_billing_account( + self, + billing_account_name: str, + billing_role_assignment_name: str, + **kwargs + ) -> "models.BillingRoleAssignment": + """Deletes a role assignment for the caller on a billing account. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + async def get_by_invoice_section( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_assignment_name: str, + **kwargs + ) -> "models.BillingRoleAssignment": + """Gets a role assignment for the caller on an invoice section. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + async def delete_by_invoice_section( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_assignment_name: str, + **kwargs + ) -> "models.BillingRoleAssignment": + """Deletes a role assignment for the caller on an invoice section. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + async def get_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + billing_role_assignment_name: str, + **kwargs + ) -> "models.BillingRoleAssignment": + """Gets a role assignment for the caller on a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + async def delete_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + billing_role_assignment_name: str, + **kwargs + ) -> "models.BillingRoleAssignment": + """Deletes a role assignment for the caller on a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name: str, + **kwargs + ) -> AsyncIterable["models.BillingRoleAssignmentListResult"]: + """Lists the role assignments for the caller on a billing account. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingRoleAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleAssignmentListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs + ) -> AsyncIterable["models.BillingRoleAssignmentListResult"]: + """Lists the role assignments for the caller on an invoice section. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingRoleAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleAssignmentListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> AsyncIterable["models.BillingRoleAssignmentListResult"]: + """Lists the role assignments for the caller on a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingRoleAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleAssignmentListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_definitions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_definitions_operations.py new file mode 100644 index 00000000000..1cbca48b894 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_role_definitions_operations.py @@ -0,0 +1,456 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingRoleDefinitionsOperations: + """BillingRoleDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_by_billing_account( + self, + billing_account_name: str, + billing_role_definition_name: str, + **kwargs + ) -> "models.BillingRoleDefinition": + """Gets the definition for a role on a billing account. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_role_definition_name: The ID that uniquely identifies a role definition. + :type billing_role_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleDefinition, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + async def get_by_invoice_section( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_definition_name: str, + **kwargs + ) -> "models.BillingRoleDefinition": + """Gets the definition for a role on an invoice section. The operation is supported only for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param billing_role_definition_name: The ID that uniquely identifies a role definition. + :type billing_role_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleDefinition, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + async def get_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + billing_role_definition_name: str, + **kwargs + ) -> "models.BillingRoleDefinition": + """Gets the definition for a role on a billing profile. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param billing_role_definition_name: The ID that uniquely identifies a role definition. + :type billing_role_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleDefinition, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name: str, + **kwargs + ) -> AsyncIterable["models.BillingRoleDefinitionListResult"]: + """Lists the role definitions for a billing account. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingRoleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleDefinitionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs + ) -> AsyncIterable["models.BillingRoleDefinitionListResult"]: + """Lists the role definitions for an invoice section. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingRoleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleDefinitionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> AsyncIterable["models.BillingRoleDefinitionListResult"]: + """Lists the role definitions for a billing profile. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingRoleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleDefinitionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_subscriptions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_subscriptions_operations.py new file mode 100644 index 00000000000..bcbcb94192e --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_billing_subscriptions_operations.py @@ -0,0 +1,659 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingSubscriptionsOperations: + """BillingSubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_customer( + self, + billing_account_name: str, + customer_name: str, + **kwargs + ) -> AsyncIterable["models.BillingSubscriptionsListResult"]: + """Lists the subscriptions for a customer. The operation is supported only for billing accounts + with agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/{billingAccountName}/customers/{customerName}/billingSubscriptions'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name: str, + **kwargs + ) -> AsyncIterable["models.BillingSubscriptionsListResult"]: + """Lists the subscriptions for a billing account. The operation is supported for billing accounts + with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> AsyncIterable["models.BillingSubscriptionsListResult"]: + """Lists the subscriptions that are billed to a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs + ) -> AsyncIterable["models.BillingSubscriptionsListResult"]: + """Lists the subscriptions that are billed to an invoice section. The operation is supported only + for billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingSubscriptions'} # type: ignore + + async def get( + self, + billing_account_name: str, + **kwargs + ) -> "models.BillingSubscription": + """Gets a subscription by its ID. The operation is supported for billing accounts with agreement + type Microsoft Customer Agreement and Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingSubscription, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingSubscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + + async def update( + self, + billing_account_name: str, + parameters: "models.BillingSubscription", + **kwargs + ) -> "models.BillingSubscription": + """Updates the properties of a billing subscription. Currently, cost center can be updated. The + operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the update billing subscription + operation. + :type parameters: ~billing_management_client.models.BillingSubscription + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingSubscription, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingSubscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingSubscription') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + + async def _move_initial( + self, + billing_account_name: str, + parameters: "models.TransferBillingSubscriptionRequestProperties", + **kwargs + ) -> Optional["models.BillingSubscription"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.BillingSubscription"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._move_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _move_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + + async def begin_move( + self, + billing_account_name: str, + parameters: "models.TransferBillingSubscriptionRequestProperties", + **kwargs + ) -> AsyncLROPoller["models.BillingSubscription"]: + """Moves a subscription's charges to a new invoice section. The new invoice section must belong to + the same billing profile as the existing invoice section. This operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the move subscription operation. + :type parameters: ~billing_management_client.models.TransferBillingSubscriptionRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BillingSubscription or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.BillingSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscription"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._move_initial( + billing_account_name=billing_account_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + + async def validate_move( + self, + billing_account_name: str, + parameters: "models.TransferBillingSubscriptionRequestProperties", + **kwargs + ) -> "models.ValidateSubscriptionTransferEligibilityResult": + """Validates if a subscription's charges can be moved to a new invoice section. This operation is + supported for billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the validate move eligibility + operation. + :type parameters: ~billing_management_client.models.TransferBillingSubscriptionRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ValidateSubscriptionTransferEligibilityResult, or the result of cls(response) + :rtype: ~billing_management_client.models.ValidateSubscriptionTransferEligibilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ValidateSubscriptionTransferEligibilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.validate_move.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ValidateSubscriptionTransferEligibilityResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/validateMoveEligibility'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_customers_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_customers_operations.py new file mode 100644 index 00000000000..2edf0137ecb --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_customers_operations.py @@ -0,0 +1,274 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CustomersOperations: + """CustomersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + search: Optional[str] = None, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.CustomerListResult"]: + """Lists the customers that are billed to a billing profile. The operation is supported only for + billing accounts with agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param search: Used for searching customers by their name. Any customer with name containing + the search text will be included in the response. + :type search: str + :param filter: May be used to filter the list of customers. + :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 CustomerListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.CustomerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if search is not None: + query_parameters['$search'] = self._serialize.query("search", search, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CustomerListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name: str, + search: Optional[str] = None, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.CustomerListResult"]: + """Lists the customers that are billed to a billing account. The operation is supported only for + billing accounts with agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param search: Used for searching customers by their name. Any customer with name containing + the search text will be included in the response. + :type search: str + :param filter: May be used to filter the list of customers. + :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 CustomerListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.CustomerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if search is not None: + query_parameters['$search'] = self._serialize.query("search", search, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CustomerListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers'} # type: ignore + + async def get( + self, + billing_account_name: str, + customer_name: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Customer": + """Gets a customer by its ID. The operation is supported only for billing accounts with agreement + type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :param expand: May be used to expand enabledAzurePlans and resellers. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Customer, or the result of cls(response) + :rtype: ~billing_management_client.models.Customer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Customer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Customer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_enrollment_accounts_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_enrollment_accounts_operations.py new file mode 100644 index 00000000000..00624016d9d --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_enrollment_accounts_operations.py @@ -0,0 +1,159 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class EnrollmentAccountsOperations: + """EnrollmentAccountsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.EnrollmentAccountListResult"]: + """Lists the enrollment accounts the caller has access to. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EnrollmentAccountListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.EnrollmentAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EnrollmentAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('EnrollmentAccountListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts'} # type: ignore + + async def get( + self, + name: str, + **kwargs + ) -> "models.EnrollmentAccountSummary": + """Gets a enrollment account by name. + + :param name: Enrollment Account name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EnrollmentAccountSummary, or the result of cls(response) + :rtype: ~billing_management_client.models.EnrollmentAccountSummary + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EnrollmentAccountSummary"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'name': self._serialize.url("name", name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EnrollmentAccountSummary', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{name}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_instructions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_instructions_operations.py new file mode 100644 index 00000000000..280cb85bb59 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_instructions_operations.py @@ -0,0 +1,250 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class InstructionsOperations: + """InstructionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> AsyncIterable["models.InstructionListResult"]: + """Lists the instructions by billing profile id. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InstructionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.InstructionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InstructionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('InstructionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions'} # type: ignore + + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + instruction_name: str, + **kwargs + ) -> "models.Instruction": + """Get the instruction by name. These are custom billing instructions and are only applicable for + certain customers. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param instruction_name: Instruction Name. + :type instruction_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Instruction, or the result of cls(response) + :rtype: ~billing_management_client.models.Instruction + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Instruction"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Instruction', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore + + async def put( + self, + billing_account_name: str, + billing_profile_name: str, + instruction_name: str, + parameters: "models.Instruction", + **kwargs + ) -> "models.Instruction": + """Creates or updates an instruction. These are custom billing instructions and are only + applicable for certain customers. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param instruction_name: Instruction Name. + :type instruction_name: str + :param parameters: The new instruction. + :type parameters: ~billing_management_client.models.Instruction + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Instruction, or the result of cls(response) + :rtype: ~billing_management_client.models.Instruction + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Instruction"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.put.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Instruction') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Instruction', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + put.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoice_sections_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoice_sections_operations.py new file mode 100644 index 00000000000..94fa65f0bc4 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoice_sections_operations.py @@ -0,0 +1,320 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class InvoiceSectionsOperations: + """InvoiceSectionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> AsyncIterable["models.InvoiceSectionListResult"]: + """Lists the invoice sections that a user has access to. The operation is supported only for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceSectionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.InvoiceSectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceSectionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections'} # type: ignore + + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs + ) -> "models.InvoiceSection": + """Gets an invoice section by its ID. The operation is supported only for billing accounts with + agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InvoiceSection, or the result of cls(response) + :rtype: ~billing_management_client.models.InvoiceSection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('InvoiceSection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + + async def _create_or_update_initial( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "models.InvoiceSection", + **kwargs + ) -> Optional["models.InvoiceSection"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.InvoiceSection"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'InvoiceSection') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('InvoiceSection', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + + async def begin_create_or_update( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "models.InvoiceSection", + **kwargs + ) -> AsyncLROPoller["models.InvoiceSection"]: + """Creates or updates an invoice section. The operation is supported only for billing accounts + with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param parameters: The new or updated invoice section. + :type parameters: ~billing_management_client.models.InvoiceSection + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either InvoiceSection or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.InvoiceSection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSection"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('InvoiceSection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoices_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoices_operations.py new file mode 100644 index 00000000000..5818831867b --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_invoices_operations.py @@ -0,0 +1,948 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class InvoicesOperations: + """InvoicesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_account( + self, + billing_account_name: str, + period_start_date: str, + period_end_date: str, + **kwargs + ) -> AsyncIterable["models.InvoiceListResult"]: + """Lists the invoices for a billing account for a given start date and end date. The operation is + supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft + Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param period_start_date: The start date to fetch the invoices. The date should be specified in + MM-DD-YYYY format. + :type period_start_date: str + :param period_end_date: The end date to fetch the invoices. The date should be specified in MM- + DD-YYYY format. + :type period_end_date: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.InvoiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + period_start_date: str, + period_end_date: str, + **kwargs + ) -> AsyncIterable["models.InvoiceListResult"]: + """Lists the invoices for a billing profile for a given start date and end date. The operation is + supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft + Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param period_start_date: The start date to fetch the invoices. The date should be specified in + MM-DD-YYYY format. + :type period_start_date: str + :param period_end_date: The end date to fetch the invoices. The date should be specified in MM- + DD-YYYY format. + :type period_end_date: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.InvoiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices'} # type: ignore + + async def get( + self, + billing_account_name: str, + invoice_name: str, + **kwargs + ) -> "models.Invoice": + """Gets an invoice by billing account name and ID. The operation is supported for billing accounts + with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Invoice, or the result of cls(response) + :rtype: ~billing_management_client.models.Invoice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Invoice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Invoice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}'} # type: ignore + + async def get_by_id( + self, + invoice_name: str, + **kwargs + ) -> "models.Invoice": + """Gets an invoice by ID. The operation is supported for billing accounts with agreement type + Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Invoice, or the result of cls(response) + :rtype: ~billing_management_client.models.Invoice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Invoice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Invoice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}'} # type: ignore + + async def _download_invoice_initial( + self, + billing_account_name: str, + invoice_name: str, + download_token: str, + **kwargs + ) -> Optional["models.DownloadUrl"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self._download_invoice_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore + + async def begin_download_invoice( + self, + billing_account_name: str, + invoice_name: str, + download_token: str, + **kwargs + ) -> AsyncLROPoller["models.DownloadUrl"]: + """Gets a URL to download an invoice. The operation is supported for billing accounts with + agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :param download_token: Download token with document source and document ID. + :type download_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._download_invoice_initial( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + download_token=download_token, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore + + async def _download_multiple_billing_profile_invoices_initial( + self, + billing_account_name: str, + download_urls: List[str], + **kwargs + ) -> Optional["models.DownloadUrl"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._download_multiple_billing_profile_invoices_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(download_urls, '[str]') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_multiple_billing_profile_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + + async def begin_download_multiple_billing_profile_invoices( + self, + billing_account_name: str, + download_urls: List[str], + **kwargs + ) -> AsyncLROPoller["models.DownloadUrl"]: + """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as + a zip file. The operation is supported for billing accounts with agreement type Microsoft + Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param download_urls: An array of download urls for individual documents. + :type download_urls: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._download_multiple_billing_profile_invoices_initial( + billing_account_name=billing_account_name, + download_urls=download_urls, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_profile_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + + def list_by_billing_subscription( + self, + period_start_date: str, + period_end_date: str, + **kwargs + ) -> AsyncIterable["models.InvoiceListResult"]: + """Lists the invoices for a subscription. + + :param period_start_date: Invoice period start date. + :type period_start_date: str + :param period_end_date: Invoice period end date. + :type period_end_date: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.InvoiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices'} # type: ignore + + async def get_by_subscription_and_invoice_id( + self, + invoice_name: str, + **kwargs + ) -> "models.Invoice": + """Gets an invoice by subscription ID and invoice ID. + + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Invoice, or the result of cls(response) + :rtype: ~billing_management_client.models.Invoice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Invoice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_subscription_and_invoice_id.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Invoice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_subscription_and_invoice_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}'} # type: ignore + + async def _download_billing_subscription_invoice_initial( + self, + invoice_name: str, + download_token: str, + **kwargs + ) -> Optional["models.DownloadUrl"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self._download_billing_subscription_invoice_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_billing_subscription_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore + + async def begin_download_billing_subscription_invoice( + self, + invoice_name: str, + download_token: str, + **kwargs + ) -> AsyncLROPoller["models.DownloadUrl"]: + """Gets a URL to download an invoice. + + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :param download_token: Download token with document source and document ID. + :type download_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._download_billing_subscription_invoice_initial( + invoice_name=invoice_name, + download_token=download_token, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_billing_subscription_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore + + async def _download_multiple_billing_subscription_invoices_initial( + self, + download_urls: List[str], + **kwargs + ) -> Optional["models.DownloadUrl"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._download_multiple_billing_subscription_invoices_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(download_urls, '[str]') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_multiple_billing_subscription_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore + + async def begin_download_multiple_billing_subscription_invoices( + self, + download_urls: List[str], + **kwargs + ) -> AsyncLROPoller["models.DownloadUrl"]: + """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as + a zip file. + + :param download_urls: An array of download urls for individual documents. + :type download_urls: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._download_multiple_billing_subscription_invoices_initial( + download_urls=download_urls, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_subscription_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_operations.py new file mode 100644 index 00000000000..1a11de145c2 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists the available billing REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Billing/operations'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_policies_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_policies_operations.py new file mode 100644 index 00000000000..bf34772d852 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_policies_operations.py @@ -0,0 +1,293 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PoliciesOperations: + """PoliciesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + **kwargs + ) -> "models.Policy": + """Lists the policies for a billing profile. This operation is supported only for billing accounts + with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Policy, or the result of cls(response) + :rtype: ~billing_management_client.models.Policy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Policy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Policy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + async def update( + self, + billing_account_name: str, + billing_profile_name: str, + parameters: "models.Policy", + **kwargs + ) -> "models.Policy": + """Updates the policies for a billing profile. This operation is supported only for billing + accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param parameters: Request parameters that are provided to the update policies operation. + :type parameters: ~billing_management_client.models.Policy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Policy, or the result of cls(response) + :rtype: ~billing_management_client.models.Policy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Policy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Policy') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Policy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + async def get_by_customer( + self, + billing_account_name: str, + customer_name: str, + **kwargs + ) -> "models.CustomerPolicy": + """Lists the policies for a customer. This operation is supported only for billing accounts with + agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomerPolicy, or the result of cls(response) + :rtype: ~billing_management_client.models.CustomerPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomerPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore + + async def update_customer( + self, + billing_account_name: str, + customer_name: str, + parameters: "models.CustomerPolicy", + **kwargs + ) -> "models.CustomerPolicy": + """Updates the policies for a customer. This operation is supported only for billing accounts with + agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :param parameters: Request parameters that are provided to the update policies operation. + :type parameters: ~billing_management_client.models.CustomerPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomerPolicy, or the result of cls(response) + :rtype: ~billing_management_client.models.CustomerPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'CustomerPolicy') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomerPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_products_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_products_operations.py new file mode 100644 index 00000000000..36c2559bf90 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_products_operations.py @@ -0,0 +1,638 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProductsOperations: + """ProductsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_customer( + self, + billing_account_name: str, + customer_name: str, + **kwargs + ) -> AsyncIterable["models.ProductsListResult"]: + """Lists the products for a customer. These don't include products billed based on usage.The + operation is supported only for billing accounts with agreement type Microsoft Partner + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/{billingAccountName}/customers/{customerName}/products'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProductsListResult"]: + """Lists the products for a billing account. These don't include products billed based on usage. + The operation is supported for billing accounts with agreement type Microsoft Customer + Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param filter: May be used to filter by product type. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key + value pair string where key and value are 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 ProductsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name: str, + billing_profile_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProductsListResult"]: + """Lists the products for a billing profile. These don't include products billed based on usage. + The operation is supported for billing accounts with agreement type Microsoft Customer + Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param filter: May be used to filter by product type. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key + value pair string where key and value are 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 ProductsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/products'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProductsListResult"]: + """Lists the products for an invoice section. These don't include products billed based on usage. + The operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param filter: May be used to filter by product type. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key + value pair string where key and value are 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 ProductsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/products'} # type: ignore + + async def get( + self, + billing_account_name: str, + product_name: str, + **kwargs + ) -> "models.Product": + """Gets a product by ID. The operation is supported only for billing accounts with agreement type + Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~billing_management_client.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Product', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + async def update( + self, + billing_account_name: str, + product_name: str, + parameters: "models.Product", + **kwargs + ) -> "models.Product": + """Updates the properties of a Product. Currently, auto renew can be updated. The operation is + supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :param parameters: Request parameters that are provided to the update product operation. + :type parameters: ~billing_management_client.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~billing_management_client.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Product') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Product', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + async def move( + self, + billing_account_name: str, + product_name: str, + parameters: "models.TransferProductRequestProperties", + **kwargs + ) -> Optional["models.Product"]: + """Moves a product's charges to a new invoice section. The new invoice section must belong to the + same billing profile as the existing invoice section. This operation is supported only for + products that are purchased with a recurring charge and for billing accounts with agreement + type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :param parameters: Request parameters that are provided to the move product operation. + :type parameters: ~billing_management_client.models.TransferProductRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~billing_management_client.models.Product or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.move.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Product', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move'} # type: ignore + + async def validate_move( + self, + billing_account_name: str, + product_name: str, + parameters: "models.TransferProductRequestProperties", + **kwargs + ) -> "models.ValidateProductTransferEligibilityResult": + """Validates if a product's charges can be moved to a new invoice section. This operation is + supported only for products that are purchased with a recurring charge and for billing accounts + with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :param parameters: Request parameters that are provided to the validate move eligibility + operation. + :type parameters: ~billing_management_client.models.TransferProductRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ValidateProductTransferEligibilityResult, or the result of cls(response) + :rtype: ~billing_management_client.models.ValidateProductTransferEligibilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ValidateProductTransferEligibilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.validate_move.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ValidateProductTransferEligibilityResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_transactions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_transactions_operations.py new file mode 100644 index 00000000000..4d422ed69e9 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/aio/operations/_transactions_operations.py @@ -0,0 +1,117 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TransactionsOperations: + """TransactionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_invoice( + self, + billing_account_name: str, + invoice_name: str, + **kwargs + ) -> AsyncIterable["models.TransactionListResult"]: + """Lists the transactions for an invoice. Transactions include purchases, refunds and Azure usage + charges. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TransactionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~billing_management_client.models.TransactionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TransactionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TransactionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactions'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/models/__init__.py b/src/billing/azext_billing/vendored_sdks/billing/models/__init__.py new file mode 100644 index 00000000000..33834337f27 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/models/__init__.py @@ -0,0 +1,294 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AddressDetails + from ._models_py3 import Agreement + from ._models_py3 import AgreementListResult + from ._models_py3 import Amount + from ._models_py3 import AvailableBalance + from ._models_py3 import AzurePlan + from ._models_py3 import BillingAccount + from ._models_py3 import BillingAccountListResult + from ._models_py3 import BillingAccountUpdateRequest + from ._models_py3 import BillingPeriod + from ._models_py3 import BillingPeriodsListResult + from ._models_py3 import BillingPermissionsListResult + from ._models_py3 import BillingPermissionsProperties + from ._models_py3 import BillingProfile + from ._models_py3 import BillingProfileCreationRequest + from ._models_py3 import BillingProfileListResult + from ._models_py3 import BillingProfilesOnExpand + from ._models_py3 import BillingProperty + from ._models_py3 import BillingRoleAssignment + from ._models_py3 import BillingRoleAssignmentListResult + from ._models_py3 import BillingRoleDefinition + from ._models_py3 import BillingRoleDefinitionListResult + from ._models_py3 import BillingSubscription + from ._models_py3 import BillingSubscriptionsListResult + from ._models_py3 import Customer + from ._models_py3 import CustomerListResult + from ._models_py3 import CustomerPolicy + from ._models_py3 import Department + from ._models_py3 import Document + from ._models_py3 import DownloadUrl + from ._models_py3 import Enrollment + from ._models_py3 import EnrollmentAccount + from ._models_py3 import EnrollmentAccountContext + from ._models_py3 import EnrollmentAccountListResult + from ._models_py3 import EnrollmentAccountSummary + from ._models_py3 import EnrollmentPolicies + from ._models_py3 import ErrorDetails + from ._models_py3 import ErrorResponse + from ._models_py3 import ErrorSubDetailsItem + from ._models_py3 import IndirectRelationshipInfo + from ._models_py3 import Instruction + from ._models_py3 import InstructionListResult + from ._models_py3 import Invoice + from ._models_py3 import InvoiceListResult + from ._models_py3 import InvoiceSection + from ._models_py3 import InvoiceSectionCreationRequest + from ._models_py3 import InvoiceSectionListResult + from ._models_py3 import InvoiceSectionListWithCreateSubPermissionResult + from ._models_py3 import InvoiceSectionWithCreateSubPermission + from ._models_py3 import InvoiceSectionsOnExpand + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import Participants + from ._models_py3 import PaymentProperties + from ._models_py3 import Policy + from ._models_py3 import Product + from ._models_py3 import ProductsListResult + from ._models_py3 import RebillDetails + from ._models_py3 import Reseller + from ._models_py3 import Resource + from ._models_py3 import Transaction + from ._models_py3 import TransactionListResult + from ._models_py3 import TransferBillingSubscriptionRequestProperties + from ._models_py3 import TransferProductRequestProperties + from ._models_py3 import ValidateAddressResponse + from ._models_py3 import ValidateProductTransferEligibilityError + from ._models_py3 import ValidateProductTransferEligibilityResult + from ._models_py3 import ValidateSubscriptionTransferEligibilityError + from ._models_py3 import ValidateSubscriptionTransferEligibilityResult +except (SyntaxError, ImportError): + from ._models import AddressDetails # type: ignore + from ._models import Agreement # type: ignore + from ._models import AgreementListResult # type: ignore + from ._models import Amount # type: ignore + from ._models import AvailableBalance # type: ignore + from ._models import AzurePlan # type: ignore + from ._models import BillingAccount # type: ignore + from ._models import BillingAccountListResult # type: ignore + from ._models import BillingAccountUpdateRequest # type: ignore + from ._models import BillingPeriod # type: ignore + from ._models import BillingPeriodsListResult # type: ignore + from ._models import BillingPermissionsListResult # type: ignore + from ._models import BillingPermissionsProperties # type: ignore + from ._models import BillingProfile # type: ignore + from ._models import BillingProfileCreationRequest # type: ignore + from ._models import BillingProfileListResult # type: ignore + from ._models import BillingProfilesOnExpand # type: ignore + from ._models import BillingProperty # type: ignore + from ._models import BillingRoleAssignment # type: ignore + from ._models import BillingRoleAssignmentListResult # type: ignore + from ._models import BillingRoleDefinition # type: ignore + from ._models import BillingRoleDefinitionListResult # type: ignore + from ._models import BillingSubscription # type: ignore + from ._models import BillingSubscriptionsListResult # type: ignore + from ._models import Customer # type: ignore + from ._models import CustomerListResult # type: ignore + from ._models import CustomerPolicy # type: ignore + from ._models import Department # type: ignore + from ._models import Document # type: ignore + from ._models import DownloadUrl # type: ignore + from ._models import Enrollment # type: ignore + from ._models import EnrollmentAccount # type: ignore + from ._models import EnrollmentAccountContext # type: ignore + from ._models import EnrollmentAccountListResult # type: ignore + from ._models import EnrollmentAccountSummary # type: ignore + from ._models import EnrollmentPolicies # type: ignore + from ._models import ErrorDetails # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ErrorSubDetailsItem # type: ignore + from ._models import IndirectRelationshipInfo # type: ignore + from ._models import Instruction # type: ignore + from ._models import InstructionListResult # type: ignore + from ._models import Invoice # type: ignore + from ._models import InvoiceListResult # type: ignore + from ._models import InvoiceSection # type: ignore + from ._models import InvoiceSectionCreationRequest # type: ignore + from ._models import InvoiceSectionListResult # type: ignore + from ._models import InvoiceSectionListWithCreateSubPermissionResult # type: ignore + from ._models import InvoiceSectionWithCreateSubPermission # type: ignore + from ._models import InvoiceSectionsOnExpand # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import Participants # type: ignore + from ._models import PaymentProperties # type: ignore + from ._models import Policy # type: ignore + from ._models import Product # type: ignore + from ._models import ProductsListResult # type: ignore + from ._models import RebillDetails # type: ignore + from ._models import Reseller # type: ignore + from ._models import Resource # type: ignore + from ._models import Transaction # type: ignore + from ._models import TransactionListResult # type: ignore + from ._models import TransferBillingSubscriptionRequestProperties # type: ignore + from ._models import TransferProductRequestProperties # type: ignore + from ._models import ValidateAddressResponse # type: ignore + from ._models import ValidateProductTransferEligibilityError # type: ignore + from ._models import ValidateProductTransferEligibilityResult # type: ignore + from ._models import ValidateSubscriptionTransferEligibilityError # type: ignore + from ._models import ValidateSubscriptionTransferEligibilityResult # type: ignore + +from ._billing_management_client_enums import ( + AcceptanceMode, + AccountStatus, + AccountType, + AddressValidationStatus, + AgreementType, + AutoRenew, + BillingFrequency, + BillingProfileSpendingLimit, + BillingProfileStatus, + BillingProfileStatusReasonCode, + BillingRelationshipType, + BillingSubscriptionStatusType, + Category, + DocumentSource, + DocumentType, + InvoiceDocumentType, + InvoiceSectionState, + InvoiceStatus, + InvoiceType, + MarketplacePurchasesPolicy, + PaymentMethodFamily, + ProductStatusType, + ProductTransferValidationErrorCode, + ReservationPurchasesPolicy, + ReservationType, + SpendingLimit, + SpendingLimitForBillingProfile, + StatusReasonCode, + StatusReasonCodeForBillingProfile, + SubscriptionTransferValidationErrorCode, + TargetCloud, + TransactionTypeKind, + ViewCharges, + ViewChargesPolicy, +) + +__all__ = [ + 'AddressDetails', + 'Agreement', + 'AgreementListResult', + 'Amount', + 'AvailableBalance', + 'AzurePlan', + 'BillingAccount', + 'BillingAccountListResult', + 'BillingAccountUpdateRequest', + 'BillingPeriod', + 'BillingPeriodsListResult', + 'BillingPermissionsListResult', + 'BillingPermissionsProperties', + 'BillingProfile', + 'BillingProfileCreationRequest', + 'BillingProfileListResult', + 'BillingProfilesOnExpand', + 'BillingProperty', + 'BillingRoleAssignment', + 'BillingRoleAssignmentListResult', + 'BillingRoleDefinition', + 'BillingRoleDefinitionListResult', + 'BillingSubscription', + 'BillingSubscriptionsListResult', + 'Customer', + 'CustomerListResult', + 'CustomerPolicy', + 'Department', + 'Document', + 'DownloadUrl', + 'Enrollment', + 'EnrollmentAccount', + 'EnrollmentAccountContext', + 'EnrollmentAccountListResult', + 'EnrollmentAccountSummary', + 'EnrollmentPolicies', + 'ErrorDetails', + 'ErrorResponse', + 'ErrorSubDetailsItem', + 'IndirectRelationshipInfo', + 'Instruction', + 'InstructionListResult', + 'Invoice', + 'InvoiceListResult', + 'InvoiceSection', + 'InvoiceSectionCreationRequest', + 'InvoiceSectionListResult', + 'InvoiceSectionListWithCreateSubPermissionResult', + 'InvoiceSectionWithCreateSubPermission', + 'InvoiceSectionsOnExpand', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'Participants', + 'PaymentProperties', + 'Policy', + 'Product', + 'ProductsListResult', + 'RebillDetails', + 'Reseller', + 'Resource', + 'Transaction', + 'TransactionListResult', + 'TransferBillingSubscriptionRequestProperties', + 'TransferProductRequestProperties', + 'ValidateAddressResponse', + 'ValidateProductTransferEligibilityError', + 'ValidateProductTransferEligibilityResult', + 'ValidateSubscriptionTransferEligibilityError', + 'ValidateSubscriptionTransferEligibilityResult', + 'AcceptanceMode', + 'AccountStatus', + 'AccountType', + 'AddressValidationStatus', + 'AgreementType', + 'AutoRenew', + 'BillingFrequency', + 'BillingProfileSpendingLimit', + 'BillingProfileStatus', + 'BillingProfileStatusReasonCode', + 'BillingRelationshipType', + 'BillingSubscriptionStatusType', + 'Category', + 'DocumentSource', + 'DocumentType', + 'InvoiceDocumentType', + 'InvoiceSectionState', + 'InvoiceStatus', + 'InvoiceType', + 'MarketplacePurchasesPolicy', + 'PaymentMethodFamily', + 'ProductStatusType', + 'ProductTransferValidationErrorCode', + 'ReservationPurchasesPolicy', + 'ReservationType', + 'SpendingLimit', + 'SpendingLimitForBillingProfile', + 'StatusReasonCode', + 'StatusReasonCodeForBillingProfile', + 'SubscriptionTransferValidationErrorCode', + 'TargetCloud', + 'TransactionTypeKind', + 'ViewCharges', + 'ViewChargesPolicy', +] diff --git a/src/billing/azext_billing/vendored_sdks/billing/models/_billing_management_client_enums.py b/src/billing/azext_billing/vendored_sdks/billing/models/_billing_management_client_enums.py new file mode 100644 index 00000000000..b2c5e1ab210 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/models/_billing_management_client_enums.py @@ -0,0 +1,327 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class AcceptanceMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The mode of acceptance for an agreement. + """ + + CLICK_TO_ACCEPT = "ClickToAccept" + E_SIGN_EMBEDDED = "ESignEmbedded" + E_SIGN_OFFLINE = "ESignOffline" + +class AccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The current status of the billing account. + """ + + ACTIVE = "Active" + DELETED = "Deleted" + DISABLED = "Disabled" + EXPIRED = "Expired" + TRANSFERRED = "Transferred" + EXTENDED = "Extended" + TERMINATED = "Terminated" + +class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of customer. + """ + + ENTERPRISE = "Enterprise" + INDIVIDUAL = "Individual" + PARTNER = "Partner" + +class AddressValidationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status of the address validation. + """ + + VALID = "Valid" + INVALID = "Invalid" + +class AgreementType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of agreement. + """ + + MICROSOFT_CUSTOMER_AGREEMENT = "MicrosoftCustomerAgreement" + ENTERPRISE_AGREEMENT = "EnterpriseAgreement" + MICROSOFT_ONLINE_SERVICES_PROGRAM = "MicrosoftOnlineServicesProgram" + MICROSOFT_PARTNER_AGREEMENT = "MicrosoftPartnerAgreement" + +class AutoRenew(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Indicates whether auto renewal is turned on or off for a product. + """ + + OFF = "Off" + ON = "On" + +class BillingFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The frequency at which the product will be billed. + """ + + ONE_TIME = "OneTime" + MONTHLY = "Monthly" + USAGE_BASED = "UsageBased" + +class BillingProfileSpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The billing profile spending limit. + """ + + OFF = "Off" + ON = "On" + +class BillingProfileStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The status of the billing profile. + """ + + ACTIVE = "Active" + DISABLED = "Disabled" + WARNED = "Warned" + +class BillingProfileStatusReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Reason for the specified billing profile status. + """ + + PAST_DUE = "PastDue" + SPENDING_LIMIT_REACHED = "SpendingLimitReached" + SPENDING_LIMIT_EXPIRED = "SpendingLimitExpired" + +class BillingRelationshipType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Identifies which services and purchases are paid by a billing profile. + """ + + DIRECT = "Direct" + INDIRECT_CUSTOMER = "IndirectCustomer" + INDIRECT_PARTNER = "IndirectPartner" + CSP_PARTNER = "CSPPartner" + +class BillingSubscriptionStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The current billing status of the subscription. + """ + + ACTIVE = "Active" + INACTIVE = "Inactive" + ABANDONED = "Abandoned" + DELETED = "Deleted" + WARNING = "Warning" + +class Category(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The category of the agreement signed by a customer. + """ + + MICROSOFT_CUSTOMER_AGREEMENT = "MicrosoftCustomerAgreement" + AFFILIATE_PURCHASE_TERMS = "AffiliatePurchaseTerms" + OTHER = "Other" + +class DocumentSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The source of the document. ENF for Brazil and DRS for rest of the world. + """ + + DRS = "DRS" + ENF = "ENF" + +class DocumentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of the document. + """ + + INVOICE = "Invoice" + VOID_NOTE = "VoidNote" + TAX_RECEIPT = "TaxReceipt" + CREDIT_NOTE = "CreditNote" + +class InvoiceDocumentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of the document. + """ + + INVOICE = "Invoice" + CREDIT_NOTE = "CreditNote" + +class InvoiceSectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Identifies the state of an invoice section. + """ + + ACTIVE = "Active" + RESTRICTED = "Restricted" + +class InvoiceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The current status of the invoice. + """ + + DUE = "Due" + OVER_DUE = "OverDue" + PAID = "Paid" + VOID = "Void" + +class InvoiceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Invoice type. + """ + + AZURE_SERVICE = "AzureService" + AZURE_MARKETPLACE = "AzureMarketplace" + AZURE_SUPPORT = "AzureSupport" + +class MarketplacePurchasesPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The policy that controls whether Azure marketplace purchases are allowed for a billing profile. + """ + + ALL_ALLOWED = "AllAllowed" + ONLY_FREE_ALLOWED = "OnlyFreeAllowed" + NOT_ALLOWED = "NotAllowed" + +class PaymentMethodFamily(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The family of payment method. + """ + + CREDITS = "Credits" + CHECK_WIRE = "CheckWire" + CREDIT_CARD = "CreditCard" + NONE = "None" + +class ProductStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The current status of the product. + """ + + ACTIVE = "Active" + INACTIVE = "Inactive" + PAST_DUE = "PastDue" + EXPIRING = "Expiring" + EXPIRED = "Expired" + DISABLED = "Disabled" + CANCELLED = "Cancelled" + AUTO_RENEW = "AutoRenew" + +class ProductTransferValidationErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Error code of the transfer validation response. + """ + + INVALID_SOURCE = "InvalidSource" + PRODUCT_NOT_ACTIVE = "ProductNotActive" + INSUFFICIENT_PERMISSION_ON_SOURCE = "InsufficientPermissionOnSource" + INSUFFICIENT_PERMISSION_ON_DESTINATION = "InsufficientPermissionOnDestination" + DESTINATION_BILLING_PROFILE_PAST_DUE = "DestinationBillingProfilePastDue" + PRODUCT_TYPE_NOT_SUPPORTED = "ProductTypeNotSupported" + CROSS_BILLING_ACCOUNT_NOT_ALLOWED = "CrossBillingAccountNotAllowed" + NOT_AVAILABLE_FOR_DESTINATION_MARKET = "NotAvailableForDestinationMarket" + ONE_TIME_PURCHASE_PRODUCT_TRANSFER_NOT_ALLOWED = "OneTimePurchaseProductTransferNotAllowed" + +class ReservationPurchasesPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The policy that controls whether Azure reservation purchases are allowed for a billing profile. + """ + + ALLOWED = "Allowed" + NOT_ALLOWED = "NotAllowed" + +class ReservationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of transaction. + """ + + PURCHASE = "Purchase" + USAGE_CHARGE = "Usage Charge" + +class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The billing profile spending limit. + """ + + OFF = "Off" + ON = "On" + +class SpendingLimitForBillingProfile(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The billing profile spending limit. + """ + + OFF = "Off" + ON = "On" + +class StatusReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Reason for the specified billing profile status. + """ + + PAST_DUE = "PastDue" + SPENDING_LIMIT_REACHED = "SpendingLimitReached" + SPENDING_LIMIT_EXPIRED = "SpendingLimitExpired" + +class StatusReasonCodeForBillingProfile(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Reason for the specified billing profile status. + """ + + PAST_DUE = "PastDue" + SPENDING_LIMIT_REACHED = "SpendingLimitReached" + SPENDING_LIMIT_EXPIRED = "SpendingLimitExpired" + +class SubscriptionTransferValidationErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Error code of the transfer validation response. + """ + + BILLING_ACCOUNT_INACTIVE = "BillingAccountInactive" + CROSS_BILLING_ACCOUNT_NOT_ALLOWED = "CrossBillingAccountNotAllowed" + DESTINATION_BILLING_PROFILE_INACTIVE = "DestinationBillingProfileInactive" + DESTINATION_BILLING_PROFILE_NOT_FOUND = "DestinationBillingProfileNotFound" + DESTINATION_BILLING_PROFILE_PAST_DUE = "DestinationBillingProfilePastDue" + DESTINATION_INVOICE_SECTION_INACTIVE = "DestinationInvoiceSectionInactive" + DESTINATION_INVOICE_SECTION_NOT_FOUND = "DestinationInvoiceSectionNotFound" + INSUFFICIENT_PERMISSION_ON_DESTINATION = "InsufficientPermissionOnDestination" + INSUFFICIENT_PERMISSION_ON_SOURCE = "InsufficientPermissionOnSource" + INVALID_DESTINATION = "InvalidDestination" + INVALID_SOURCE = "InvalidSource" + MARKETPLACE_NOT_ENABLED_ON_DESTINATION = "MarketplaceNotEnabledOnDestination" + NOT_AVAILABLE_FOR_DESTINATION_MARKET = "NotAvailableForDestinationMarket" + PRODUCT_INACTIVE = "ProductInactive" + PRODUCT_NOT_FOUND = "ProductNotFound" + PRODUCT_TYPE_NOT_SUPPORTED = "ProductTypeNotSupported" + SOURCE_BILLING_PROFILE_PAST_DUE = "SourceBillingProfilePastDue" + SOURCE_INVOICE_SECTION_INACTIVE = "SourceInvoiceSectionInactive" + SUBSCRIPTION_NOT_ACTIVE = "SubscriptionNotActive" + SUBSCRIPTION_TYPE_NOT_SUPPORTED = "SubscriptionTypeNotSupported" + +class TargetCloud(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Possible cloud environments. + """ + + US_GOV = "USGov" + US_NAT = "USNat" + US_SEC = "USSec" + +class TransactionTypeKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The kind of transaction. Options are all or reservation. + """ + + ALL = "all" + RESERVATION = "reservation" + +class ViewCharges(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The policy that controls whether the users in customer's organization can view charges at pay- + as-you-go prices. + """ + + ALLOWED = "Allowed" + NOT_ALLOWED = "NotAllowed" + +class ViewChargesPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The policy that controls whether users with Azure RBAC access to a subscription can view its + charges. + """ + + ALLOWED = "Allowed" + NOT_ALLOWED = "NotAllowed" diff --git a/src/billing/azext_billing/vendored_sdks/billing/models/_models.py b/src/billing/azext_billing/vendored_sdks/billing/models/_models.py new file mode 100644 index 00000000000..4224a3fbd18 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/models/_models.py @@ -0,0 +1,3371 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class AddressDetails(msrest.serialization.Model): + """Address details. + + All required parameters must be populated in order to send to Azure. + + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + :param company_name: Company name. + :type company_name: str + :param address_line1: Required. Address line 1. + :type address_line1: str + :param address_line2: Address line 2. + :type address_line2: str + :param address_line3: Address line 3. + :type address_line3: str + :param city: Address city. + :type city: str + :param district: Address district. + :type district: str + :param region: Address region. + :type region: str + :param country: Required. Country code uses ISO2, 2-digit format. + :type country: str + :param postal_code: Postal code. + :type postal_code: str + :param email: Email address. + :type email: str + :param phone_number: Phone number. + :type phone_number: str + """ + + _validation = { + 'address_line1': {'required': True}, + 'country': {'required': True}, + } + + _attribute_map = { + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'company_name': {'key': 'companyName', 'type': 'str'}, + 'address_line1': {'key': 'addressLine1', 'type': 'str'}, + 'address_line2': {'key': 'addressLine2', 'type': 'str'}, + 'address_line3': {'key': 'addressLine3', 'type': 'str'}, + 'city': {'key': 'city', 'type': 'str'}, + 'district': {'key': 'district', 'type': 'str'}, + 'region': {'key': 'region', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'postal_code': {'key': 'postalCode', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AddressDetails, self).__init__(**kwargs) + self.first_name = kwargs.get('first_name', None) + self.last_name = kwargs.get('last_name', None) + self.company_name = kwargs.get('company_name', None) + self.address_line1 = kwargs['address_line1'] + self.address_line2 = kwargs.get('address_line2', None) + self.address_line3 = kwargs.get('address_line3', None) + self.city = kwargs.get('city', None) + self.district = kwargs.get('district', None) + self.region = kwargs.get('region', None) + self.country = kwargs['country'] + self.postal_code = kwargs.get('postal_code', None) + self.email = kwargs.get('email', None) + self.phone_number = kwargs.get('phone_number', None) + + +class Resource(msrest.serialization.Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Agreement(Resource): + """An agreement. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar agreement_link: The URL to download the agreement. + :vartype agreement_link: str + :ivar category: The category of the agreement signed by a customer. Possible values include: + "MicrosoftCustomerAgreement", "AffiliatePurchaseTerms", "Other". + :vartype category: str or ~billing_management_client.models.Category + :ivar acceptance_mode: The mode of acceptance for an agreement. Possible values include: + "ClickToAccept", "ESignEmbedded", "ESignOffline". + :vartype acceptance_mode: str or ~billing_management_client.models.AcceptanceMode + :ivar effective_date: The date from which the agreement is effective. + :vartype effective_date: ~datetime.datetime + :ivar expiration_date: The date when the agreement expires. + :vartype expiration_date: ~datetime.datetime + :param participants: The list of participants that participates in acceptance of an agreement. + :type participants: list[~billing_management_client.models.Participants] + :ivar status: The current status of the agreement. + :vartype status: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'agreement_link': {'readonly': True}, + 'category': {'readonly': True}, + 'acceptance_mode': {'readonly': True}, + 'effective_date': {'readonly': True}, + 'expiration_date': {'readonly': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'agreement_link': {'key': 'properties.agreementLink', 'type': 'str'}, + 'category': {'key': 'properties.category', 'type': 'str'}, + 'acceptance_mode': {'key': 'properties.acceptanceMode', 'type': 'str'}, + 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, + 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, + 'participants': {'key': 'properties.participants', 'type': '[Participants]'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Agreement, self).__init__(**kwargs) + self.agreement_link = None + self.category = None + self.acceptance_mode = None + self.effective_date = None + self.expiration_date = None + self.participants = kwargs.get('participants', None) + self.status = None + + +class AgreementListResult(msrest.serialization.Model): + """Result of listing agreements. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of agreements. + :vartype value: list[~billing_management_client.models.Agreement] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Agreement]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AgreementListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Amount(msrest.serialization.Model): + """The amount. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar currency: The currency for the amount value. + :vartype currency: str + :param value: Amount value. + :type value: float + """ + + _validation = { + 'currency': {'readonly': True}, + } + + _attribute_map = { + 'currency': {'key': 'currency', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(Amount, self).__init__(**kwargs) + self.currency = None + self.value = kwargs.get('value', None) + + +class AvailableBalance(Resource): + """The latest Azure credit balance. This is the balance available for pay now. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar amount: Balance amount. + :vartype amount: ~billing_management_client.models.Amount + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'amount': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'amount': {'key': 'properties.amount', 'type': 'Amount'}, + } + + def __init__( + self, + **kwargs + ): + super(AvailableBalance, self).__init__(**kwargs) + self.amount = None + + +class AzurePlan(msrest.serialization.Model): + """Details of the Azure plan. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param sku_id: The sku id. + :type sku_id: str + :ivar sku_description: The sku description. + :vartype sku_description: str + """ + + _validation = { + 'sku_description': {'readonly': True}, + } + + _attribute_map = { + 'sku_id': {'key': 'skuId', 'type': 'str'}, + 'sku_description': {'key': 'skuDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AzurePlan, self).__init__(**kwargs) + self.sku_id = kwargs.get('sku_id', None) + self.sku_description = None + + +class BillingAccount(Resource): + """A billing account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param display_name: The billing account name. + :type display_name: str + :param sold_to: The address of the individual or organization that is responsible for the + billing account. + :type sold_to: ~billing_management_client.models.AddressDetails + :ivar agreement_type: The type of agreement. Possible values include: + "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", + "MicrosoftPartnerAgreement". + :vartype agreement_type: str or ~billing_management_client.models.AgreementType + :ivar account_type: The type of customer. Possible values include: "Enterprise", "Individual", + "Partner". + :vartype account_type: str or ~billing_management_client.models.AccountType + :ivar account_status: The current status of the billing account. Possible values include: + "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". + :vartype account_status: str or ~billing_management_client.models.AccountStatus + :param billing_profiles: The billing profiles associated with the billing account. By default + this is not populated, unless it's specified in $expand. + :type billing_profiles: ~billing_management_client.models.BillingProfilesOnExpand + :ivar enrollment_details: The details about the associated legacy enrollment. By default this + is not populated, unless it's specified in $expand. + :vartype enrollment_details: ~billing_management_client.models.Enrollment + :param departments: The departments associated to the enrollment. + :type departments: list[~billing_management_client.models.Department] + :param enrollment_accounts: The accounts associated to the enrollment. + :type enrollment_accounts: list[~billing_management_client.models.EnrollmentAccount] + :ivar has_read_access: Indicates whether user has read access to the billing account. + :vartype has_read_access: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'agreement_type': {'readonly': True}, + 'account_type': {'readonly': True}, + 'account_status': {'readonly': True}, + 'enrollment_details': {'readonly': True}, + 'has_read_access': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'sold_to': {'key': 'properties.soldTo', 'type': 'AddressDetails'}, + 'agreement_type': {'key': 'properties.agreementType', 'type': 'str'}, + 'account_type': {'key': 'properties.accountType', 'type': 'str'}, + 'account_status': {'key': 'properties.accountStatus', 'type': 'str'}, + 'billing_profiles': {'key': 'properties.billingProfiles', 'type': 'BillingProfilesOnExpand'}, + 'enrollment_details': {'key': 'properties.enrollmentDetails', 'type': 'Enrollment'}, + 'departments': {'key': 'properties.departments', 'type': '[Department]'}, + 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, + 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingAccount, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.sold_to = kwargs.get('sold_to', None) + self.agreement_type = None + self.account_type = None + self.account_status = None + self.billing_profiles = kwargs.get('billing_profiles', None) + self.enrollment_details = None + self.departments = kwargs.get('departments', None) + self.enrollment_accounts = kwargs.get('enrollment_accounts', None) + self.has_read_access = None + + +class BillingAccountListResult(msrest.serialization.Model): + """The list of billing accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing accounts. + :vartype value: list[~billing_management_client.models.BillingAccount] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingAccount]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingAccountListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingAccountUpdateRequest(msrest.serialization.Model): + """The request properties of the billing account that can be updated. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param display_name: The billing account name. + :type display_name: str + :param sold_to: The address of the individual or organization that is responsible for the + billing account. + :type sold_to: ~billing_management_client.models.AddressDetails + :ivar agreement_type: The type of agreement. Possible values include: + "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", + "MicrosoftPartnerAgreement". + :vartype agreement_type: str or ~billing_management_client.models.AgreementType + :ivar account_type: The type of customer. Possible values include: "Enterprise", "Individual", + "Partner". + :vartype account_type: str or ~billing_management_client.models.AccountType + :ivar account_status: The current status of the billing account. Possible values include: + "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". + :vartype account_status: str or ~billing_management_client.models.AccountStatus + :param billing_profiles: The billing profiles associated with the billing account. By default + this is not populated, unless it's specified in $expand. + :type billing_profiles: ~billing_management_client.models.BillingProfilesOnExpand + :ivar enrollment_details: The details about the associated legacy enrollment. By default this + is not populated, unless it's specified in $expand. + :vartype enrollment_details: ~billing_management_client.models.Enrollment + :param departments: The departments associated to the enrollment. + :type departments: list[~billing_management_client.models.Department] + :param enrollment_accounts: The accounts associated to the enrollment. + :type enrollment_accounts: list[~billing_management_client.models.EnrollmentAccount] + :ivar has_read_access: Indicates whether user has read access to the billing account. + :vartype has_read_access: bool + """ + + _validation = { + 'agreement_type': {'readonly': True}, + 'account_type': {'readonly': True}, + 'account_status': {'readonly': True}, + 'enrollment_details': {'readonly': True}, + 'has_read_access': {'readonly': True}, + } + + _attribute_map = { + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'sold_to': {'key': 'properties.soldTo', 'type': 'AddressDetails'}, + 'agreement_type': {'key': 'properties.agreementType', 'type': 'str'}, + 'account_type': {'key': 'properties.accountType', 'type': 'str'}, + 'account_status': {'key': 'properties.accountStatus', 'type': 'str'}, + 'billing_profiles': {'key': 'properties.billingProfiles', 'type': 'BillingProfilesOnExpand'}, + 'enrollment_details': {'key': 'properties.enrollmentDetails', 'type': 'Enrollment'}, + 'departments': {'key': 'properties.departments', 'type': '[Department]'}, + 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, + 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingAccountUpdateRequest, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.sold_to = kwargs.get('sold_to', None) + self.agreement_type = None + self.account_type = None + self.account_status = None + self.billing_profiles = kwargs.get('billing_profiles', None) + self.enrollment_details = None + self.departments = kwargs.get('departments', None) + self.enrollment_accounts = kwargs.get('enrollment_accounts', None) + self.has_read_access = None + + +class BillingPeriod(Resource): + """A billing period resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar billing_period_start_date: The start of the date range covered by the billing period. + :vartype billing_period_start_date: ~datetime.date + :ivar billing_period_end_date: The end of the date range covered by the billing period. + :vartype billing_period_end_date: ~datetime.date + :ivar invoice_ids: Array of invoice ids that associated with. + :vartype invoice_ids: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'billing_period_start_date': {'readonly': True}, + 'billing_period_end_date': {'readonly': True}, + 'invoice_ids': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'billing_period_start_date': {'key': 'properties.billingPeriodStartDate', 'type': 'date'}, + 'billing_period_end_date': {'key': 'properties.billingPeriodEndDate', 'type': 'date'}, + 'invoice_ids': {'key': 'properties.invoiceIds', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPeriod, self).__init__(**kwargs) + self.billing_period_start_date = None + self.billing_period_end_date = None + self.invoice_ids = None + + +class BillingPeriodsListResult(msrest.serialization.Model): + """Result of listing billing periods. It contains a list of available billing periods in reverse chronological order. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing periods. + :vartype value: list[~billing_management_client.models.BillingPeriod] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingPeriod]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPeriodsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingPermissionsListResult(msrest.serialization.Model): + """Result of list billingPermissions a caller has on a billing account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billingPermissions a caller has on a billing account. + :vartype value: list[~billing_management_client.models.BillingPermissionsProperties] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingPermissionsProperties]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPermissionsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingPermissionsProperties(msrest.serialization.Model): + """The set of allowed action and not allowed actions a caller has on a billing account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar actions: The set of actions that the caller is allowed to perform. + :vartype actions: list[str] + :ivar not_actions: The set of actions that the caller is not allowed to perform. + :vartype not_actions: list[str] + """ + + _validation = { + 'actions': {'readonly': True}, + 'not_actions': {'readonly': True}, + } + + _attribute_map = { + 'actions': {'key': 'actions', 'type': '[str]'}, + 'not_actions': {'key': 'notActions', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPermissionsProperties, self).__init__(**kwargs) + self.actions = None + self.not_actions = None + + +class BillingProfile(Resource): + """A billing profile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param display_name: The name of the billing profile. + :type display_name: str + :param po_number: The purchase order name that will appear on the invoices generated for the + billing profile. + :type po_number: str + :ivar billing_relationship_type: Identifies which services and purchases are paid by a billing + profile. Possible values include: "Direct", "IndirectCustomer", "IndirectPartner", + "CSPPartner". + :vartype billing_relationship_type: str or + ~billing_management_client.models.BillingRelationshipType + :param bill_to: Billing address. + :type bill_to: ~billing_management_client.models.AddressDetails + :ivar indirect_relationship_info: Identifies the billing profile that is linked to another + billing profile in indirect purchase motion. + :vartype indirect_relationship_info: ~billing_management_client.models.IndirectRelationshipInfo + :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are + sent through email. + :type invoice_email_opt_in: bool + :ivar invoice_day: The day of the month when the invoice for the billing profile is generated. + :vartype invoice_day: int + :ivar currency: The currency in which the charges for the billing profile are billed. + :vartype currency: str + :param enabled_azure_plans: Information about the enabled azure plans. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + :param invoice_sections: The invoice sections associated to the billing profile. By default + this is not populated, unless it's specified in $expand. + :type invoice_sections: ~billing_management_client.models.InvoiceSectionsOnExpand + :ivar has_read_access: Indicates whether user has read access to the billing profile. + :vartype has_read_access: bool + :ivar system_id: The system generated unique identifier for a billing profile. + :vartype system_id: str + :ivar status: The status of the billing profile. Possible values include: "Active", "Disabled", + "Warned". + :vartype status: str or ~billing_management_client.models.BillingProfileStatus + :ivar status_reason_code: Reason for the specified billing profile status. Possible values + include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". + :vartype status_reason_code: str or ~billing_management_client.models.StatusReasonCode + :ivar spending_limit: The billing profile spending limit. Possible values include: "Off", "On". + :vartype spending_limit: str or ~billing_management_client.models.SpendingLimit + :ivar target_clouds: Identifies the cloud environments that are associated with a billing + profile. This is a system managed optional field and gets updated as the billing profile gets + associated with accounts in various clouds. + :vartype target_clouds: list[str or ~billing_management_client.models.TargetCloud] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'billing_relationship_type': {'readonly': True}, + 'indirect_relationship_info': {'readonly': True}, + 'invoice_day': {'readonly': True}, + 'currency': {'readonly': True}, + 'has_read_access': {'readonly': True}, + 'system_id': {'readonly': True}, + 'status': {'readonly': True}, + 'status_reason_code': {'readonly': True}, + 'spending_limit': {'readonly': True}, + 'target_clouds': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'po_number': {'key': 'properties.poNumber', 'type': 'str'}, + 'billing_relationship_type': {'key': 'properties.billingRelationshipType', 'type': 'str'}, + 'bill_to': {'key': 'properties.billTo', 'type': 'AddressDetails'}, + 'indirect_relationship_info': {'key': 'properties.indirectRelationshipInfo', 'type': 'IndirectRelationshipInfo'}, + 'invoice_email_opt_in': {'key': 'properties.invoiceEmailOptIn', 'type': 'bool'}, + 'invoice_day': {'key': 'properties.invoiceDay', 'type': 'int'}, + 'currency': {'key': 'properties.currency', 'type': 'str'}, + 'enabled_azure_plans': {'key': 'properties.enabledAzurePlans', 'type': '[AzurePlan]'}, + 'invoice_sections': {'key': 'properties.invoiceSections', 'type': 'InvoiceSectionsOnExpand'}, + 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, + 'system_id': {'key': 'properties.systemId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'status_reason_code': {'key': 'properties.statusReasonCode', 'type': 'str'}, + 'spending_limit': {'key': 'properties.spendingLimit', 'type': 'str'}, + 'target_clouds': {'key': 'properties.targetClouds', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingProfile, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.po_number = kwargs.get('po_number', None) + self.billing_relationship_type = None + self.bill_to = kwargs.get('bill_to', None) + self.indirect_relationship_info = None + self.invoice_email_opt_in = kwargs.get('invoice_email_opt_in', None) + self.invoice_day = None + self.currency = None + self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) + self.invoice_sections = kwargs.get('invoice_sections', None) + self.has_read_access = None + self.system_id = None + self.status = None + self.status_reason_code = None + self.spending_limit = None + self.target_clouds = None + + +class BillingProfileCreationRequest(msrest.serialization.Model): + """The request parameters for creating a new billing profile. + + :param display_name: The name of the billing profile. + :type display_name: str + :param po_number: The purchase order name that will appear on the invoices generated for the + billing profile. + :type po_number: str + :param bill_to: The address of the individual or organization that is responsible for the + billing profile. + :type bill_to: ~billing_management_client.models.AddressDetails + :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are + sent through email. + :type invoice_email_opt_in: bool + :param enabled_azure_plans: Enabled azure plans for the billing profile. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + """ + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'po_number': {'key': 'poNumber', 'type': 'str'}, + 'bill_to': {'key': 'billTo', 'type': 'AddressDetails'}, + 'invoice_email_opt_in': {'key': 'invoiceEmailOptIn', 'type': 'bool'}, + 'enabled_azure_plans': {'key': 'enabledAzurePlans', 'type': '[AzurePlan]'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingProfileCreationRequest, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.po_number = kwargs.get('po_number', None) + self.bill_to = kwargs.get('bill_to', None) + self.invoice_email_opt_in = kwargs.get('invoice_email_opt_in', None) + self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) + + +class BillingProfileListResult(msrest.serialization.Model): + """The list of billing profiles. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing profiles. + :vartype value: list[~billing_management_client.models.BillingProfile] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingProfile]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingProfileListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingProfilesOnExpand(msrest.serialization.Model): + """The billing profiles associated with the billing account. By default this is not populated, unless it's specified in $expand. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar has_more_results: Indicates whether there are more billing profiles than the ones listed + in this collection. The collection lists a maximum of 50 billing profiles. To get all billing + profiles, use the list billing profiles API. + :vartype has_more_results: bool + :param value: The billing profiles associated with the billing account. + :type value: list[~billing_management_client.models.BillingProfile] + """ + + _validation = { + 'has_more_results': {'readonly': True}, + } + + _attribute_map = { + 'has_more_results': {'key': 'hasMoreResults', 'type': 'bool'}, + 'value': {'key': 'value', 'type': '[BillingProfile]'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingProfilesOnExpand, self).__init__(**kwargs) + self.has_more_results = None + self.value = kwargs.get('value', None) + + +class BillingProperty(Resource): + """A billing property. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar account_admin_notification_email_address: The email address on which the account admin + gets all Azure notifications. + :vartype account_admin_notification_email_address: str + :ivar billing_tenant_id: The Azure AD tenant ID of the billing account for the subscription. + :vartype billing_tenant_id: str + :ivar billing_account_id: The ID of the billing account to which the subscription is billed. + :vartype billing_account_id: str + :ivar billing_account_display_name: The name of the billing account to which the subscription + is billed. + :vartype billing_account_display_name: str + :ivar billing_profile_id: The ID of the billing profile to which the subscription is billed. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile to which the subscription + is billed. + :vartype billing_profile_display_name: str + :ivar billing_profile_status: The status of the billing profile. Possible values include: + "Active", "Disabled", "Warned". + :vartype billing_profile_status: str or ~billing_management_client.models.BillingProfileStatus + :ivar billing_profile_status_reason_code: Reason for the specified billing profile status. + Possible values include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". + :vartype billing_profile_status_reason_code: str or + ~billing_management_client.models.BillingProfileStatusReasonCode + :ivar billing_profile_spending_limit: The billing profile spending limit. Possible values + include: "Off", "On". + :vartype billing_profile_spending_limit: str or + ~billing_management_client.models.BillingProfileSpendingLimit + :param cost_center: The cost center applied to the subscription. + :type cost_center: str + :ivar invoice_section_id: The ID of the invoice section to which the subscription is billed. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section to which the subscription + is billed. + :vartype invoice_section_display_name: str + :ivar is_account_admin: Indicates whether user is the account admin. + :vartype is_account_admin: bool + :ivar product_id: The product ID of the Azure plan. + :vartype product_id: str + :ivar product_name: The product name of the Azure plan. + :vartype product_name: str + :ivar sku_id: The sku ID of the Azure plan for the subscription. + :vartype sku_id: str + :ivar sku_description: The sku description of the Azure plan for the subscription. + :vartype sku_description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'account_admin_notification_email_address': {'readonly': True}, + 'billing_tenant_id': {'readonly': True}, + 'billing_account_id': {'readonly': True}, + 'billing_account_display_name': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'billing_profile_status': {'readonly': True}, + 'billing_profile_status_reason_code': {'readonly': True}, + 'billing_profile_spending_limit': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'is_account_admin': {'readonly': True}, + 'product_id': {'readonly': True}, + 'product_name': {'readonly': True}, + 'sku_id': {'readonly': True}, + 'sku_description': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'account_admin_notification_email_address': {'key': 'properties.accountAdminNotificationEmailAddress', 'type': 'str'}, + 'billing_tenant_id': {'key': 'properties.billingTenantId', 'type': 'str'}, + 'billing_account_id': {'key': 'properties.billingAccountId', 'type': 'str'}, + 'billing_account_display_name': {'key': 'properties.billingAccountDisplayName', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'billing_profile_status': {'key': 'properties.billingProfileStatus', 'type': 'str'}, + 'billing_profile_status_reason_code': {'key': 'properties.billingProfileStatusReasonCode', 'type': 'str'}, + 'billing_profile_spending_limit': {'key': 'properties.billingProfileSpendingLimit', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'is_account_admin': {'key': 'properties.isAccountAdmin', 'type': 'bool'}, + 'product_id': {'key': 'properties.productId', 'type': 'str'}, + 'product_name': {'key': 'properties.productName', 'type': 'str'}, + 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, + 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingProperty, self).__init__(**kwargs) + self.account_admin_notification_email_address = None + self.billing_tenant_id = None + self.billing_account_id = None + self.billing_account_display_name = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.billing_profile_status = None + self.billing_profile_status_reason_code = None + self.billing_profile_spending_limit = None + self.cost_center = kwargs.get('cost_center', None) + self.invoice_section_id = None + self.invoice_section_display_name = None + self.is_account_admin = None + self.product_id = None + self.product_name = None + self.sku_id = None + self.sku_description = None + + +class BillingRoleAssignment(Resource): + """The role assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar created_on: The date the role assignment was created. + :vartype created_on: str + :ivar created_by_principal_tenant_id: The tenant Id of the user who created the role + assignment. + :vartype created_by_principal_tenant_id: str + :ivar created_by_principal_id: The principal Id of the user who created the role assignment. + :vartype created_by_principal_id: str + :ivar created_by_user_email_address: The email address of the user who created the role + assignment. + :vartype created_by_user_email_address: str + :param principal_id: The principal id of the user to whom the role was assigned. + :type principal_id: str + :param principal_tenant_id: The principal tenant id of the user to whom the role was assigned. + :type principal_tenant_id: str + :param role_definition_id: The ID of the role definition. + :type role_definition_id: str + :ivar scope: The scope at which the role was assigned. + :vartype scope: str + :param user_authentication_type: The authentication type. + :type user_authentication_type: str + :param user_email_address: The email address of the user. + :type user_email_address: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'created_on': {'readonly': True}, + 'created_by_principal_tenant_id': {'readonly': True}, + 'created_by_principal_id': {'readonly': True}, + 'created_by_user_email_address': {'readonly': True}, + 'scope': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'str'}, + 'created_by_principal_tenant_id': {'key': 'properties.createdByPrincipalTenantId', 'type': 'str'}, + 'created_by_principal_id': {'key': 'properties.createdByPrincipalId', 'type': 'str'}, + 'created_by_user_email_address': {'key': 'properties.createdByUserEmailAddress', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_tenant_id': {'key': 'properties.principalTenantId', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'user_authentication_type': {'key': 'properties.userAuthenticationType', 'type': 'str'}, + 'user_email_address': {'key': 'properties.userEmailAddress', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingRoleAssignment, self).__init__(**kwargs) + self.created_on = None + self.created_by_principal_tenant_id = None + self.created_by_principal_id = None + self.created_by_user_email_address = None + self.principal_id = kwargs.get('principal_id', None) + self.principal_tenant_id = kwargs.get('principal_tenant_id', None) + self.role_definition_id = kwargs.get('role_definition_id', None) + self.scope = None + self.user_authentication_type = kwargs.get('user_authentication_type', None) + self.user_email_address = kwargs.get('user_email_address', None) + + +class BillingRoleAssignmentListResult(msrest.serialization.Model): + """The list of role assignments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of role assignments. + :vartype value: list[~billing_management_client.models.BillingRoleAssignment] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingRoleAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingRoleAssignmentListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingRoleDefinition(Resource): + """The properties of a role definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar description: The role description. + :vartype description: str + :param permissions: The billingPermissions the role has. + :type permissions: list[~billing_management_client.models.BillingPermissionsProperties] + :ivar role_name: The name of the role. + :vartype role_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'description': {'readonly': True}, + 'role_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'permissions': {'key': 'properties.permissions', 'type': '[BillingPermissionsProperties]'}, + 'role_name': {'key': 'properties.roleName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingRoleDefinition, self).__init__(**kwargs) + self.description = None + self.permissions = kwargs.get('permissions', None) + self.role_name = None + + +class BillingRoleDefinitionListResult(msrest.serialization.Model): + """The list of role definitions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The role definitions. + :vartype value: list[~billing_management_client.models.BillingRoleDefinition] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingRoleDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingRoleDefinitionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingSubscription(Resource): + """A billing subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: The name of the subscription. + :vartype display_name: str + :ivar subscription_id: The ID of the subscription. + :vartype subscription_id: str + :param subscription_billing_status: The current billing status of the subscription. Possible + values include: "Active", "Inactive", "Abandoned", "Deleted", "Warning". + :type subscription_billing_status: str or + ~billing_management_client.models.BillingSubscriptionStatusType + :ivar last_month_charges: The last month charges. + :vartype last_month_charges: ~billing_management_client.models.Amount + :ivar month_to_date_charges: The current month to date charges. + :vartype month_to_date_charges: ~billing_management_client.models.Amount + :ivar billing_profile_id: The ID of the billing profile to which the subscription is billed. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile to which the subscription + is billed. + :vartype billing_profile_display_name: str + :param cost_center: The cost center applied to the subscription. + :type cost_center: str + :ivar customer_id: The ID of the customer for whom the subscription was created. The field is + applicable only for Microsoft Partner Agreement billing account. + :vartype customer_id: str + :ivar customer_display_name: The name of the customer for whom the subscription was created. + The field is applicable only for Microsoft Partner Agreement billing account. + :vartype customer_display_name: str + :ivar invoice_section_id: The ID of the invoice section to which the subscription is billed. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section to which the subscription + is billed. + :vartype invoice_section_display_name: str + :ivar reseller: Reseller for this subscription. + :vartype reseller: ~billing_management_client.models.Reseller + :param sku_id: The sku ID of the Azure plan for the subscription. + :type sku_id: str + :ivar sku_description: The sku description of the Azure plan for the subscription. + :vartype sku_description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'last_month_charges': {'readonly': True}, + 'month_to_date_charges': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'customer_id': {'readonly': True}, + 'customer_display_name': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'reseller': {'readonly': True}, + 'sku_description': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + 'subscription_billing_status': {'key': 'properties.subscriptionBillingStatus', 'type': 'str'}, + 'last_month_charges': {'key': 'properties.lastMonthCharges', 'type': 'Amount'}, + 'month_to_date_charges': {'key': 'properties.monthToDateCharges', 'type': 'Amount'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, + 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, + 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingSubscription, self).__init__(**kwargs) + self.display_name = None + self.subscription_id = None + self.subscription_billing_status = kwargs.get('subscription_billing_status', None) + self.last_month_charges = None + self.month_to_date_charges = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.cost_center = kwargs.get('cost_center', None) + self.customer_id = None + self.customer_display_name = None + self.invoice_section_id = None + self.invoice_section_display_name = None + self.reseller = None + self.sku_id = kwargs.get('sku_id', None) + self.sku_description = None + + +class BillingSubscriptionsListResult(msrest.serialization.Model): + """The list of billing subscriptions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing subscriptions. + :vartype value: list[~billing_management_client.models.BillingSubscription] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingSubscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingSubscriptionsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Customer(Resource): + """A partner's customer. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar billing_profile_id: The ID of the billing profile for the invoice section. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile for the invoice section. + :vartype billing_profile_display_name: str + :param display_name: The name of the customer. + :type display_name: str + :param enabled_azure_plans: Azure plans enabled for the customer. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + :param resellers: The list of resellers for which an Azure plan is enabled for the customer. + :type resellers: list[~billing_management_client.models.Reseller] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'enabled_azure_plans': {'key': 'properties.enabledAzurePlans', 'type': '[AzurePlan]'}, + 'resellers': {'key': 'properties.resellers', 'type': '[Reseller]'}, + } + + def __init__( + self, + **kwargs + ): + super(Customer, self).__init__(**kwargs) + self.billing_profile_id = None + self.billing_profile_display_name = None + self.display_name = kwargs.get('display_name', None) + self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) + self.resellers = kwargs.get('resellers', None) + + +class CustomerListResult(msrest.serialization.Model): + """The list of customers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of customers. + :vartype value: list[~billing_management_client.models.Customer] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Customer]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CustomerListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class CustomerPolicy(Resource): + """The customer's Policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param view_charges: The policy that controls whether the users in customer's organization can + view charges at pay-as-you-go prices. Possible values include: "Allowed", "NotAllowed". + :type view_charges: str or ~billing_management_client.models.ViewCharges + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'view_charges': {'key': 'properties.viewCharges', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CustomerPolicy, self).__init__(**kwargs) + self.view_charges = kwargs.get('view_charges', None) + + +class Department(Resource): + """A department. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param department_name: The name of the department. + :type department_name: str + :param cost_center: The cost center associated with the department. + :type cost_center: str + :param status: The status of the department. + :type status: str + :param enrollment_accounts: Associated enrollment accounts. By default this is not populated, + unless it's specified in $expand. + :type enrollment_accounts: list[~billing_management_client.models.EnrollmentAccount] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'department_name': {'key': 'properties.departmentName', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, + } + + def __init__( + self, + **kwargs + ): + super(Department, self).__init__(**kwargs) + self.department_name = kwargs.get('department_name', None) + self.cost_center = kwargs.get('cost_center', None) + self.status = kwargs.get('status', None) + self.enrollment_accounts = kwargs.get('enrollment_accounts', None) + + +class Document(msrest.serialization.Model): + """The properties of a document. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar kind: The type of the document. Possible values include: "Invoice", "VoidNote", + "TaxReceipt", "CreditNote". + :vartype kind: str or ~billing_management_client.models.DocumentType + :ivar url: Document URL. + :vartype url: str + :ivar source: The source of the document. ENF for Brazil and DRS for rest of the world. + Possible values include: "DRS", "ENF". + :vartype source: str or ~billing_management_client.models.DocumentSource + """ + + _validation = { + 'kind': {'readonly': True}, + 'url': {'readonly': True}, + 'source': {'readonly': True}, + } + + _attribute_map = { + 'kind': {'key': 'kind', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Document, self).__init__(**kwargs) + self.kind = None + self.url = None + self.source = None + + +class DownloadUrl(msrest.serialization.Model): + """A secure URL that can be used to download a an entity until the URL expires. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar expiry_time: The time in UTC when the download URL will expire. + :vartype expiry_time: ~datetime.datetime + :ivar url: The URL to the PDF file. + :vartype url: str + """ + + _validation = { + 'expiry_time': {'readonly': True}, + 'url': {'readonly': True}, + } + + _attribute_map = { + 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, + 'url': {'key': 'url', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DownloadUrl, self).__init__(**kwargs) + self.expiry_time = None + self.url = None + + +class Enrollment(msrest.serialization.Model): + """The properties of an enrollment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param start_date: The start date of the enrollment. + :type start_date: ~datetime.datetime + :param end_date: The end date of the enrollment. + :type end_date: ~datetime.datetime + :ivar currency: The billing currency for the enrollment. + :vartype currency: str + :ivar channel: The channel type of the enrollment. + :vartype channel: str + :ivar policies: The policies for Enterprise Agreement enrollments. + :vartype policies: ~billing_management_client.models.EnrollmentPolicies + :ivar language: The language for the enrollment. + :vartype language: str + :ivar country_code: The country code of the enrollment. + :vartype country_code: str + :ivar status: The current status of the enrollment. + :vartype status: str + :ivar billing_cycle: The billing cycle for the enrollment. + :vartype billing_cycle: str + """ + + _validation = { + 'currency': {'readonly': True}, + 'channel': {'readonly': True}, + 'policies': {'readonly': True}, + 'language': {'readonly': True}, + 'country_code': {'readonly': True}, + 'status': {'readonly': True}, + 'billing_cycle': {'readonly': True}, + } + + _attribute_map = { + 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'endDate', 'type': 'iso-8601'}, + 'currency': {'key': 'currency', 'type': 'str'}, + 'channel': {'key': 'channel', 'type': 'str'}, + 'policies': {'key': 'policies', 'type': 'EnrollmentPolicies'}, + 'language': {'key': 'language', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'billing_cycle': {'key': 'billingCycle', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Enrollment, self).__init__(**kwargs) + self.start_date = kwargs.get('start_date', None) + self.end_date = kwargs.get('end_date', None) + self.currency = None + self.channel = None + self.policies = None + self.language = None + self.country_code = None + self.status = None + self.billing_cycle = None + + +class EnrollmentAccount(Resource): + """An enrollment account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param account_name: The name of the enrollment account. + :type account_name: str + :param cost_center: The cost center associated with the enrollment account. + :type cost_center: str + :param account_owner: The owner of the enrollment account. + :type account_owner: str + :param status: The status of the enrollment account. + :type status: str + :param start_date: The start date of the enrollment account. + :type start_date: ~datetime.datetime + :param end_date: The end date of the enrollment account. + :type end_date: ~datetime.datetime + :param department: Associated department. By default this is not populated, unless it's + specified in $expand. + :type department: ~billing_management_client.models.Department + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'account_name': {'key': 'properties.accountName', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'account_owner': {'key': 'properties.accountOwner', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, + 'department': {'key': 'properties.department', 'type': 'Department'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentAccount, self).__init__(**kwargs) + self.account_name = kwargs.get('account_name', None) + self.cost_center = kwargs.get('cost_center', None) + self.account_owner = kwargs.get('account_owner', None) + self.status = kwargs.get('status', None) + self.start_date = kwargs.get('start_date', None) + self.end_date = kwargs.get('end_date', None) + self.department = kwargs.get('department', None) + + +class EnrollmentAccountContext(msrest.serialization.Model): + """The enrollment account context. + + :param cost_center: The cost center associated with the enrollment account. + :type cost_center: str + :param start_date: The start date of the enrollment account. + :type start_date: ~datetime.datetime + :param end_date: The end date of the enrollment account. + :type end_date: ~datetime.datetime + :param enrollment_account_name: The ID of the enrollment account. + :type enrollment_account_name: str + """ + + _attribute_map = { + 'cost_center': {'key': 'costCenter', 'type': 'str'}, + 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'endDate', 'type': 'iso-8601'}, + 'enrollment_account_name': {'key': 'enrollmentAccountName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentAccountContext, self).__init__(**kwargs) + self.cost_center = kwargs.get('cost_center', None) + self.start_date = kwargs.get('start_date', None) + self.end_date = kwargs.get('end_date', None) + self.enrollment_account_name = kwargs.get('enrollment_account_name', None) + + +class EnrollmentAccountListResult(msrest.serialization.Model): + """Result of listing enrollment accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of enrollment accounts. + :vartype value: list[~billing_management_client.models.EnrollmentAccountSummary] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[EnrollmentAccountSummary]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentAccountListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class EnrollmentAccountSummary(Resource): + """An enrollment account resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar principal_name: The account owner's principal name. + :vartype principal_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'principal_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentAccountSummary, self).__init__(**kwargs) + self.principal_name = None + + +class EnrollmentPolicies(msrest.serialization.Model): + """The policies for Enterprise Agreement enrollments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar account_owner_view_charges: The policy that controls whether Account Owners can view + charges. + :vartype account_owner_view_charges: bool + :ivar department_admin_view_charges: The policy that controls whether Department Administrators + can view charges. + :vartype department_admin_view_charges: bool + :ivar marketplaces_enabled: The policy that controls whether Azure marketplace purchases are + allowed in the enrollment. + :vartype marketplaces_enabled: bool + :ivar reserved_instances_enabled: The policy that controls whether Azure reservation purchases + are allowed in the enrollment. + :vartype reserved_instances_enabled: bool + """ + + _validation = { + 'account_owner_view_charges': {'readonly': True}, + 'department_admin_view_charges': {'readonly': True}, + 'marketplaces_enabled': {'readonly': True}, + 'reserved_instances_enabled': {'readonly': True}, + } + + _attribute_map = { + 'account_owner_view_charges': {'key': 'accountOwnerViewCharges', 'type': 'bool'}, + 'department_admin_view_charges': {'key': 'departmentAdminViewCharges', 'type': 'bool'}, + 'marketplaces_enabled': {'key': 'marketplacesEnabled', 'type': 'bool'}, + 'reserved_instances_enabled': {'key': 'reservedInstancesEnabled', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentPolicies, self).__init__(**kwargs) + self.account_owner_view_charges = None + self.department_admin_view_charges = None + self.marketplaces_enabled = None + self.reserved_instances_enabled = None + + +class ErrorDetails(msrest.serialization.Model): + """The details of the error. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar details: The sub details of the error. + :vartype details: list[~billing_management_client.models.ErrorSubDetailsItem] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorSubDetailsItem]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetails, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + + +class ErrorResponse(msrest.serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + + :param error: The details of the error. + :type error: ~billing_management_client.models.ErrorDetails + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetails'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorSubDetailsItem(msrest.serialization.Model): + """ErrorSubDetailsItem. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorSubDetailsItem, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + + +class IndirectRelationshipInfo(msrest.serialization.Model): + """The billing profile details of the partner of the customer for an indirect motion. + + :param billing_account_name: The billing account name of the partner or the customer for an + indirect motion. + :type billing_account_name: str + :param billing_profile_name: The billing profile name of the partner or the customer for an + indirect motion. + :type billing_profile_name: str + :param display_name: The display name of the partner or customer for an indirect motion. + :type display_name: str + """ + + _attribute_map = { + 'billing_account_name': {'key': 'billingAccountName', 'type': 'str'}, + 'billing_profile_name': {'key': 'billingProfileName', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IndirectRelationshipInfo, self).__init__(**kwargs) + self.billing_account_name = kwargs.get('billing_account_name', None) + self.billing_profile_name = kwargs.get('billing_profile_name', None) + self.display_name = kwargs.get('display_name', None) + + +class Instruction(Resource): + """An instruction. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param amount: The amount budgeted for this billing instruction. + :type amount: float + :param start_date: The date this billing instruction goes into effect. + :type start_date: ~datetime.datetime + :param end_date: The date this billing instruction is no longer in effect. + :type end_date: ~datetime.datetime + :param creation_date: The date this billing instruction was created. + :type creation_date: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'amount': {'key': 'properties.amount', 'type': 'float'}, + 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, + 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(Instruction, self).__init__(**kwargs) + self.amount = kwargs.get('amount', None) + self.start_date = kwargs.get('start_date', None) + self.end_date = kwargs.get('end_date', None) + self.creation_date = kwargs.get('creation_date', None) + + +class InstructionListResult(msrest.serialization.Model): + """The list of billing instructions used during invoice generation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing instructions used during invoice generation. + :vartype value: list[~billing_management_client.models.Instruction] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Instruction]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InstructionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Invoice(Resource): + """An invoice. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar due_date: The due date for the invoice. + :vartype due_date: ~datetime.datetime + :ivar invoice_date: The date when the invoice was generated. + :vartype invoice_date: ~datetime.datetime + :ivar status: The current status of the invoice. Possible values include: "Due", "OverDue", + "Paid", "Void". + :vartype status: str or ~billing_management_client.models.InvoiceStatus + :ivar amount_due: The amount due as of now. + :vartype amount_due: ~billing_management_client.models.Amount + :ivar azure_prepayment_applied: The amount of Azure prepayment applied to the charges. This + field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + :vartype azure_prepayment_applied: ~billing_management_client.models.Amount + :ivar billed_amount: The total charges for the invoice billing period. + :vartype billed_amount: ~billing_management_client.models.Amount + :ivar credit_amount: The total refund for returns and cancellations during the invoice billing + period. This field is applicable to billing accounts with agreement type Microsoft Customer + Agreement. + :vartype credit_amount: ~billing_management_client.models.Amount + :ivar free_azure_credit_applied: The amount of free Azure credits applied to the charges. This + field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + :vartype free_azure_credit_applied: ~billing_management_client.models.Amount + :ivar sub_total: The pre-tax amount due. This field is applicable to billing accounts with + agreement type Microsoft Customer Agreement. + :vartype sub_total: ~billing_management_client.models.Amount + :ivar tax_amount: The amount of tax charged for the billing period. This field is applicable to + billing accounts with agreement type Microsoft Customer Agreement. + :vartype tax_amount: ~billing_management_client.models.Amount + :ivar total_amount: The amount due when the invoice was generated. This field is applicable to + billing accounts with agreement type Microsoft Customer Agreement. + :vartype total_amount: ~billing_management_client.models.Amount + :ivar invoice_period_start_date: The start date of the billing period for which the invoice is + generated. + :vartype invoice_period_start_date: ~datetime.datetime + :ivar invoice_period_end_date: The end date of the billing period for which the invoice is + generated. + :vartype invoice_period_end_date: ~datetime.datetime + :ivar invoice_type: Invoice type. Possible values include: "AzureService", "AzureMarketplace", + "AzureSupport". + :vartype invoice_type: str or ~billing_management_client.models.InvoiceType + :ivar is_monthly_invoice: Specifies if the invoice is generated as part of monthly invoicing + cycle or not. This field is applicable to billing accounts with agreement type Microsoft + Customer Agreement. + :vartype is_monthly_invoice: bool + :ivar billing_profile_id: The ID of the billing profile for which the invoice is generated. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile for which the invoice is + generated. + :vartype billing_profile_display_name: str + :ivar purchase_order_number: An optional purchase order number for the invoice. + :vartype purchase_order_number: str + :ivar documents: List of documents available to download such as invoice and tax receipt. + :vartype documents: list[~billing_management_client.models.Document] + :ivar payments: List of payments. + :vartype payments: list[~billing_management_client.models.PaymentProperties] + :ivar rebill_details: Rebill details for an invoice. + :vartype rebill_details: dict[str, ~billing_management_client.models.RebillDetails] + :ivar document_type: The type of the document. Possible values include: "Invoice", + "CreditNote". + :vartype document_type: str or ~billing_management_client.models.InvoiceDocumentType + :ivar billed_document_id: The Id of the active invoice which is originally billed after this + invoice was voided. This field is applicable to the void invoices only. + :vartype billed_document_id: str + :ivar credit_for_document_id: The Id of the invoice which got voided and this credit note was + issued as a result. This field is applicable to the credit notes only. + :vartype credit_for_document_id: str + :ivar subscription_id: The ID of the subscription for which the invoice is generated. + :vartype subscription_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'due_date': {'readonly': True}, + 'invoice_date': {'readonly': True}, + 'status': {'readonly': True}, + 'amount_due': {'readonly': True}, + 'azure_prepayment_applied': {'readonly': True}, + 'billed_amount': {'readonly': True}, + 'credit_amount': {'readonly': True}, + 'free_azure_credit_applied': {'readonly': True}, + 'sub_total': {'readonly': True}, + 'tax_amount': {'readonly': True}, + 'total_amount': {'readonly': True}, + 'invoice_period_start_date': {'readonly': True}, + 'invoice_period_end_date': {'readonly': True}, + 'invoice_type': {'readonly': True}, + 'is_monthly_invoice': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'purchase_order_number': {'readonly': True}, + 'documents': {'readonly': True}, + 'payments': {'readonly': True}, + 'rebill_details': {'readonly': True}, + 'document_type': {'readonly': True}, + 'billed_document_id': {'readonly': True}, + 'credit_for_document_id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'due_date': {'key': 'properties.dueDate', 'type': 'iso-8601'}, + 'invoice_date': {'key': 'properties.invoiceDate', 'type': 'iso-8601'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'amount_due': {'key': 'properties.amountDue', 'type': 'Amount'}, + 'azure_prepayment_applied': {'key': 'properties.azurePrepaymentApplied', 'type': 'Amount'}, + 'billed_amount': {'key': 'properties.billedAmount', 'type': 'Amount'}, + 'credit_amount': {'key': 'properties.creditAmount', 'type': 'Amount'}, + 'free_azure_credit_applied': {'key': 'properties.freeAzureCreditApplied', 'type': 'Amount'}, + 'sub_total': {'key': 'properties.subTotal', 'type': 'Amount'}, + 'tax_amount': {'key': 'properties.taxAmount', 'type': 'Amount'}, + 'total_amount': {'key': 'properties.totalAmount', 'type': 'Amount'}, + 'invoice_period_start_date': {'key': 'properties.invoicePeriodStartDate', 'type': 'iso-8601'}, + 'invoice_period_end_date': {'key': 'properties.invoicePeriodEndDate', 'type': 'iso-8601'}, + 'invoice_type': {'key': 'properties.invoiceType', 'type': 'str'}, + 'is_monthly_invoice': {'key': 'properties.isMonthlyInvoice', 'type': 'bool'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'purchase_order_number': {'key': 'properties.purchaseOrderNumber', 'type': 'str'}, + 'documents': {'key': 'properties.documents', 'type': '[Document]'}, + 'payments': {'key': 'properties.payments', 'type': '[PaymentProperties]'}, + 'rebill_details': {'key': 'properties.rebillDetails', 'type': '{RebillDetails}'}, + 'document_type': {'key': 'properties.documentType', 'type': 'str'}, + 'billed_document_id': {'key': 'properties.billedDocumentId', 'type': 'str'}, + 'credit_for_document_id': {'key': 'properties.creditForDocumentId', 'type': 'str'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Invoice, self).__init__(**kwargs) + self.due_date = None + self.invoice_date = None + self.status = None + self.amount_due = None + self.azure_prepayment_applied = None + self.billed_amount = None + self.credit_amount = None + self.free_azure_credit_applied = None + self.sub_total = None + self.tax_amount = None + self.total_amount = None + self.invoice_period_start_date = None + self.invoice_period_end_date = None + self.invoice_type = None + self.is_monthly_invoice = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.purchase_order_number = None + self.documents = None + self.payments = None + self.rebill_details = None + self.document_type = None + self.billed_document_id = None + self.credit_for_document_id = None + self.subscription_id = None + + +class InvoiceListResult(msrest.serialization.Model): + """The list of invoices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of invoices. + :vartype value: list[~billing_management_client.models.Invoice] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Invoice]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class InvoiceSection(Resource): + """An invoice section. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param display_name: The name of the invoice section. + :type display_name: str + :param labels: Dictionary of metadata associated with the invoice section. + :type labels: dict[str, str] + :ivar state: Identifies the state of an invoice section. Possible values include: "Active", + "Restricted". + :vartype state: str or ~billing_management_client.models.InvoiceSectionState + :ivar system_id: The system generated unique identifier for an invoice section. + :vartype system_id: str + :ivar target_cloud: Identifies the cloud environments that are associated with an invoice + section. This is a system managed optional field and gets updated as the invoice section gets + associated with accounts in various clouds. Possible values include: "USGov", "USNat", "USSec". + :vartype target_cloud: str or ~billing_management_client.models.TargetCloud + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'state': {'readonly': True}, + 'system_id': {'readonly': True}, + 'target_cloud': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'labels': {'key': 'properties.labels', 'type': '{str}'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'system_id': {'key': 'properties.systemId', 'type': 'str'}, + 'target_cloud': {'key': 'properties.targetCloud', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceSection, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.labels = kwargs.get('labels', None) + self.state = None + self.system_id = None + self.target_cloud = None + + +class InvoiceSectionCreationRequest(msrest.serialization.Model): + """The properties of the invoice section. + + :param display_name: The name of the invoice section. + :type display_name: str + """ + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceSectionCreationRequest, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + + +class InvoiceSectionListResult(msrest.serialization.Model): + """The list of invoice sections. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of invoice sections. + :vartype value: list[~billing_management_client.models.InvoiceSection] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[InvoiceSection]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceSectionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class InvoiceSectionListWithCreateSubPermissionResult(msrest.serialization.Model): + """The list of invoice section properties with create subscription permission. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: The list of invoice section properties with create subscription permission. + :type value: list[~billing_management_client.models.InvoiceSectionWithCreateSubPermission] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[InvoiceSectionWithCreateSubPermission]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceSectionListWithCreateSubPermissionResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class InvoiceSectionsOnExpand(msrest.serialization.Model): + """The invoice sections associated to the billing profile. By default this is not populated, unless it's specified in $expand. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar has_more_results: Indicates whether there are more invoice sections than the ones listed + in this collection. The collection lists a maximum of 50 invoice sections. To get all invoice + sections, use the list invoice sections API. + :vartype has_more_results: bool + :param value: The invoice sections associated to the billing profile. + :type value: list[~billing_management_client.models.InvoiceSection] + """ + + _validation = { + 'has_more_results': {'readonly': True}, + } + + _attribute_map = { + 'has_more_results': {'key': 'hasMoreResults', 'type': 'bool'}, + 'value': {'key': 'value', 'type': '[InvoiceSection]'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceSectionsOnExpand, self).__init__(**kwargs) + self.has_more_results = None + self.value = kwargs.get('value', None) + + +class InvoiceSectionWithCreateSubPermission(msrest.serialization.Model): + """Invoice section properties with create subscription permission. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar invoice_section_id: The ID of the invoice section. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section. + :vartype invoice_section_display_name: str + :ivar invoice_section_system_id: The system generated unique identifier for an invoice section. + :vartype invoice_section_system_id: str + :ivar billing_profile_id: The ID of the billing profile for the invoice section. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile for the invoice section. + :vartype billing_profile_display_name: str + :ivar billing_profile_status: The status of the billing profile. Possible values include: + "Active", "Disabled", "Warned". + :vartype billing_profile_status: str or ~billing_management_client.models.BillingProfileStatus + :ivar billing_profile_status_reason_code: Reason for the specified billing profile status. + Possible values include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". + :vartype billing_profile_status_reason_code: str or + ~billing_management_client.models.StatusReasonCodeForBillingProfile + :ivar billing_profile_spending_limit: The billing profile spending limit. Possible values + include: "Off", "On". + :vartype billing_profile_spending_limit: str or + ~billing_management_client.models.SpendingLimitForBillingProfile + :ivar billing_profile_system_id: The system generated unique identifier for a billing profile. + :vartype billing_profile_system_id: str + :param enabled_azure_plans: Enabled azure plans for the associated billing profile. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + """ + + _validation = { + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'invoice_section_system_id': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'billing_profile_status': {'readonly': True}, + 'billing_profile_status_reason_code': {'readonly': True}, + 'billing_profile_spending_limit': {'readonly': True}, + 'billing_profile_system_id': {'readonly': True}, + } + + _attribute_map = { + 'invoice_section_id': {'key': 'invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'invoiceSectionDisplayName', 'type': 'str'}, + 'invoice_section_system_id': {'key': 'invoiceSectionSystemId', 'type': 'str'}, + 'billing_profile_id': {'key': 'billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'billingProfileDisplayName', 'type': 'str'}, + 'billing_profile_status': {'key': 'billingProfileStatus', 'type': 'str'}, + 'billing_profile_status_reason_code': {'key': 'billingProfileStatusReasonCode', 'type': 'str'}, + 'billing_profile_spending_limit': {'key': 'billingProfileSpendingLimit', 'type': 'str'}, + 'billing_profile_system_id': {'key': 'billingProfileSystemId', 'type': 'str'}, + 'enabled_azure_plans': {'key': 'enabledAzurePlans', 'type': '[AzurePlan]'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceSectionWithCreateSubPermission, self).__init__(**kwargs) + self.invoice_section_id = None + self.invoice_section_display_name = None + self.invoice_section_system_id = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.billing_profile_status = None + self.billing_profile_status_reason_code = None + self.billing_profile_spending_limit = None + self.billing_profile_system_id = None + self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) + + +class Operation(msrest.serialization.Model): + """A Billing REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :param display: The object that represents the operation. + :type display: ~billing_management_client.models.OperationDisplay + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.display = kwargs.get('display', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Service provider: Microsoft.Billing. + :vartype provider: str + :ivar resource: Resource on which the operation is performed such as invoice and billing + subscription. + :vartype resource: str + :ivar operation: Operation type such as read, write and delete. + :vartype operation: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + + +class OperationListResult(msrest.serialization.Model): + """The list of billing operations and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing operations supported by the Microsoft.Billing resource + provider. + :vartype value: list[~billing_management_client.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Participants(msrest.serialization.Model): + """The details about a participant. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The acceptance status of the participant. + :vartype status: str + :ivar status_date: The date when the status got changed. + :vartype status_date: ~datetime.datetime + :ivar email: The email address of the participant. + :vartype email: str + """ + + _validation = { + 'status': {'readonly': True}, + 'status_date': {'readonly': True}, + 'email': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'status_date': {'key': 'statusDate', 'type': 'iso-8601'}, + 'email': {'key': 'email', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Participants, self).__init__(**kwargs) + self.status = None + self.status_date = None + self.email = None + + +class PaymentProperties(msrest.serialization.Model): + """The properties of a payment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar payment_type: The type of payment. + :vartype payment_type: str + :ivar amount: The paid amount. + :vartype amount: ~billing_management_client.models.Amount + :ivar date: The date when the payment was made. + :vartype date: ~datetime.datetime + :param payment_method_family: The family of payment method. Possible values include: "Credits", + "CheckWire", "CreditCard", "None". + :type payment_method_family: str or ~billing_management_client.models.PaymentMethodFamily + :ivar payment_method_type: The type of payment method. + :vartype payment_method_type: str + """ + + _validation = { + 'payment_type': {'readonly': True}, + 'amount': {'readonly': True}, + 'date': {'readonly': True}, + 'payment_method_type': {'readonly': True}, + } + + _attribute_map = { + 'payment_type': {'key': 'paymentType', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'Amount'}, + 'date': {'key': 'date', 'type': 'iso-8601'}, + 'payment_method_family': {'key': 'paymentMethodFamily', 'type': 'str'}, + 'payment_method_type': {'key': 'paymentMethodType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PaymentProperties, self).__init__(**kwargs) + self.payment_type = None + self.amount = None + self.date = None + self.payment_method_family = kwargs.get('payment_method_family', None) + self.payment_method_type = None + + +class Policy(Resource): + """A policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param marketplace_purchases: The policy that controls whether Azure marketplace purchases are + allowed for a billing profile. Possible values include: "AllAllowed", "OnlyFreeAllowed", + "NotAllowed". + :type marketplace_purchases: str or + ~billing_management_client.models.MarketplacePurchasesPolicy + :param reservation_purchases: The policy that controls whether Azure reservation purchases are + allowed for a billing profile. Possible values include: "Allowed", "NotAllowed". + :type reservation_purchases: str or + ~billing_management_client.models.ReservationPurchasesPolicy + :param view_charges: The policy that controls whether users with Azure RBAC access to a + subscription can view its charges. Possible values include: "Allowed", "NotAllowed". + :type view_charges: str or ~billing_management_client.models.ViewChargesPolicy + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'marketplace_purchases': {'key': 'properties.marketplacePurchases', 'type': 'str'}, + 'reservation_purchases': {'key': 'properties.reservationPurchases', 'type': 'str'}, + 'view_charges': {'key': 'properties.viewCharges', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Policy, self).__init__(**kwargs) + self.marketplace_purchases = kwargs.get('marketplace_purchases', None) + self.reservation_purchases = kwargs.get('reservation_purchases', None) + self.view_charges = kwargs.get('view_charges', None) + + +class Product(Resource): + """A product. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param auto_renew: Indicates whether auto renewal is turned on or off for a product. Possible + values include: "Off", "On". + :type auto_renew: str or ~billing_management_client.models.AutoRenew + :ivar display_name: The display name of the product. + :vartype display_name: str + :ivar purchase_date: The date when the product was purchased. + :vartype purchase_date: ~datetime.datetime + :ivar product_type_id: The ID of the type of product. + :vartype product_type_id: str + :ivar product_type: The description of the type of product. + :vartype product_type: str + :param status: The current status of the product. Possible values include: "Active", + "Inactive", "PastDue", "Expiring", "Expired", "Disabled", "Cancelled", "AutoRenew". + :type status: str or ~billing_management_client.models.ProductStatusType + :ivar end_date: The date when the product will be renewed or canceled. + :vartype end_date: ~datetime.datetime + :param billing_frequency: The frequency at which the product will be billed. Possible values + include: "OneTime", "Monthly", "UsageBased". + :type billing_frequency: str or ~billing_management_client.models.BillingFrequency + :ivar last_charge: The last month charges. + :vartype last_charge: ~billing_management_client.models.Amount + :ivar last_charge_date: The date of the last charge. + :vartype last_charge_date: ~datetime.datetime + :ivar quantity: The quantity purchased for the product. + :vartype quantity: float + :ivar sku_id: The sku ID of the product. + :vartype sku_id: str + :ivar sku_description: The sku description of the product. + :vartype sku_description: str + :ivar tenant_id: The id of the tenant in which the product is used. + :vartype tenant_id: str + :ivar availability_id: The availability of the product. + :vartype availability_id: str + :ivar invoice_section_id: The ID of the invoice section to which the product is billed. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section to which the product is + billed. + :vartype invoice_section_display_name: str + :ivar billing_profile_id: The ID of the billing profile to which the product is billed. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile to which the product is + billed. + :vartype billing_profile_display_name: str + :ivar customer_id: The ID of the customer for whom the product was purchased. The field is + applicable only for Microsoft Partner Agreement billing account. + :vartype customer_id: str + :ivar customer_display_name: The name of the customer for whom the product was purchased. The + field is applicable only for Microsoft Partner Agreement billing account. + :vartype customer_display_name: str + :ivar reseller: Reseller for this product. + :vartype reseller: ~billing_management_client.models.Reseller + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'purchase_date': {'readonly': True}, + 'product_type_id': {'readonly': True}, + 'product_type': {'readonly': True}, + 'end_date': {'readonly': True}, + 'last_charge': {'readonly': True}, + 'last_charge_date': {'readonly': True}, + 'quantity': {'readonly': True}, + 'sku_id': {'readonly': True}, + 'sku_description': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'availability_id': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'customer_id': {'readonly': True}, + 'customer_display_name': {'readonly': True}, + 'reseller': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'auto_renew': {'key': 'properties.autoRenew', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'purchase_date': {'key': 'properties.purchaseDate', 'type': 'iso-8601'}, + 'product_type_id': {'key': 'properties.productTypeId', 'type': 'str'}, + 'product_type': {'key': 'properties.productType', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, + 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, + 'last_charge': {'key': 'properties.lastCharge', 'type': 'Amount'}, + 'last_charge_date': {'key': 'properties.lastChargeDate', 'type': 'iso-8601'}, + 'quantity': {'key': 'properties.quantity', 'type': 'float'}, + 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, + 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'availability_id': {'key': 'properties.availabilityId', 'type': 'str'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, + 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + } + + def __init__( + self, + **kwargs + ): + super(Product, self).__init__(**kwargs) + self.auto_renew = kwargs.get('auto_renew', None) + self.display_name = None + self.purchase_date = None + self.product_type_id = None + self.product_type = None + self.status = kwargs.get('status', None) + self.end_date = None + self.billing_frequency = kwargs.get('billing_frequency', None) + self.last_charge = None + self.last_charge_date = None + self.quantity = None + self.sku_id = None + self.sku_description = None + self.tenant_id = None + self.availability_id = None + self.invoice_section_id = None + self.invoice_section_display_name = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.customer_id = None + self.customer_display_name = None + self.reseller = None + + +class ProductsListResult(msrest.serialization.Model): + """The list of products. It contains a list of available product summaries in reverse chronological order by purchase date. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of products. + :vartype value: list[~billing_management_client.models.Product] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Product]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProductsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class RebillDetails(msrest.serialization.Model): + """The rebill details of an invoice. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar credit_note_document_id: The ID of credit note. + :vartype credit_note_document_id: str + :ivar invoice_document_id: The ID of invoice. + :vartype invoice_document_id: str + :ivar rebill_details: Rebill details for an invoice. + :vartype rebill_details: dict[str, ~billing_management_client.models.RebillDetails] + """ + + _validation = { + 'credit_note_document_id': {'readonly': True}, + 'invoice_document_id': {'readonly': True}, + 'rebill_details': {'readonly': True}, + } + + _attribute_map = { + 'credit_note_document_id': {'key': 'creditNoteDocumentId', 'type': 'str'}, + 'invoice_document_id': {'key': 'invoiceDocumentId', 'type': 'str'}, + 'rebill_details': {'key': 'rebillDetails', 'type': '{RebillDetails}'}, + } + + def __init__( + self, + **kwargs + ): + super(RebillDetails, self).__init__(**kwargs) + self.credit_note_document_id = None + self.invoice_document_id = None + self.rebill_details = None + + +class Reseller(msrest.serialization.Model): + """Details of the reseller. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar reseller_id: The MPN ID of the reseller. + :vartype reseller_id: str + :ivar description: The name of the reseller. + :vartype description: str + """ + + _validation = { + 'reseller_id': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Reseller, self).__init__(**kwargs) + self.reseller_id = None + self.description = None + + +class Transaction(Resource): + """A transaction. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param kind: The kind of transaction. Options are all or reservation. Possible values include: + "all", "reservation". + :type kind: str or ~billing_management_client.models.TransactionTypeKind + :ivar date: The date of transaction. + :vartype date: ~datetime.datetime + :ivar invoice: Invoice on which the transaction was billed or 'pending' if the transaction is + not billed. + :vartype invoice: str + :ivar invoice_id: The ID of the invoice on which the transaction was billed. This field is only + applicable for transactions which are billed. + :vartype invoice_id: str + :ivar order_id: The order ID of the reservation. The field is only applicable for transaction + of kind reservation. + :vartype order_id: str + :ivar order_name: The name of the reservation order. The field is only applicable for + transactions of kind reservation. + :vartype order_name: str + :ivar product_family: The family of the product for which the transaction took place. + :vartype product_family: str + :ivar product_type_id: The ID of the product type for which the transaction took place. + :vartype product_type_id: str + :ivar product_type: The type of the product for which the transaction took place. + :vartype product_type: str + :ivar product_description: The description of the product for which the transaction took place. + :vartype product_description: str + :param transaction_type: The type of transaction. Possible values include: "Purchase", "Usage + Charge". + :type transaction_type: str or ~billing_management_client.models.ReservationType + :ivar transaction_amount: The charge associated with the transaction. + :vartype transaction_amount: ~billing_management_client.models.Amount + :ivar quantity: The quantity purchased in the transaction. + :vartype quantity: int + :ivar invoice_section_id: The ID of the invoice section which will be billed for the + transaction. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section which will be billed for + the transaction. + :vartype invoice_section_display_name: str + :ivar billing_profile_id: The ID of the billing profile which will be billed for the + transaction. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile which will be billed for + the transaction. + :vartype billing_profile_display_name: str + :ivar customer_id: The ID of the customer for which the transaction took place. The field is + applicable only for Microsoft Partner Agreement billing account. + :vartype customer_id: str + :ivar customer_display_name: The name of the customer for which the transaction took place. The + field is applicable only for Microsoft Partner Agreement billing account. + :vartype customer_display_name: str + :ivar subscription_id: The ID of the subscription that was used for the transaction. The field + is only applicable for transaction of kind reservation. + :vartype subscription_id: str + :ivar subscription_name: The name of the subscription that was used for the transaction. The + field is only applicable for transaction of kind reservation. + :vartype subscription_name: str + :ivar azure_plan: The type of azure plan of the subscription that was used for the transaction. + :vartype azure_plan: str + :ivar azure_credit_applied: The amount of any Azure credits automatically applied to this + transaction. + :vartype azure_credit_applied: ~billing_management_client.models.Amount + :ivar billing_currency: The ISO 4217 code for the currency in which this transaction is billed. + :vartype billing_currency: str + :ivar discount: The percentage discount, if any, applied to this transaction. + :vartype discount: float + :ivar effective_price: The price of the product after applying any discounts. + :vartype effective_price: ~billing_management_client.models.Amount + :ivar exchange_rate: The exchange rate used to convert charged amount to billing currency, if + applicable. + :vartype exchange_rate: float + :ivar market_price: The retail price of the product. + :vartype market_price: ~billing_management_client.models.Amount + :ivar pricing_currency: The ISO 4217 code for the currency in which the product is priced. + :vartype pricing_currency: str + :ivar service_period_start_date: The date of the purchase of the product, or the start date of + the month in which usage started. + :vartype service_period_start_date: ~datetime.datetime + :ivar service_period_end_date: The end date of the product term, or the end date of the month + in which usage ended. + :vartype service_period_end_date: ~datetime.datetime + :ivar sub_total: The pre-tax charged amount for the transaction. + :vartype sub_total: ~billing_management_client.models.Amount + :ivar tax: The tax amount applied to the transaction. + :vartype tax: ~billing_management_client.models.Amount + :ivar unit_of_measure: The unit of measure used to bill for the product. For example, compute + services are billed per hour. + :vartype unit_of_measure: str + :ivar units: The number of units used for a given product. + :vartype units: float + :ivar unit_type: The description for the unit of measure for a given product. + :vartype unit_type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'date': {'readonly': True}, + 'invoice': {'readonly': True}, + 'invoice_id': {'readonly': True}, + 'order_id': {'readonly': True}, + 'order_name': {'readonly': True}, + 'product_family': {'readonly': True}, + 'product_type_id': {'readonly': True}, + 'product_type': {'readonly': True}, + 'product_description': {'readonly': True}, + 'transaction_amount': {'readonly': True}, + 'quantity': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'customer_id': {'readonly': True}, + 'customer_display_name': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'subscription_name': {'readonly': True}, + 'azure_plan': {'readonly': True}, + 'azure_credit_applied': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'discount': {'readonly': True}, + 'effective_price': {'readonly': True}, + 'exchange_rate': {'readonly': True}, + 'market_price': {'readonly': True}, + 'pricing_currency': {'readonly': True}, + 'service_period_start_date': {'readonly': True}, + 'service_period_end_date': {'readonly': True}, + 'sub_total': {'readonly': True}, + 'tax': {'readonly': True}, + 'unit_of_measure': {'readonly': True}, + 'units': {'readonly': True}, + 'unit_type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'properties.kind', 'type': 'str'}, + 'date': {'key': 'properties.date', 'type': 'iso-8601'}, + 'invoice': {'key': 'properties.invoice', 'type': 'str'}, + 'invoice_id': {'key': 'properties.invoiceId', 'type': 'str'}, + 'order_id': {'key': 'properties.orderId', 'type': 'str'}, + 'order_name': {'key': 'properties.orderName', 'type': 'str'}, + 'product_family': {'key': 'properties.productFamily', 'type': 'str'}, + 'product_type_id': {'key': 'properties.productTypeId', 'type': 'str'}, + 'product_type': {'key': 'properties.productType', 'type': 'str'}, + 'product_description': {'key': 'properties.productDescription', 'type': 'str'}, + 'transaction_type': {'key': 'properties.transactionType', 'type': 'str'}, + 'transaction_amount': {'key': 'properties.transactionAmount', 'type': 'Amount'}, + 'quantity': {'key': 'properties.quantity', 'type': 'int'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, + 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + 'subscription_name': {'key': 'properties.subscriptionName', 'type': 'str'}, + 'azure_plan': {'key': 'properties.azurePlan', 'type': 'str'}, + 'azure_credit_applied': {'key': 'properties.azureCreditApplied', 'type': 'Amount'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'discount': {'key': 'properties.discount', 'type': 'float'}, + 'effective_price': {'key': 'properties.effectivePrice', 'type': 'Amount'}, + 'exchange_rate': {'key': 'properties.exchangeRate', 'type': 'float'}, + 'market_price': {'key': 'properties.marketPrice', 'type': 'Amount'}, + 'pricing_currency': {'key': 'properties.pricingCurrency', 'type': 'str'}, + 'service_period_start_date': {'key': 'properties.servicePeriodStartDate', 'type': 'iso-8601'}, + 'service_period_end_date': {'key': 'properties.servicePeriodEndDate', 'type': 'iso-8601'}, + 'sub_total': {'key': 'properties.subTotal', 'type': 'Amount'}, + 'tax': {'key': 'properties.tax', 'type': 'Amount'}, + 'unit_of_measure': {'key': 'properties.unitOfMeasure', 'type': 'str'}, + 'units': {'key': 'properties.units', 'type': 'float'}, + 'unit_type': {'key': 'properties.unitType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Transaction, self).__init__(**kwargs) + self.kind = kwargs.get('kind', None) + self.date = None + self.invoice = None + self.invoice_id = None + self.order_id = None + self.order_name = None + self.product_family = None + self.product_type_id = None + self.product_type = None + self.product_description = None + self.transaction_type = kwargs.get('transaction_type', None) + self.transaction_amount = None + self.quantity = None + self.invoice_section_id = None + self.invoice_section_display_name = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.customer_id = None + self.customer_display_name = None + self.subscription_id = None + self.subscription_name = None + self.azure_plan = None + self.azure_credit_applied = None + self.billing_currency = None + self.discount = None + self.effective_price = None + self.exchange_rate = None + self.market_price = None + self.pricing_currency = None + self.service_period_start_date = None + self.service_period_end_date = None + self.sub_total = None + self.tax = None + self.unit_of_measure = None + self.units = None + self.unit_type = None + + +class TransactionListResult(msrest.serialization.Model): + """The list of transactions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of transactions. + :vartype value: list[~billing_management_client.models.Transaction] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Transaction]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TransactionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class TransferBillingSubscriptionRequestProperties(msrest.serialization.Model): + """Request parameters to transfer billing subscription. + + All required parameters must be populated in order to send to Azure. + + :param destination_invoice_section_id: Required. The destination invoice section id. + :type destination_invoice_section_id: str + """ + + _validation = { + 'destination_invoice_section_id': {'required': True}, + } + + _attribute_map = { + 'destination_invoice_section_id': {'key': 'destinationInvoiceSectionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TransferBillingSubscriptionRequestProperties, self).__init__(**kwargs) + self.destination_invoice_section_id = kwargs['destination_invoice_section_id'] + + +class TransferProductRequestProperties(msrest.serialization.Model): + """The properties of the product to initiate a transfer. + + :param destination_invoice_section_id: The 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(TransferProductRequestProperties, self).__init__(**kwargs) + self.destination_invoice_section_id = kwargs.get('destination_invoice_section_id', None) + + +class ValidateAddressResponse(msrest.serialization.Model): + """Result of the address validation. + + :param status: status of the address validation. Possible values include: "Valid", "Invalid". + :type status: str or ~billing_management_client.models.AddressValidationStatus + :param suggested_addresses: The list of suggested addresses. + :type suggested_addresses: list[~billing_management_client.models.AddressDetails] + :param validation_message: Validation error message. + :type validation_message: str + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'suggested_addresses': {'key': 'suggestedAddresses', 'type': '[AddressDetails]'}, + 'validation_message': {'key': 'validationMessage', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ValidateAddressResponse, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.suggested_addresses = kwargs.get('suggested_addresses', None) + self.validation_message = kwargs.get('validation_message', None) + + +class ValidateProductTransferEligibilityError(msrest.serialization.Model): + """Error details of the product transfer eligibility validation. + + :param code: Error code for the product transfer validation. Possible values include: + "InvalidSource", "ProductNotActive", "InsufficientPermissionOnSource", + "InsufficientPermissionOnDestination", "DestinationBillingProfilePastDue", + "ProductTypeNotSupported", "CrossBillingAccountNotAllowed", "NotAvailableForDestinationMarket", + "OneTimePurchaseProductTransferNotAllowed". + :type code: str or ~billing_management_client.models.ProductTransferValidationErrorCode + :param message: The error message. + :type message: str + :param details: Detailed error message explaining the error. + :type details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ValidateProductTransferEligibilityError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.details = kwargs.get('details', None) + + +class ValidateProductTransferEligibilityResult(msrest.serialization.Model): + """Result of the product transfer eligibility validation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar is_move_eligible: Specifies whether the transfer is eligible or not. + :vartype is_move_eligible: bool + :param error_details: Validation error details. + :type error_details: ~billing_management_client.models.ValidateProductTransferEligibilityError + """ + + _validation = { + 'is_move_eligible': {'readonly': True}, + } + + _attribute_map = { + 'is_move_eligible': {'key': 'isMoveEligible', 'type': 'bool'}, + 'error_details': {'key': 'errorDetails', 'type': 'ValidateProductTransferEligibilityError'}, + } + + def __init__( + self, + **kwargs + ): + super(ValidateProductTransferEligibilityResult, self).__init__(**kwargs) + self.is_move_eligible = None + self.error_details = kwargs.get('error_details', None) + + +class ValidateSubscriptionTransferEligibilityError(msrest.serialization.Model): + """Error details of the transfer eligibility validation. + + :param code: Error code for the product transfer validation. Possible values include: + "BillingAccountInactive", "CrossBillingAccountNotAllowed", "DestinationBillingProfileInactive", + "DestinationBillingProfileNotFound", "DestinationBillingProfilePastDue", + "DestinationInvoiceSectionInactive", "DestinationInvoiceSectionNotFound", + "InsufficientPermissionOnDestination", "InsufficientPermissionOnSource", "InvalidDestination", + "InvalidSource", "MarketplaceNotEnabledOnDestination", "NotAvailableForDestinationMarket", + "ProductInactive", "ProductNotFound", "ProductTypeNotSupported", "SourceBillingProfilePastDue", + "SourceInvoiceSectionInactive", "SubscriptionNotActive", "SubscriptionTypeNotSupported". + :type code: str or ~billing_management_client.models.SubscriptionTransferValidationErrorCode + :param message: The error message. + :type message: str + :param details: Detailed error message explaining the error. + :type details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ValidateSubscriptionTransferEligibilityError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.details = kwargs.get('details', None) + + +class ValidateSubscriptionTransferEligibilityResult(msrest.serialization.Model): + """Result of the transfer eligibility validation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar is_move_eligible: Specifies whether the subscription is eligible to be transferred. + :vartype is_move_eligible: bool + :param error_details: Validation error details. + :type error_details: + ~billing_management_client.models.ValidateSubscriptionTransferEligibilityError + """ + + _validation = { + 'is_move_eligible': {'readonly': True}, + } + + _attribute_map = { + 'is_move_eligible': {'key': 'isMoveEligible', 'type': 'bool'}, + 'error_details': {'key': 'errorDetails', 'type': 'ValidateSubscriptionTransferEligibilityError'}, + } + + def __init__( + self, + **kwargs + ): + super(ValidateSubscriptionTransferEligibilityResult, self).__init__(**kwargs) + self.is_move_eligible = None + self.error_details = kwargs.get('error_details', None) diff --git a/src/billing/azext_billing/vendored_sdks/billing/models/_models_py3.py b/src/billing/azext_billing/vendored_sdks/billing/models/_models_py3.py new file mode 100644 index 00000000000..169efb013b9 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/models/_models_py3.py @@ -0,0 +1,3521 @@ +# 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 datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._billing_management_client_enums import * + + +class AddressDetails(msrest.serialization.Model): + """Address details. + + All required parameters must be populated in order to send to Azure. + + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + :param company_name: Company name. + :type company_name: str + :param address_line1: Required. Address line 1. + :type address_line1: str + :param address_line2: Address line 2. + :type address_line2: str + :param address_line3: Address line 3. + :type address_line3: str + :param city: Address city. + :type city: str + :param district: Address district. + :type district: str + :param region: Address region. + :type region: str + :param country: Required. Country code uses ISO2, 2-digit format. + :type country: str + :param postal_code: Postal code. + :type postal_code: str + :param email: Email address. + :type email: str + :param phone_number: Phone number. + :type phone_number: str + """ + + _validation = { + 'address_line1': {'required': True}, + 'country': {'required': True}, + } + + _attribute_map = { + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'company_name': {'key': 'companyName', 'type': 'str'}, + 'address_line1': {'key': 'addressLine1', 'type': 'str'}, + 'address_line2': {'key': 'addressLine2', 'type': 'str'}, + 'address_line3': {'key': 'addressLine3', 'type': 'str'}, + 'city': {'key': 'city', 'type': 'str'}, + 'district': {'key': 'district', 'type': 'str'}, + 'region': {'key': 'region', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'postal_code': {'key': 'postalCode', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + *, + address_line1: str, + country: str, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + company_name: Optional[str] = None, + address_line2: Optional[str] = None, + address_line3: Optional[str] = None, + city: Optional[str] = None, + district: Optional[str] = None, + region: Optional[str] = None, + postal_code: Optional[str] = None, + email: Optional[str] = None, + phone_number: Optional[str] = None, + **kwargs + ): + super(AddressDetails, self).__init__(**kwargs) + self.first_name = first_name + self.last_name = last_name + self.company_name = company_name + self.address_line1 = address_line1 + self.address_line2 = address_line2 + self.address_line3 = address_line3 + self.city = city + self.district = district + self.region = region + self.country = country + self.postal_code = postal_code + self.email = email + self.phone_number = phone_number + + +class Resource(msrest.serialization.Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Agreement(Resource): + """An agreement. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar agreement_link: The URL to download the agreement. + :vartype agreement_link: str + :ivar category: The category of the agreement signed by a customer. Possible values include: + "MicrosoftCustomerAgreement", "AffiliatePurchaseTerms", "Other". + :vartype category: str or ~billing_management_client.models.Category + :ivar acceptance_mode: The mode of acceptance for an agreement. Possible values include: + "ClickToAccept", "ESignEmbedded", "ESignOffline". + :vartype acceptance_mode: str or ~billing_management_client.models.AcceptanceMode + :ivar effective_date: The date from which the agreement is effective. + :vartype effective_date: ~datetime.datetime + :ivar expiration_date: The date when the agreement expires. + :vartype expiration_date: ~datetime.datetime + :param participants: The list of participants that participates in acceptance of an agreement. + :type participants: list[~billing_management_client.models.Participants] + :ivar status: The current status of the agreement. + :vartype status: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'agreement_link': {'readonly': True}, + 'category': {'readonly': True}, + 'acceptance_mode': {'readonly': True}, + 'effective_date': {'readonly': True}, + 'expiration_date': {'readonly': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'agreement_link': {'key': 'properties.agreementLink', 'type': 'str'}, + 'category': {'key': 'properties.category', 'type': 'str'}, + 'acceptance_mode': {'key': 'properties.acceptanceMode', 'type': 'str'}, + 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, + 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, + 'participants': {'key': 'properties.participants', 'type': '[Participants]'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__( + self, + *, + participants: Optional[List["Participants"]] = None, + **kwargs + ): + super(Agreement, self).__init__(**kwargs) + self.agreement_link = None + self.category = None + self.acceptance_mode = None + self.effective_date = None + self.expiration_date = None + self.participants = participants + self.status = None + + +class AgreementListResult(msrest.serialization.Model): + """Result of listing agreements. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of agreements. + :vartype value: list[~billing_management_client.models.Agreement] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Agreement]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AgreementListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Amount(msrest.serialization.Model): + """The amount. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar currency: The currency for the amount value. + :vartype currency: str + :param value: Amount value. + :type value: float + """ + + _validation = { + 'currency': {'readonly': True}, + } + + _attribute_map = { + 'currency': {'key': 'currency', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__( + self, + *, + value: Optional[float] = None, + **kwargs + ): + super(Amount, self).__init__(**kwargs) + self.currency = None + self.value = value + + +class AvailableBalance(Resource): + """The latest Azure credit balance. This is the balance available for pay now. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar amount: Balance amount. + :vartype amount: ~billing_management_client.models.Amount + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'amount': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'amount': {'key': 'properties.amount', 'type': 'Amount'}, + } + + def __init__( + self, + **kwargs + ): + super(AvailableBalance, self).__init__(**kwargs) + self.amount = None + + +class AzurePlan(msrest.serialization.Model): + """Details of the Azure plan. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param sku_id: The sku id. + :type sku_id: str + :ivar sku_description: The sku description. + :vartype sku_description: str + """ + + _validation = { + 'sku_description': {'readonly': True}, + } + + _attribute_map = { + 'sku_id': {'key': 'skuId', 'type': 'str'}, + 'sku_description': {'key': 'skuDescription', 'type': 'str'}, + } + + def __init__( + self, + *, + sku_id: Optional[str] = None, + **kwargs + ): + super(AzurePlan, self).__init__(**kwargs) + self.sku_id = sku_id + self.sku_description = None + + +class BillingAccount(Resource): + """A billing account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param display_name: The billing account name. + :type display_name: str + :param sold_to: The address of the individual or organization that is responsible for the + billing account. + :type sold_to: ~billing_management_client.models.AddressDetails + :ivar agreement_type: The type of agreement. Possible values include: + "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", + "MicrosoftPartnerAgreement". + :vartype agreement_type: str or ~billing_management_client.models.AgreementType + :ivar account_type: The type of customer. Possible values include: "Enterprise", "Individual", + "Partner". + :vartype account_type: str or ~billing_management_client.models.AccountType + :ivar account_status: The current status of the billing account. Possible values include: + "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". + :vartype account_status: str or ~billing_management_client.models.AccountStatus + :param billing_profiles: The billing profiles associated with the billing account. By default + this is not populated, unless it's specified in $expand. + :type billing_profiles: ~billing_management_client.models.BillingProfilesOnExpand + :ivar enrollment_details: The details about the associated legacy enrollment. By default this + is not populated, unless it's specified in $expand. + :vartype enrollment_details: ~billing_management_client.models.Enrollment + :param departments: The departments associated to the enrollment. + :type departments: list[~billing_management_client.models.Department] + :param enrollment_accounts: The accounts associated to the enrollment. + :type enrollment_accounts: list[~billing_management_client.models.EnrollmentAccount] + :ivar has_read_access: Indicates whether user has read access to the billing account. + :vartype has_read_access: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'agreement_type': {'readonly': True}, + 'account_type': {'readonly': True}, + 'account_status': {'readonly': True}, + 'enrollment_details': {'readonly': True}, + 'has_read_access': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'sold_to': {'key': 'properties.soldTo', 'type': 'AddressDetails'}, + 'agreement_type': {'key': 'properties.agreementType', 'type': 'str'}, + 'account_type': {'key': 'properties.accountType', 'type': 'str'}, + 'account_status': {'key': 'properties.accountStatus', 'type': 'str'}, + 'billing_profiles': {'key': 'properties.billingProfiles', 'type': 'BillingProfilesOnExpand'}, + 'enrollment_details': {'key': 'properties.enrollmentDetails', 'type': 'Enrollment'}, + 'departments': {'key': 'properties.departments', 'type': '[Department]'}, + 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, + 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + sold_to: Optional["AddressDetails"] = None, + billing_profiles: Optional["BillingProfilesOnExpand"] = None, + departments: Optional[List["Department"]] = None, + enrollment_accounts: Optional[List["EnrollmentAccount"]] = None, + **kwargs + ): + super(BillingAccount, self).__init__(**kwargs) + self.display_name = display_name + self.sold_to = sold_to + self.agreement_type = None + self.account_type = None + self.account_status = None + self.billing_profiles = billing_profiles + self.enrollment_details = None + self.departments = departments + self.enrollment_accounts = enrollment_accounts + self.has_read_access = None + + +class BillingAccountListResult(msrest.serialization.Model): + """The list of billing accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing accounts. + :vartype value: list[~billing_management_client.models.BillingAccount] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingAccount]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingAccountListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingAccountUpdateRequest(msrest.serialization.Model): + """The request properties of the billing account that can be updated. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param display_name: The billing account name. + :type display_name: str + :param sold_to: The address of the individual or organization that is responsible for the + billing account. + :type sold_to: ~billing_management_client.models.AddressDetails + :ivar agreement_type: The type of agreement. Possible values include: + "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", + "MicrosoftPartnerAgreement". + :vartype agreement_type: str or ~billing_management_client.models.AgreementType + :ivar account_type: The type of customer. Possible values include: "Enterprise", "Individual", + "Partner". + :vartype account_type: str or ~billing_management_client.models.AccountType + :ivar account_status: The current status of the billing account. Possible values include: + "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". + :vartype account_status: str or ~billing_management_client.models.AccountStatus + :param billing_profiles: The billing profiles associated with the billing account. By default + this is not populated, unless it's specified in $expand. + :type billing_profiles: ~billing_management_client.models.BillingProfilesOnExpand + :ivar enrollment_details: The details about the associated legacy enrollment. By default this + is not populated, unless it's specified in $expand. + :vartype enrollment_details: ~billing_management_client.models.Enrollment + :param departments: The departments associated to the enrollment. + :type departments: list[~billing_management_client.models.Department] + :param enrollment_accounts: The accounts associated to the enrollment. + :type enrollment_accounts: list[~billing_management_client.models.EnrollmentAccount] + :ivar has_read_access: Indicates whether user has read access to the billing account. + :vartype has_read_access: bool + """ + + _validation = { + 'agreement_type': {'readonly': True}, + 'account_type': {'readonly': True}, + 'account_status': {'readonly': True}, + 'enrollment_details': {'readonly': True}, + 'has_read_access': {'readonly': True}, + } + + _attribute_map = { + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'sold_to': {'key': 'properties.soldTo', 'type': 'AddressDetails'}, + 'agreement_type': {'key': 'properties.agreementType', 'type': 'str'}, + 'account_type': {'key': 'properties.accountType', 'type': 'str'}, + 'account_status': {'key': 'properties.accountStatus', 'type': 'str'}, + 'billing_profiles': {'key': 'properties.billingProfiles', 'type': 'BillingProfilesOnExpand'}, + 'enrollment_details': {'key': 'properties.enrollmentDetails', 'type': 'Enrollment'}, + 'departments': {'key': 'properties.departments', 'type': '[Department]'}, + 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, + 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + sold_to: Optional["AddressDetails"] = None, + billing_profiles: Optional["BillingProfilesOnExpand"] = None, + departments: Optional[List["Department"]] = None, + enrollment_accounts: Optional[List["EnrollmentAccount"]] = None, + **kwargs + ): + super(BillingAccountUpdateRequest, self).__init__(**kwargs) + self.display_name = display_name + self.sold_to = sold_to + self.agreement_type = None + self.account_type = None + self.account_status = None + self.billing_profiles = billing_profiles + self.enrollment_details = None + self.departments = departments + self.enrollment_accounts = enrollment_accounts + self.has_read_access = None + + +class BillingPeriod(Resource): + """A billing period resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar billing_period_start_date: The start of the date range covered by the billing period. + :vartype billing_period_start_date: ~datetime.date + :ivar billing_period_end_date: The end of the date range covered by the billing period. + :vartype billing_period_end_date: ~datetime.date + :ivar invoice_ids: Array of invoice ids that associated with. + :vartype invoice_ids: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'billing_period_start_date': {'readonly': True}, + 'billing_period_end_date': {'readonly': True}, + 'invoice_ids': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'billing_period_start_date': {'key': 'properties.billingPeriodStartDate', 'type': 'date'}, + 'billing_period_end_date': {'key': 'properties.billingPeriodEndDate', 'type': 'date'}, + 'invoice_ids': {'key': 'properties.invoiceIds', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPeriod, self).__init__(**kwargs) + self.billing_period_start_date = None + self.billing_period_end_date = None + self.invoice_ids = None + + +class BillingPeriodsListResult(msrest.serialization.Model): + """Result of listing billing periods. It contains a list of available billing periods in reverse chronological order. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing periods. + :vartype value: list[~billing_management_client.models.BillingPeriod] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingPeriod]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPeriodsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingPermissionsListResult(msrest.serialization.Model): + """Result of list billingPermissions a caller has on a billing account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billingPermissions a caller has on a billing account. + :vartype value: list[~billing_management_client.models.BillingPermissionsProperties] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingPermissionsProperties]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPermissionsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingPermissionsProperties(msrest.serialization.Model): + """The set of allowed action and not allowed actions a caller has on a billing account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar actions: The set of actions that the caller is allowed to perform. + :vartype actions: list[str] + :ivar not_actions: The set of actions that the caller is not allowed to perform. + :vartype not_actions: list[str] + """ + + _validation = { + 'actions': {'readonly': True}, + 'not_actions': {'readonly': True}, + } + + _attribute_map = { + 'actions': {'key': 'actions', 'type': '[str]'}, + 'not_actions': {'key': 'notActions', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingPermissionsProperties, self).__init__(**kwargs) + self.actions = None + self.not_actions = None + + +class BillingProfile(Resource): + """A billing profile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param display_name: The name of the billing profile. + :type display_name: str + :param po_number: The purchase order name that will appear on the invoices generated for the + billing profile. + :type po_number: str + :ivar billing_relationship_type: Identifies which services and purchases are paid by a billing + profile. Possible values include: "Direct", "IndirectCustomer", "IndirectPartner", + "CSPPartner". + :vartype billing_relationship_type: str or + ~billing_management_client.models.BillingRelationshipType + :param bill_to: Billing address. + :type bill_to: ~billing_management_client.models.AddressDetails + :ivar indirect_relationship_info: Identifies the billing profile that is linked to another + billing profile in indirect purchase motion. + :vartype indirect_relationship_info: ~billing_management_client.models.IndirectRelationshipInfo + :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are + sent through email. + :type invoice_email_opt_in: bool + :ivar invoice_day: The day of the month when the invoice for the billing profile is generated. + :vartype invoice_day: int + :ivar currency: The currency in which the charges for the billing profile are billed. + :vartype currency: str + :param enabled_azure_plans: Information about the enabled azure plans. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + :param invoice_sections: The invoice sections associated to the billing profile. By default + this is not populated, unless it's specified in $expand. + :type invoice_sections: ~billing_management_client.models.InvoiceSectionsOnExpand + :ivar has_read_access: Indicates whether user has read access to the billing profile. + :vartype has_read_access: bool + :ivar system_id: The system generated unique identifier for a billing profile. + :vartype system_id: str + :ivar status: The status of the billing profile. Possible values include: "Active", "Disabled", + "Warned". + :vartype status: str or ~billing_management_client.models.BillingProfileStatus + :ivar status_reason_code: Reason for the specified billing profile status. Possible values + include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". + :vartype status_reason_code: str or ~billing_management_client.models.StatusReasonCode + :ivar spending_limit: The billing profile spending limit. Possible values include: "Off", "On". + :vartype spending_limit: str or ~billing_management_client.models.SpendingLimit + :ivar target_clouds: Identifies the cloud environments that are associated with a billing + profile. This is a system managed optional field and gets updated as the billing profile gets + associated with accounts in various clouds. + :vartype target_clouds: list[str or ~billing_management_client.models.TargetCloud] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'billing_relationship_type': {'readonly': True}, + 'indirect_relationship_info': {'readonly': True}, + 'invoice_day': {'readonly': True}, + 'currency': {'readonly': True}, + 'has_read_access': {'readonly': True}, + 'system_id': {'readonly': True}, + 'status': {'readonly': True}, + 'status_reason_code': {'readonly': True}, + 'spending_limit': {'readonly': True}, + 'target_clouds': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'po_number': {'key': 'properties.poNumber', 'type': 'str'}, + 'billing_relationship_type': {'key': 'properties.billingRelationshipType', 'type': 'str'}, + 'bill_to': {'key': 'properties.billTo', 'type': 'AddressDetails'}, + 'indirect_relationship_info': {'key': 'properties.indirectRelationshipInfo', 'type': 'IndirectRelationshipInfo'}, + 'invoice_email_opt_in': {'key': 'properties.invoiceEmailOptIn', 'type': 'bool'}, + 'invoice_day': {'key': 'properties.invoiceDay', 'type': 'int'}, + 'currency': {'key': 'properties.currency', 'type': 'str'}, + 'enabled_azure_plans': {'key': 'properties.enabledAzurePlans', 'type': '[AzurePlan]'}, + 'invoice_sections': {'key': 'properties.invoiceSections', 'type': 'InvoiceSectionsOnExpand'}, + 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, + 'system_id': {'key': 'properties.systemId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'status_reason_code': {'key': 'properties.statusReasonCode', 'type': 'str'}, + 'spending_limit': {'key': 'properties.spendingLimit', 'type': 'str'}, + 'target_clouds': {'key': 'properties.targetClouds', 'type': '[str]'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + po_number: Optional[str] = None, + bill_to: Optional["AddressDetails"] = None, + invoice_email_opt_in: Optional[bool] = None, + enabled_azure_plans: Optional[List["AzurePlan"]] = None, + invoice_sections: Optional["InvoiceSectionsOnExpand"] = None, + **kwargs + ): + super(BillingProfile, self).__init__(**kwargs) + self.display_name = display_name + self.po_number = po_number + self.billing_relationship_type = None + self.bill_to = bill_to + self.indirect_relationship_info = None + self.invoice_email_opt_in = invoice_email_opt_in + self.invoice_day = None + self.currency = None + self.enabled_azure_plans = enabled_azure_plans + self.invoice_sections = invoice_sections + self.has_read_access = None + self.system_id = None + self.status = None + self.status_reason_code = None + self.spending_limit = None + self.target_clouds = None + + +class BillingProfileCreationRequest(msrest.serialization.Model): + """The request parameters for creating a new billing profile. + + :param display_name: The name of the billing profile. + :type display_name: str + :param po_number: The purchase order name that will appear on the invoices generated for the + billing profile. + :type po_number: str + :param bill_to: The address of the individual or organization that is responsible for the + billing profile. + :type bill_to: ~billing_management_client.models.AddressDetails + :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are + sent through email. + :type invoice_email_opt_in: bool + :param enabled_azure_plans: Enabled azure plans for the billing profile. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + """ + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'po_number': {'key': 'poNumber', 'type': 'str'}, + 'bill_to': {'key': 'billTo', 'type': 'AddressDetails'}, + 'invoice_email_opt_in': {'key': 'invoiceEmailOptIn', 'type': 'bool'}, + 'enabled_azure_plans': {'key': 'enabledAzurePlans', 'type': '[AzurePlan]'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + po_number: Optional[str] = None, + bill_to: Optional["AddressDetails"] = None, + invoice_email_opt_in: Optional[bool] = None, + enabled_azure_plans: Optional[List["AzurePlan"]] = None, + **kwargs + ): + super(BillingProfileCreationRequest, self).__init__(**kwargs) + self.display_name = display_name + self.po_number = po_number + self.bill_to = bill_to + self.invoice_email_opt_in = invoice_email_opt_in + self.enabled_azure_plans = enabled_azure_plans + + +class BillingProfileListResult(msrest.serialization.Model): + """The list of billing profiles. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing profiles. + :vartype value: list[~billing_management_client.models.BillingProfile] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingProfile]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingProfileListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingProfilesOnExpand(msrest.serialization.Model): + """The billing profiles associated with the billing account. By default this is not populated, unless it's specified in $expand. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar has_more_results: Indicates whether there are more billing profiles than the ones listed + in this collection. The collection lists a maximum of 50 billing profiles. To get all billing + profiles, use the list billing profiles API. + :vartype has_more_results: bool + :param value: The billing profiles associated with the billing account. + :type value: list[~billing_management_client.models.BillingProfile] + """ + + _validation = { + 'has_more_results': {'readonly': True}, + } + + _attribute_map = { + 'has_more_results': {'key': 'hasMoreResults', 'type': 'bool'}, + 'value': {'key': 'value', 'type': '[BillingProfile]'}, + } + + def __init__( + self, + *, + value: Optional[List["BillingProfile"]] = None, + **kwargs + ): + super(BillingProfilesOnExpand, self).__init__(**kwargs) + self.has_more_results = None + self.value = value + + +class BillingProperty(Resource): + """A billing property. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar account_admin_notification_email_address: The email address on which the account admin + gets all Azure notifications. + :vartype account_admin_notification_email_address: str + :ivar billing_tenant_id: The Azure AD tenant ID of the billing account for the subscription. + :vartype billing_tenant_id: str + :ivar billing_account_id: The ID of the billing account to which the subscription is billed. + :vartype billing_account_id: str + :ivar billing_account_display_name: The name of the billing account to which the subscription + is billed. + :vartype billing_account_display_name: str + :ivar billing_profile_id: The ID of the billing profile to which the subscription is billed. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile to which the subscription + is billed. + :vartype billing_profile_display_name: str + :ivar billing_profile_status: The status of the billing profile. Possible values include: + "Active", "Disabled", "Warned". + :vartype billing_profile_status: str or ~billing_management_client.models.BillingProfileStatus + :ivar billing_profile_status_reason_code: Reason for the specified billing profile status. + Possible values include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". + :vartype billing_profile_status_reason_code: str or + ~billing_management_client.models.BillingProfileStatusReasonCode + :ivar billing_profile_spending_limit: The billing profile spending limit. Possible values + include: "Off", "On". + :vartype billing_profile_spending_limit: str or + ~billing_management_client.models.BillingProfileSpendingLimit + :param cost_center: The cost center applied to the subscription. + :type cost_center: str + :ivar invoice_section_id: The ID of the invoice section to which the subscription is billed. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section to which the subscription + is billed. + :vartype invoice_section_display_name: str + :ivar is_account_admin: Indicates whether user is the account admin. + :vartype is_account_admin: bool + :ivar product_id: The product ID of the Azure plan. + :vartype product_id: str + :ivar product_name: The product name of the Azure plan. + :vartype product_name: str + :ivar sku_id: The sku ID of the Azure plan for the subscription. + :vartype sku_id: str + :ivar sku_description: The sku description of the Azure plan for the subscription. + :vartype sku_description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'account_admin_notification_email_address': {'readonly': True}, + 'billing_tenant_id': {'readonly': True}, + 'billing_account_id': {'readonly': True}, + 'billing_account_display_name': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'billing_profile_status': {'readonly': True}, + 'billing_profile_status_reason_code': {'readonly': True}, + 'billing_profile_spending_limit': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'is_account_admin': {'readonly': True}, + 'product_id': {'readonly': True}, + 'product_name': {'readonly': True}, + 'sku_id': {'readonly': True}, + 'sku_description': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'account_admin_notification_email_address': {'key': 'properties.accountAdminNotificationEmailAddress', 'type': 'str'}, + 'billing_tenant_id': {'key': 'properties.billingTenantId', 'type': 'str'}, + 'billing_account_id': {'key': 'properties.billingAccountId', 'type': 'str'}, + 'billing_account_display_name': {'key': 'properties.billingAccountDisplayName', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'billing_profile_status': {'key': 'properties.billingProfileStatus', 'type': 'str'}, + 'billing_profile_status_reason_code': {'key': 'properties.billingProfileStatusReasonCode', 'type': 'str'}, + 'billing_profile_spending_limit': {'key': 'properties.billingProfileSpendingLimit', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'is_account_admin': {'key': 'properties.isAccountAdmin', 'type': 'bool'}, + 'product_id': {'key': 'properties.productId', 'type': 'str'}, + 'product_name': {'key': 'properties.productName', 'type': 'str'}, + 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, + 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, + } + + def __init__( + self, + *, + cost_center: Optional[str] = None, + **kwargs + ): + super(BillingProperty, self).__init__(**kwargs) + self.account_admin_notification_email_address = None + self.billing_tenant_id = None + self.billing_account_id = None + self.billing_account_display_name = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.billing_profile_status = None + self.billing_profile_status_reason_code = None + self.billing_profile_spending_limit = None + self.cost_center = cost_center + self.invoice_section_id = None + self.invoice_section_display_name = None + self.is_account_admin = None + self.product_id = None + self.product_name = None + self.sku_id = None + self.sku_description = None + + +class BillingRoleAssignment(Resource): + """The role assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar created_on: The date the role assignment was created. + :vartype created_on: str + :ivar created_by_principal_tenant_id: The tenant Id of the user who created the role + assignment. + :vartype created_by_principal_tenant_id: str + :ivar created_by_principal_id: The principal Id of the user who created the role assignment. + :vartype created_by_principal_id: str + :ivar created_by_user_email_address: The email address of the user who created the role + assignment. + :vartype created_by_user_email_address: str + :param principal_id: The principal id of the user to whom the role was assigned. + :type principal_id: str + :param principal_tenant_id: The principal tenant id of the user to whom the role was assigned. + :type principal_tenant_id: str + :param role_definition_id: The ID of the role definition. + :type role_definition_id: str + :ivar scope: The scope at which the role was assigned. + :vartype scope: str + :param user_authentication_type: The authentication type. + :type user_authentication_type: str + :param user_email_address: The email address of the user. + :type user_email_address: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'created_on': {'readonly': True}, + 'created_by_principal_tenant_id': {'readonly': True}, + 'created_by_principal_id': {'readonly': True}, + 'created_by_user_email_address': {'readonly': True}, + 'scope': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'str'}, + 'created_by_principal_tenant_id': {'key': 'properties.createdByPrincipalTenantId', 'type': 'str'}, + 'created_by_principal_id': {'key': 'properties.createdByPrincipalId', 'type': 'str'}, + 'created_by_user_email_address': {'key': 'properties.createdByUserEmailAddress', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_tenant_id': {'key': 'properties.principalTenantId', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'user_authentication_type': {'key': 'properties.userAuthenticationType', 'type': 'str'}, + 'user_email_address': {'key': 'properties.userEmailAddress', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + principal_tenant_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + user_authentication_type: Optional[str] = None, + user_email_address: Optional[str] = None, + **kwargs + ): + super(BillingRoleAssignment, self).__init__(**kwargs) + self.created_on = None + self.created_by_principal_tenant_id = None + self.created_by_principal_id = None + self.created_by_user_email_address = None + self.principal_id = principal_id + self.principal_tenant_id = principal_tenant_id + self.role_definition_id = role_definition_id + self.scope = None + self.user_authentication_type = user_authentication_type + self.user_email_address = user_email_address + + +class BillingRoleAssignmentListResult(msrest.serialization.Model): + """The list of role assignments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of role assignments. + :vartype value: list[~billing_management_client.models.BillingRoleAssignment] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingRoleAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingRoleAssignmentListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingRoleDefinition(Resource): + """The properties of a role definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar description: The role description. + :vartype description: str + :param permissions: The billingPermissions the role has. + :type permissions: list[~billing_management_client.models.BillingPermissionsProperties] + :ivar role_name: The name of the role. + :vartype role_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'description': {'readonly': True}, + 'role_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'permissions': {'key': 'properties.permissions', 'type': '[BillingPermissionsProperties]'}, + 'role_name': {'key': 'properties.roleName', 'type': 'str'}, + } + + def __init__( + self, + *, + permissions: Optional[List["BillingPermissionsProperties"]] = None, + **kwargs + ): + super(BillingRoleDefinition, self).__init__(**kwargs) + self.description = None + self.permissions = permissions + self.role_name = None + + +class BillingRoleDefinitionListResult(msrest.serialization.Model): + """The list of role definitions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The role definitions. + :vartype value: list[~billing_management_client.models.BillingRoleDefinition] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingRoleDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingRoleDefinitionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class BillingSubscription(Resource): + """A billing subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar display_name: The name of the subscription. + :vartype display_name: str + :ivar subscription_id: The ID of the subscription. + :vartype subscription_id: str + :param subscription_billing_status: The current billing status of the subscription. Possible + values include: "Active", "Inactive", "Abandoned", "Deleted", "Warning". + :type subscription_billing_status: str or + ~billing_management_client.models.BillingSubscriptionStatusType + :ivar last_month_charges: The last month charges. + :vartype last_month_charges: ~billing_management_client.models.Amount + :ivar month_to_date_charges: The current month to date charges. + :vartype month_to_date_charges: ~billing_management_client.models.Amount + :ivar billing_profile_id: The ID of the billing profile to which the subscription is billed. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile to which the subscription + is billed. + :vartype billing_profile_display_name: str + :param cost_center: The cost center applied to the subscription. + :type cost_center: str + :ivar customer_id: The ID of the customer for whom the subscription was created. The field is + applicable only for Microsoft Partner Agreement billing account. + :vartype customer_id: str + :ivar customer_display_name: The name of the customer for whom the subscription was created. + The field is applicable only for Microsoft Partner Agreement billing account. + :vartype customer_display_name: str + :ivar invoice_section_id: The ID of the invoice section to which the subscription is billed. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section to which the subscription + is billed. + :vartype invoice_section_display_name: str + :ivar reseller: Reseller for this subscription. + :vartype reseller: ~billing_management_client.models.Reseller + :param sku_id: The sku ID of the Azure plan for the subscription. + :type sku_id: str + :ivar sku_description: The sku description of the Azure plan for the subscription. + :vartype sku_description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'last_month_charges': {'readonly': True}, + 'month_to_date_charges': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'customer_id': {'readonly': True}, + 'customer_display_name': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'reseller': {'readonly': True}, + 'sku_description': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + 'subscription_billing_status': {'key': 'properties.subscriptionBillingStatus', 'type': 'str'}, + 'last_month_charges': {'key': 'properties.lastMonthCharges', 'type': 'Amount'}, + 'month_to_date_charges': {'key': 'properties.monthToDateCharges', 'type': 'Amount'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, + 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, + 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, + } + + def __init__( + self, + *, + subscription_billing_status: Optional[Union[str, "BillingSubscriptionStatusType"]] = None, + cost_center: Optional[str] = None, + sku_id: Optional[str] = None, + **kwargs + ): + super(BillingSubscription, self).__init__(**kwargs) + self.display_name = None + self.subscription_id = None + self.subscription_billing_status = subscription_billing_status + self.last_month_charges = None + self.month_to_date_charges = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.cost_center = cost_center + self.customer_id = None + self.customer_display_name = None + self.invoice_section_id = None + self.invoice_section_display_name = None + self.reseller = None + self.sku_id = sku_id + self.sku_description = None + + +class BillingSubscriptionsListResult(msrest.serialization.Model): + """The list of billing subscriptions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing subscriptions. + :vartype value: list[~billing_management_client.models.BillingSubscription] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BillingSubscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingSubscriptionsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Customer(Resource): + """A partner's customer. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar billing_profile_id: The ID of the billing profile for the invoice section. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile for the invoice section. + :vartype billing_profile_display_name: str + :param display_name: The name of the customer. + :type display_name: str + :param enabled_azure_plans: Azure plans enabled for the customer. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + :param resellers: The list of resellers for which an Azure plan is enabled for the customer. + :type resellers: list[~billing_management_client.models.Reseller] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'enabled_azure_plans': {'key': 'properties.enabledAzurePlans', 'type': '[AzurePlan]'}, + 'resellers': {'key': 'properties.resellers', 'type': '[Reseller]'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + enabled_azure_plans: Optional[List["AzurePlan"]] = None, + resellers: Optional[List["Reseller"]] = None, + **kwargs + ): + super(Customer, self).__init__(**kwargs) + self.billing_profile_id = None + self.billing_profile_display_name = None + self.display_name = display_name + self.enabled_azure_plans = enabled_azure_plans + self.resellers = resellers + + +class CustomerListResult(msrest.serialization.Model): + """The list of customers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of customers. + :vartype value: list[~billing_management_client.models.Customer] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Customer]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CustomerListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class CustomerPolicy(Resource): + """The customer's Policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param view_charges: The policy that controls whether the users in customer's organization can + view charges at pay-as-you-go prices. Possible values include: "Allowed", "NotAllowed". + :type view_charges: str or ~billing_management_client.models.ViewCharges + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'view_charges': {'key': 'properties.viewCharges', 'type': 'str'}, + } + + def __init__( + self, + *, + view_charges: Optional[Union[str, "ViewCharges"]] = None, + **kwargs + ): + super(CustomerPolicy, self).__init__(**kwargs) + self.view_charges = view_charges + + +class Department(Resource): + """A department. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param department_name: The name of the department. + :type department_name: str + :param cost_center: The cost center associated with the department. + :type cost_center: str + :param status: The status of the department. + :type status: str + :param enrollment_accounts: Associated enrollment accounts. By default this is not populated, + unless it's specified in $expand. + :type enrollment_accounts: list[~billing_management_client.models.EnrollmentAccount] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'department_name': {'key': 'properties.departmentName', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, + } + + def __init__( + self, + *, + department_name: Optional[str] = None, + cost_center: Optional[str] = None, + status: Optional[str] = None, + enrollment_accounts: Optional[List["EnrollmentAccount"]] = None, + **kwargs + ): + super(Department, self).__init__(**kwargs) + self.department_name = department_name + self.cost_center = cost_center + self.status = status + self.enrollment_accounts = enrollment_accounts + + +class Document(msrest.serialization.Model): + """The properties of a document. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar kind: The type of the document. Possible values include: "Invoice", "VoidNote", + "TaxReceipt", "CreditNote". + :vartype kind: str or ~billing_management_client.models.DocumentType + :ivar url: Document URL. + :vartype url: str + :ivar source: The source of the document. ENF for Brazil and DRS for rest of the world. + Possible values include: "DRS", "ENF". + :vartype source: str or ~billing_management_client.models.DocumentSource + """ + + _validation = { + 'kind': {'readonly': True}, + 'url': {'readonly': True}, + 'source': {'readonly': True}, + } + + _attribute_map = { + 'kind': {'key': 'kind', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Document, self).__init__(**kwargs) + self.kind = None + self.url = None + self.source = None + + +class DownloadUrl(msrest.serialization.Model): + """A secure URL that can be used to download a an entity until the URL expires. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar expiry_time: The time in UTC when the download URL will expire. + :vartype expiry_time: ~datetime.datetime + :ivar url: The URL to the PDF file. + :vartype url: str + """ + + _validation = { + 'expiry_time': {'readonly': True}, + 'url': {'readonly': True}, + } + + _attribute_map = { + 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, + 'url': {'key': 'url', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DownloadUrl, self).__init__(**kwargs) + self.expiry_time = None + self.url = None + + +class Enrollment(msrest.serialization.Model): + """The properties of an enrollment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param start_date: The start date of the enrollment. + :type start_date: ~datetime.datetime + :param end_date: The end date of the enrollment. + :type end_date: ~datetime.datetime + :ivar currency: The billing currency for the enrollment. + :vartype currency: str + :ivar channel: The channel type of the enrollment. + :vartype channel: str + :ivar policies: The policies for Enterprise Agreement enrollments. + :vartype policies: ~billing_management_client.models.EnrollmentPolicies + :ivar language: The language for the enrollment. + :vartype language: str + :ivar country_code: The country code of the enrollment. + :vartype country_code: str + :ivar status: The current status of the enrollment. + :vartype status: str + :ivar billing_cycle: The billing cycle for the enrollment. + :vartype billing_cycle: str + """ + + _validation = { + 'currency': {'readonly': True}, + 'channel': {'readonly': True}, + 'policies': {'readonly': True}, + 'language': {'readonly': True}, + 'country_code': {'readonly': True}, + 'status': {'readonly': True}, + 'billing_cycle': {'readonly': True}, + } + + _attribute_map = { + 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'endDate', 'type': 'iso-8601'}, + 'currency': {'key': 'currency', 'type': 'str'}, + 'channel': {'key': 'channel', 'type': 'str'}, + 'policies': {'key': 'policies', 'type': 'EnrollmentPolicies'}, + 'language': {'key': 'language', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'billing_cycle': {'key': 'billingCycle', 'type': 'str'}, + } + + def __init__( + self, + *, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + **kwargs + ): + super(Enrollment, self).__init__(**kwargs) + self.start_date = start_date + self.end_date = end_date + self.currency = None + self.channel = None + self.policies = None + self.language = None + self.country_code = None + self.status = None + self.billing_cycle = None + + +class EnrollmentAccount(Resource): + """An enrollment account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param account_name: The name of the enrollment account. + :type account_name: str + :param cost_center: The cost center associated with the enrollment account. + :type cost_center: str + :param account_owner: The owner of the enrollment account. + :type account_owner: str + :param status: The status of the enrollment account. + :type status: str + :param start_date: The start date of the enrollment account. + :type start_date: ~datetime.datetime + :param end_date: The end date of the enrollment account. + :type end_date: ~datetime.datetime + :param department: Associated department. By default this is not populated, unless it's + specified in $expand. + :type department: ~billing_management_client.models.Department + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'account_name': {'key': 'properties.accountName', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'account_owner': {'key': 'properties.accountOwner', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, + 'department': {'key': 'properties.department', 'type': 'Department'}, + } + + def __init__( + self, + *, + account_name: Optional[str] = None, + cost_center: Optional[str] = None, + account_owner: Optional[str] = None, + status: Optional[str] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + department: Optional["Department"] = None, + **kwargs + ): + super(EnrollmentAccount, self).__init__(**kwargs) + self.account_name = account_name + self.cost_center = cost_center + self.account_owner = account_owner + self.status = status + self.start_date = start_date + self.end_date = end_date + self.department = department + + +class EnrollmentAccountContext(msrest.serialization.Model): + """The enrollment account context. + + :param cost_center: The cost center associated with the enrollment account. + :type cost_center: str + :param start_date: The start date of the enrollment account. + :type start_date: ~datetime.datetime + :param end_date: The end date of the enrollment account. + :type end_date: ~datetime.datetime + :param enrollment_account_name: The ID of the enrollment account. + :type enrollment_account_name: str + """ + + _attribute_map = { + 'cost_center': {'key': 'costCenter', 'type': 'str'}, + 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'endDate', 'type': 'iso-8601'}, + 'enrollment_account_name': {'key': 'enrollmentAccountName', 'type': 'str'}, + } + + def __init__( + self, + *, + cost_center: Optional[str] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + enrollment_account_name: Optional[str] = None, + **kwargs + ): + super(EnrollmentAccountContext, self).__init__(**kwargs) + self.cost_center = cost_center + self.start_date = start_date + self.end_date = end_date + self.enrollment_account_name = enrollment_account_name + + +class EnrollmentAccountListResult(msrest.serialization.Model): + """Result of listing enrollment accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of enrollment accounts. + :vartype value: list[~billing_management_client.models.EnrollmentAccountSummary] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[EnrollmentAccountSummary]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentAccountListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class EnrollmentAccountSummary(Resource): + """An enrollment account resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar principal_name: The account owner's principal name. + :vartype principal_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'principal_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentAccountSummary, self).__init__(**kwargs) + self.principal_name = None + + +class EnrollmentPolicies(msrest.serialization.Model): + """The policies for Enterprise Agreement enrollments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar account_owner_view_charges: The policy that controls whether Account Owners can view + charges. + :vartype account_owner_view_charges: bool + :ivar department_admin_view_charges: The policy that controls whether Department Administrators + can view charges. + :vartype department_admin_view_charges: bool + :ivar marketplaces_enabled: The policy that controls whether Azure marketplace purchases are + allowed in the enrollment. + :vartype marketplaces_enabled: bool + :ivar reserved_instances_enabled: The policy that controls whether Azure reservation purchases + are allowed in the enrollment. + :vartype reserved_instances_enabled: bool + """ + + _validation = { + 'account_owner_view_charges': {'readonly': True}, + 'department_admin_view_charges': {'readonly': True}, + 'marketplaces_enabled': {'readonly': True}, + 'reserved_instances_enabled': {'readonly': True}, + } + + _attribute_map = { + 'account_owner_view_charges': {'key': 'accountOwnerViewCharges', 'type': 'bool'}, + 'department_admin_view_charges': {'key': 'departmentAdminViewCharges', 'type': 'bool'}, + 'marketplaces_enabled': {'key': 'marketplacesEnabled', 'type': 'bool'}, + 'reserved_instances_enabled': {'key': 'reservedInstancesEnabled', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(EnrollmentPolicies, self).__init__(**kwargs) + self.account_owner_view_charges = None + self.department_admin_view_charges = None + self.marketplaces_enabled = None + self.reserved_instances_enabled = None + + +class ErrorDetails(msrest.serialization.Model): + """The details of the error. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar details: The sub details of the error. + :vartype details: list[~billing_management_client.models.ErrorSubDetailsItem] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorSubDetailsItem]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetails, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + + +class ErrorResponse(msrest.serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + + :param error: The details of the error. + :type error: ~billing_management_client.models.ErrorDetails + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetails'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetails"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorSubDetailsItem(msrest.serialization.Model): + """ErrorSubDetailsItem. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorSubDetailsItem, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + + +class IndirectRelationshipInfo(msrest.serialization.Model): + """The billing profile details of the partner of the customer for an indirect motion. + + :param billing_account_name: The billing account name of the partner or the customer for an + indirect motion. + :type billing_account_name: str + :param billing_profile_name: The billing profile name of the partner or the customer for an + indirect motion. + :type billing_profile_name: str + :param display_name: The display name of the partner or customer for an indirect motion. + :type display_name: str + """ + + _attribute_map = { + 'billing_account_name': {'key': 'billingAccountName', 'type': 'str'}, + 'billing_profile_name': {'key': 'billingProfileName', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + billing_account_name: Optional[str] = None, + billing_profile_name: Optional[str] = None, + display_name: Optional[str] = None, + **kwargs + ): + super(IndirectRelationshipInfo, self).__init__(**kwargs) + self.billing_account_name = billing_account_name + self.billing_profile_name = billing_profile_name + self.display_name = display_name + + +class Instruction(Resource): + """An instruction. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param amount: The amount budgeted for this billing instruction. + :type amount: float + :param start_date: The date this billing instruction goes into effect. + :type start_date: ~datetime.datetime + :param end_date: The date this billing instruction is no longer in effect. + :type end_date: ~datetime.datetime + :param creation_date: The date this billing instruction was created. + :type creation_date: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'amount': {'key': 'properties.amount', 'type': 'float'}, + 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, + 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + amount: Optional[float] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + creation_date: Optional[datetime.datetime] = None, + **kwargs + ): + super(Instruction, self).__init__(**kwargs) + self.amount = amount + self.start_date = start_date + self.end_date = end_date + self.creation_date = creation_date + + +class InstructionListResult(msrest.serialization.Model): + """The list of billing instructions used during invoice generation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing instructions used during invoice generation. + :vartype value: list[~billing_management_client.models.Instruction] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Instruction]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InstructionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Invoice(Resource): + """An invoice. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar due_date: The due date for the invoice. + :vartype due_date: ~datetime.datetime + :ivar invoice_date: The date when the invoice was generated. + :vartype invoice_date: ~datetime.datetime + :ivar status: The current status of the invoice. Possible values include: "Due", "OverDue", + "Paid", "Void". + :vartype status: str or ~billing_management_client.models.InvoiceStatus + :ivar amount_due: The amount due as of now. + :vartype amount_due: ~billing_management_client.models.Amount + :ivar azure_prepayment_applied: The amount of Azure prepayment applied to the charges. This + field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + :vartype azure_prepayment_applied: ~billing_management_client.models.Amount + :ivar billed_amount: The total charges for the invoice billing period. + :vartype billed_amount: ~billing_management_client.models.Amount + :ivar credit_amount: The total refund for returns and cancellations during the invoice billing + period. This field is applicable to billing accounts with agreement type Microsoft Customer + Agreement. + :vartype credit_amount: ~billing_management_client.models.Amount + :ivar free_azure_credit_applied: The amount of free Azure credits applied to the charges. This + field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + :vartype free_azure_credit_applied: ~billing_management_client.models.Amount + :ivar sub_total: The pre-tax amount due. This field is applicable to billing accounts with + agreement type Microsoft Customer Agreement. + :vartype sub_total: ~billing_management_client.models.Amount + :ivar tax_amount: The amount of tax charged for the billing period. This field is applicable to + billing accounts with agreement type Microsoft Customer Agreement. + :vartype tax_amount: ~billing_management_client.models.Amount + :ivar total_amount: The amount due when the invoice was generated. This field is applicable to + billing accounts with agreement type Microsoft Customer Agreement. + :vartype total_amount: ~billing_management_client.models.Amount + :ivar invoice_period_start_date: The start date of the billing period for which the invoice is + generated. + :vartype invoice_period_start_date: ~datetime.datetime + :ivar invoice_period_end_date: The end date of the billing period for which the invoice is + generated. + :vartype invoice_period_end_date: ~datetime.datetime + :ivar invoice_type: Invoice type. Possible values include: "AzureService", "AzureMarketplace", + "AzureSupport". + :vartype invoice_type: str or ~billing_management_client.models.InvoiceType + :ivar is_monthly_invoice: Specifies if the invoice is generated as part of monthly invoicing + cycle or not. This field is applicable to billing accounts with agreement type Microsoft + Customer Agreement. + :vartype is_monthly_invoice: bool + :ivar billing_profile_id: The ID of the billing profile for which the invoice is generated. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile for which the invoice is + generated. + :vartype billing_profile_display_name: str + :ivar purchase_order_number: An optional purchase order number for the invoice. + :vartype purchase_order_number: str + :ivar documents: List of documents available to download such as invoice and tax receipt. + :vartype documents: list[~billing_management_client.models.Document] + :ivar payments: List of payments. + :vartype payments: list[~billing_management_client.models.PaymentProperties] + :ivar rebill_details: Rebill details for an invoice. + :vartype rebill_details: dict[str, ~billing_management_client.models.RebillDetails] + :ivar document_type: The type of the document. Possible values include: "Invoice", + "CreditNote". + :vartype document_type: str or ~billing_management_client.models.InvoiceDocumentType + :ivar billed_document_id: The Id of the active invoice which is originally billed after this + invoice was voided. This field is applicable to the void invoices only. + :vartype billed_document_id: str + :ivar credit_for_document_id: The Id of the invoice which got voided and this credit note was + issued as a result. This field is applicable to the credit notes only. + :vartype credit_for_document_id: str + :ivar subscription_id: The ID of the subscription for which the invoice is generated. + :vartype subscription_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'due_date': {'readonly': True}, + 'invoice_date': {'readonly': True}, + 'status': {'readonly': True}, + 'amount_due': {'readonly': True}, + 'azure_prepayment_applied': {'readonly': True}, + 'billed_amount': {'readonly': True}, + 'credit_amount': {'readonly': True}, + 'free_azure_credit_applied': {'readonly': True}, + 'sub_total': {'readonly': True}, + 'tax_amount': {'readonly': True}, + 'total_amount': {'readonly': True}, + 'invoice_period_start_date': {'readonly': True}, + 'invoice_period_end_date': {'readonly': True}, + 'invoice_type': {'readonly': True}, + 'is_monthly_invoice': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'purchase_order_number': {'readonly': True}, + 'documents': {'readonly': True}, + 'payments': {'readonly': True}, + 'rebill_details': {'readonly': True}, + 'document_type': {'readonly': True}, + 'billed_document_id': {'readonly': True}, + 'credit_for_document_id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'due_date': {'key': 'properties.dueDate', 'type': 'iso-8601'}, + 'invoice_date': {'key': 'properties.invoiceDate', 'type': 'iso-8601'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'amount_due': {'key': 'properties.amountDue', 'type': 'Amount'}, + 'azure_prepayment_applied': {'key': 'properties.azurePrepaymentApplied', 'type': 'Amount'}, + 'billed_amount': {'key': 'properties.billedAmount', 'type': 'Amount'}, + 'credit_amount': {'key': 'properties.creditAmount', 'type': 'Amount'}, + 'free_azure_credit_applied': {'key': 'properties.freeAzureCreditApplied', 'type': 'Amount'}, + 'sub_total': {'key': 'properties.subTotal', 'type': 'Amount'}, + 'tax_amount': {'key': 'properties.taxAmount', 'type': 'Amount'}, + 'total_amount': {'key': 'properties.totalAmount', 'type': 'Amount'}, + 'invoice_period_start_date': {'key': 'properties.invoicePeriodStartDate', 'type': 'iso-8601'}, + 'invoice_period_end_date': {'key': 'properties.invoicePeriodEndDate', 'type': 'iso-8601'}, + 'invoice_type': {'key': 'properties.invoiceType', 'type': 'str'}, + 'is_monthly_invoice': {'key': 'properties.isMonthlyInvoice', 'type': 'bool'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'purchase_order_number': {'key': 'properties.purchaseOrderNumber', 'type': 'str'}, + 'documents': {'key': 'properties.documents', 'type': '[Document]'}, + 'payments': {'key': 'properties.payments', 'type': '[PaymentProperties]'}, + 'rebill_details': {'key': 'properties.rebillDetails', 'type': '{RebillDetails}'}, + 'document_type': {'key': 'properties.documentType', 'type': 'str'}, + 'billed_document_id': {'key': 'properties.billedDocumentId', 'type': 'str'}, + 'credit_for_document_id': {'key': 'properties.creditForDocumentId', 'type': 'str'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Invoice, self).__init__(**kwargs) + self.due_date = None + self.invoice_date = None + self.status = None + self.amount_due = None + self.azure_prepayment_applied = None + self.billed_amount = None + self.credit_amount = None + self.free_azure_credit_applied = None + self.sub_total = None + self.tax_amount = None + self.total_amount = None + self.invoice_period_start_date = None + self.invoice_period_end_date = None + self.invoice_type = None + self.is_monthly_invoice = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.purchase_order_number = None + self.documents = None + self.payments = None + self.rebill_details = None + self.document_type = None + self.billed_document_id = None + self.credit_for_document_id = None + self.subscription_id = None + + +class InvoiceListResult(msrest.serialization.Model): + """The list of invoices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of invoices. + :vartype value: list[~billing_management_client.models.Invoice] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Invoice]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class InvoiceSection(Resource): + """An invoice section. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param display_name: The name of the invoice section. + :type display_name: str + :param labels: Dictionary of metadata associated with the invoice section. + :type labels: dict[str, str] + :ivar state: Identifies the state of an invoice section. Possible values include: "Active", + "Restricted". + :vartype state: str or ~billing_management_client.models.InvoiceSectionState + :ivar system_id: The system generated unique identifier for an invoice section. + :vartype system_id: str + :ivar target_cloud: Identifies the cloud environments that are associated with an invoice + section. This is a system managed optional field and gets updated as the invoice section gets + associated with accounts in various clouds. Possible values include: "USGov", "USNat", "USSec". + :vartype target_cloud: str or ~billing_management_client.models.TargetCloud + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'state': {'readonly': True}, + 'system_id': {'readonly': True}, + 'target_cloud': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'labels': {'key': 'properties.labels', 'type': '{str}'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'system_id': {'key': 'properties.systemId', 'type': 'str'}, + 'target_cloud': {'key': 'properties.targetCloud', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + labels: Optional[Dict[str, str]] = None, + **kwargs + ): + super(InvoiceSection, self).__init__(**kwargs) + self.display_name = display_name + self.labels = labels + self.state = None + self.system_id = None + self.target_cloud = None + + +class InvoiceSectionCreationRequest(msrest.serialization.Model): + """The properties of the invoice section. + + :param display_name: The name of the invoice section. + :type display_name: str + """ + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + **kwargs + ): + super(InvoiceSectionCreationRequest, self).__init__(**kwargs) + self.display_name = display_name + + +class InvoiceSectionListResult(msrest.serialization.Model): + """The list of invoice sections. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of invoice sections. + :vartype value: list[~billing_management_client.models.InvoiceSection] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[InvoiceSection]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InvoiceSectionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class InvoiceSectionListWithCreateSubPermissionResult(msrest.serialization.Model): + """The list of invoice section properties with create subscription permission. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: The list of invoice section properties with create subscription permission. + :type value: list[~billing_management_client.models.InvoiceSectionWithCreateSubPermission] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[InvoiceSectionWithCreateSubPermission]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["InvoiceSectionWithCreateSubPermission"]] = None, + **kwargs + ): + super(InvoiceSectionListWithCreateSubPermissionResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class InvoiceSectionsOnExpand(msrest.serialization.Model): + """The invoice sections associated to the billing profile. By default this is not populated, unless it's specified in $expand. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar has_more_results: Indicates whether there are more invoice sections than the ones listed + in this collection. The collection lists a maximum of 50 invoice sections. To get all invoice + sections, use the list invoice sections API. + :vartype has_more_results: bool + :param value: The invoice sections associated to the billing profile. + :type value: list[~billing_management_client.models.InvoiceSection] + """ + + _validation = { + 'has_more_results': {'readonly': True}, + } + + _attribute_map = { + 'has_more_results': {'key': 'hasMoreResults', 'type': 'bool'}, + 'value': {'key': 'value', 'type': '[InvoiceSection]'}, + } + + def __init__( + self, + *, + value: Optional[List["InvoiceSection"]] = None, + **kwargs + ): + super(InvoiceSectionsOnExpand, self).__init__(**kwargs) + self.has_more_results = None + self.value = value + + +class InvoiceSectionWithCreateSubPermission(msrest.serialization.Model): + """Invoice section properties with create subscription permission. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar invoice_section_id: The ID of the invoice section. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section. + :vartype invoice_section_display_name: str + :ivar invoice_section_system_id: The system generated unique identifier for an invoice section. + :vartype invoice_section_system_id: str + :ivar billing_profile_id: The ID of the billing profile for the invoice section. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile for the invoice section. + :vartype billing_profile_display_name: str + :ivar billing_profile_status: The status of the billing profile. Possible values include: + "Active", "Disabled", "Warned". + :vartype billing_profile_status: str or ~billing_management_client.models.BillingProfileStatus + :ivar billing_profile_status_reason_code: Reason for the specified billing profile status. + Possible values include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". + :vartype billing_profile_status_reason_code: str or + ~billing_management_client.models.StatusReasonCodeForBillingProfile + :ivar billing_profile_spending_limit: The billing profile spending limit. Possible values + include: "Off", "On". + :vartype billing_profile_spending_limit: str or + ~billing_management_client.models.SpendingLimitForBillingProfile + :ivar billing_profile_system_id: The system generated unique identifier for a billing profile. + :vartype billing_profile_system_id: str + :param enabled_azure_plans: Enabled azure plans for the associated billing profile. + :type enabled_azure_plans: list[~billing_management_client.models.AzurePlan] + """ + + _validation = { + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'invoice_section_system_id': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'billing_profile_status': {'readonly': True}, + 'billing_profile_status_reason_code': {'readonly': True}, + 'billing_profile_spending_limit': {'readonly': True}, + 'billing_profile_system_id': {'readonly': True}, + } + + _attribute_map = { + 'invoice_section_id': {'key': 'invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'invoiceSectionDisplayName', 'type': 'str'}, + 'invoice_section_system_id': {'key': 'invoiceSectionSystemId', 'type': 'str'}, + 'billing_profile_id': {'key': 'billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'billingProfileDisplayName', 'type': 'str'}, + 'billing_profile_status': {'key': 'billingProfileStatus', 'type': 'str'}, + 'billing_profile_status_reason_code': {'key': 'billingProfileStatusReasonCode', 'type': 'str'}, + 'billing_profile_spending_limit': {'key': 'billingProfileSpendingLimit', 'type': 'str'}, + 'billing_profile_system_id': {'key': 'billingProfileSystemId', 'type': 'str'}, + 'enabled_azure_plans': {'key': 'enabledAzurePlans', 'type': '[AzurePlan]'}, + } + + def __init__( + self, + *, + enabled_azure_plans: Optional[List["AzurePlan"]] = None, + **kwargs + ): + super(InvoiceSectionWithCreateSubPermission, self).__init__(**kwargs) + self.invoice_section_id = None + self.invoice_section_display_name = None + self.invoice_section_system_id = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.billing_profile_status = None + self.billing_profile_status_reason_code = None + self.billing_profile_spending_limit = None + self.billing_profile_system_id = None + self.enabled_azure_plans = enabled_azure_plans + + +class Operation(msrest.serialization.Model): + """A Billing REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :param display: The object that represents the operation. + :type display: ~billing_management_client.models.OperationDisplay + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Service provider: Microsoft.Billing. + :vartype provider: str + :ivar resource: Resource on which the operation is performed such as invoice and billing + subscription. + :vartype resource: str + :ivar operation: Operation type such as read, write and delete. + :vartype operation: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + + +class OperationListResult(msrest.serialization.Model): + """The list of billing operations and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of billing operations supported by the Microsoft.Billing resource + provider. + :vartype value: list[~billing_management_client.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Participants(msrest.serialization.Model): + """The details about a participant. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The acceptance status of the participant. + :vartype status: str + :ivar status_date: The date when the status got changed. + :vartype status_date: ~datetime.datetime + :ivar email: The email address of the participant. + :vartype email: str + """ + + _validation = { + 'status': {'readonly': True}, + 'status_date': {'readonly': True}, + 'email': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'status_date': {'key': 'statusDate', 'type': 'iso-8601'}, + 'email': {'key': 'email', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Participants, self).__init__(**kwargs) + self.status = None + self.status_date = None + self.email = None + + +class PaymentProperties(msrest.serialization.Model): + """The properties of a payment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar payment_type: The type of payment. + :vartype payment_type: str + :ivar amount: The paid amount. + :vartype amount: ~billing_management_client.models.Amount + :ivar date: The date when the payment was made. + :vartype date: ~datetime.datetime + :param payment_method_family: The family of payment method. Possible values include: "Credits", + "CheckWire", "CreditCard", "None". + :type payment_method_family: str or ~billing_management_client.models.PaymentMethodFamily + :ivar payment_method_type: The type of payment method. + :vartype payment_method_type: str + """ + + _validation = { + 'payment_type': {'readonly': True}, + 'amount': {'readonly': True}, + 'date': {'readonly': True}, + 'payment_method_type': {'readonly': True}, + } + + _attribute_map = { + 'payment_type': {'key': 'paymentType', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'Amount'}, + 'date': {'key': 'date', 'type': 'iso-8601'}, + 'payment_method_family': {'key': 'paymentMethodFamily', 'type': 'str'}, + 'payment_method_type': {'key': 'paymentMethodType', 'type': 'str'}, + } + + def __init__( + self, + *, + payment_method_family: Optional[Union[str, "PaymentMethodFamily"]] = None, + **kwargs + ): + super(PaymentProperties, self).__init__(**kwargs) + self.payment_type = None + self.amount = None + self.date = None + self.payment_method_family = payment_method_family + self.payment_method_type = None + + +class Policy(Resource): + """A policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param marketplace_purchases: The policy that controls whether Azure marketplace purchases are + allowed for a billing profile. Possible values include: "AllAllowed", "OnlyFreeAllowed", + "NotAllowed". + :type marketplace_purchases: str or + ~billing_management_client.models.MarketplacePurchasesPolicy + :param reservation_purchases: The policy that controls whether Azure reservation purchases are + allowed for a billing profile. Possible values include: "Allowed", "NotAllowed". + :type reservation_purchases: str or + ~billing_management_client.models.ReservationPurchasesPolicy + :param view_charges: The policy that controls whether users with Azure RBAC access to a + subscription can view its charges. Possible values include: "Allowed", "NotAllowed". + :type view_charges: str or ~billing_management_client.models.ViewChargesPolicy + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'marketplace_purchases': {'key': 'properties.marketplacePurchases', 'type': 'str'}, + 'reservation_purchases': {'key': 'properties.reservationPurchases', 'type': 'str'}, + 'view_charges': {'key': 'properties.viewCharges', 'type': 'str'}, + } + + def __init__( + self, + *, + marketplace_purchases: Optional[Union[str, "MarketplacePurchasesPolicy"]] = None, + reservation_purchases: Optional[Union[str, "ReservationPurchasesPolicy"]] = None, + view_charges: Optional[Union[str, "ViewChargesPolicy"]] = None, + **kwargs + ): + super(Policy, self).__init__(**kwargs) + self.marketplace_purchases = marketplace_purchases + self.reservation_purchases = reservation_purchases + self.view_charges = view_charges + + +class Product(Resource): + """A product. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param auto_renew: Indicates whether auto renewal is turned on or off for a product. Possible + values include: "Off", "On". + :type auto_renew: str or ~billing_management_client.models.AutoRenew + :ivar display_name: The display name of the product. + :vartype display_name: str + :ivar purchase_date: The date when the product was purchased. + :vartype purchase_date: ~datetime.datetime + :ivar product_type_id: The ID of the type of product. + :vartype product_type_id: str + :ivar product_type: The description of the type of product. + :vartype product_type: str + :param status: The current status of the product. Possible values include: "Active", + "Inactive", "PastDue", "Expiring", "Expired", "Disabled", "Cancelled", "AutoRenew". + :type status: str or ~billing_management_client.models.ProductStatusType + :ivar end_date: The date when the product will be renewed or canceled. + :vartype end_date: ~datetime.datetime + :param billing_frequency: The frequency at which the product will be billed. Possible values + include: "OneTime", "Monthly", "UsageBased". + :type billing_frequency: str or ~billing_management_client.models.BillingFrequency + :ivar last_charge: The last month charges. + :vartype last_charge: ~billing_management_client.models.Amount + :ivar last_charge_date: The date of the last charge. + :vartype last_charge_date: ~datetime.datetime + :ivar quantity: The quantity purchased for the product. + :vartype quantity: float + :ivar sku_id: The sku ID of the product. + :vartype sku_id: str + :ivar sku_description: The sku description of the product. + :vartype sku_description: str + :ivar tenant_id: The id of the tenant in which the product is used. + :vartype tenant_id: str + :ivar availability_id: The availability of the product. + :vartype availability_id: str + :ivar invoice_section_id: The ID of the invoice section to which the product is billed. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section to which the product is + billed. + :vartype invoice_section_display_name: str + :ivar billing_profile_id: The ID of the billing profile to which the product is billed. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile to which the product is + billed. + :vartype billing_profile_display_name: str + :ivar customer_id: The ID of the customer for whom the product was purchased. The field is + applicable only for Microsoft Partner Agreement billing account. + :vartype customer_id: str + :ivar customer_display_name: The name of the customer for whom the product was purchased. The + field is applicable only for Microsoft Partner Agreement billing account. + :vartype customer_display_name: str + :ivar reseller: Reseller for this product. + :vartype reseller: ~billing_management_client.models.Reseller + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'purchase_date': {'readonly': True}, + 'product_type_id': {'readonly': True}, + 'product_type': {'readonly': True}, + 'end_date': {'readonly': True}, + 'last_charge': {'readonly': True}, + 'last_charge_date': {'readonly': True}, + 'quantity': {'readonly': True}, + 'sku_id': {'readonly': True}, + 'sku_description': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'availability_id': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'customer_id': {'readonly': True}, + 'customer_display_name': {'readonly': True}, + 'reseller': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'auto_renew': {'key': 'properties.autoRenew', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'purchase_date': {'key': 'properties.purchaseDate', 'type': 'iso-8601'}, + 'product_type_id': {'key': 'properties.productTypeId', 'type': 'str'}, + 'product_type': {'key': 'properties.productType', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, + 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, + 'last_charge': {'key': 'properties.lastCharge', 'type': 'Amount'}, + 'last_charge_date': {'key': 'properties.lastChargeDate', 'type': 'iso-8601'}, + 'quantity': {'key': 'properties.quantity', 'type': 'float'}, + 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, + 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'availability_id': {'key': 'properties.availabilityId', 'type': 'str'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, + 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + } + + def __init__( + self, + *, + auto_renew: Optional[Union[str, "AutoRenew"]] = None, + status: Optional[Union[str, "ProductStatusType"]] = None, + billing_frequency: Optional[Union[str, "BillingFrequency"]] = None, + **kwargs + ): + super(Product, self).__init__(**kwargs) + self.auto_renew = auto_renew + self.display_name = None + self.purchase_date = None + self.product_type_id = None + self.product_type = None + self.status = status + self.end_date = None + self.billing_frequency = billing_frequency + self.last_charge = None + self.last_charge_date = None + self.quantity = None + self.sku_id = None + self.sku_description = None + self.tenant_id = None + self.availability_id = None + self.invoice_section_id = None + self.invoice_section_display_name = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.customer_id = None + self.customer_display_name = None + self.reseller = None + + +class ProductsListResult(msrest.serialization.Model): + """The list of products. It contains a list of available product summaries in reverse chronological order by purchase date. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of products. + :vartype value: list[~billing_management_client.models.Product] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Product]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProductsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class RebillDetails(msrest.serialization.Model): + """The rebill details of an invoice. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar credit_note_document_id: The ID of credit note. + :vartype credit_note_document_id: str + :ivar invoice_document_id: The ID of invoice. + :vartype invoice_document_id: str + :ivar rebill_details: Rebill details for an invoice. + :vartype rebill_details: dict[str, ~billing_management_client.models.RebillDetails] + """ + + _validation = { + 'credit_note_document_id': {'readonly': True}, + 'invoice_document_id': {'readonly': True}, + 'rebill_details': {'readonly': True}, + } + + _attribute_map = { + 'credit_note_document_id': {'key': 'creditNoteDocumentId', 'type': 'str'}, + 'invoice_document_id': {'key': 'invoiceDocumentId', 'type': 'str'}, + 'rebill_details': {'key': 'rebillDetails', 'type': '{RebillDetails}'}, + } + + def __init__( + self, + **kwargs + ): + super(RebillDetails, self).__init__(**kwargs) + self.credit_note_document_id = None + self.invoice_document_id = None + self.rebill_details = None + + +class Reseller(msrest.serialization.Model): + """Details of the reseller. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar reseller_id: The MPN ID of the reseller. + :vartype reseller_id: str + :ivar description: The name of the reseller. + :vartype description: str + """ + + _validation = { + 'reseller_id': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Reseller, self).__init__(**kwargs) + self.reseller_id = None + self.description = None + + +class Transaction(Resource): + """A transaction. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param kind: The kind of transaction. Options are all or reservation. Possible values include: + "all", "reservation". + :type kind: str or ~billing_management_client.models.TransactionTypeKind + :ivar date: The date of transaction. + :vartype date: ~datetime.datetime + :ivar invoice: Invoice on which the transaction was billed or 'pending' if the transaction is + not billed. + :vartype invoice: str + :ivar invoice_id: The ID of the invoice on which the transaction was billed. This field is only + applicable for transactions which are billed. + :vartype invoice_id: str + :ivar order_id: The order ID of the reservation. The field is only applicable for transaction + of kind reservation. + :vartype order_id: str + :ivar order_name: The name of the reservation order. The field is only applicable for + transactions of kind reservation. + :vartype order_name: str + :ivar product_family: The family of the product for which the transaction took place. + :vartype product_family: str + :ivar product_type_id: The ID of the product type for which the transaction took place. + :vartype product_type_id: str + :ivar product_type: The type of the product for which the transaction took place. + :vartype product_type: str + :ivar product_description: The description of the product for which the transaction took place. + :vartype product_description: str + :param transaction_type: The type of transaction. Possible values include: "Purchase", "Usage + Charge". + :type transaction_type: str or ~billing_management_client.models.ReservationType + :ivar transaction_amount: The charge associated with the transaction. + :vartype transaction_amount: ~billing_management_client.models.Amount + :ivar quantity: The quantity purchased in the transaction. + :vartype quantity: int + :ivar invoice_section_id: The ID of the invoice section which will be billed for the + transaction. + :vartype invoice_section_id: str + :ivar invoice_section_display_name: The name of the invoice section which will be billed for + the transaction. + :vartype invoice_section_display_name: str + :ivar billing_profile_id: The ID of the billing profile which will be billed for the + transaction. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile which will be billed for + the transaction. + :vartype billing_profile_display_name: str + :ivar customer_id: The ID of the customer for which the transaction took place. The field is + applicable only for Microsoft Partner Agreement billing account. + :vartype customer_id: str + :ivar customer_display_name: The name of the customer for which the transaction took place. The + field is applicable only for Microsoft Partner Agreement billing account. + :vartype customer_display_name: str + :ivar subscription_id: The ID of the subscription that was used for the transaction. The field + is only applicable for transaction of kind reservation. + :vartype subscription_id: str + :ivar subscription_name: The name of the subscription that was used for the transaction. The + field is only applicable for transaction of kind reservation. + :vartype subscription_name: str + :ivar azure_plan: The type of azure plan of the subscription that was used for the transaction. + :vartype azure_plan: str + :ivar azure_credit_applied: The amount of any Azure credits automatically applied to this + transaction. + :vartype azure_credit_applied: ~billing_management_client.models.Amount + :ivar billing_currency: The ISO 4217 code for the currency in which this transaction is billed. + :vartype billing_currency: str + :ivar discount: The percentage discount, if any, applied to this transaction. + :vartype discount: float + :ivar effective_price: The price of the product after applying any discounts. + :vartype effective_price: ~billing_management_client.models.Amount + :ivar exchange_rate: The exchange rate used to convert charged amount to billing currency, if + applicable. + :vartype exchange_rate: float + :ivar market_price: The retail price of the product. + :vartype market_price: ~billing_management_client.models.Amount + :ivar pricing_currency: The ISO 4217 code for the currency in which the product is priced. + :vartype pricing_currency: str + :ivar service_period_start_date: The date of the purchase of the product, or the start date of + the month in which usage started. + :vartype service_period_start_date: ~datetime.datetime + :ivar service_period_end_date: The end date of the product term, or the end date of the month + in which usage ended. + :vartype service_period_end_date: ~datetime.datetime + :ivar sub_total: The pre-tax charged amount for the transaction. + :vartype sub_total: ~billing_management_client.models.Amount + :ivar tax: The tax amount applied to the transaction. + :vartype tax: ~billing_management_client.models.Amount + :ivar unit_of_measure: The unit of measure used to bill for the product. For example, compute + services are billed per hour. + :vartype unit_of_measure: str + :ivar units: The number of units used for a given product. + :vartype units: float + :ivar unit_type: The description for the unit of measure for a given product. + :vartype unit_type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'date': {'readonly': True}, + 'invoice': {'readonly': True}, + 'invoice_id': {'readonly': True}, + 'order_id': {'readonly': True}, + 'order_name': {'readonly': True}, + 'product_family': {'readonly': True}, + 'product_type_id': {'readonly': True}, + 'product_type': {'readonly': True}, + 'product_description': {'readonly': True}, + 'transaction_amount': {'readonly': True}, + 'quantity': {'readonly': True}, + 'invoice_section_id': {'readonly': True}, + 'invoice_section_display_name': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'customer_id': {'readonly': True}, + 'customer_display_name': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'subscription_name': {'readonly': True}, + 'azure_plan': {'readonly': True}, + 'azure_credit_applied': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'discount': {'readonly': True}, + 'effective_price': {'readonly': True}, + 'exchange_rate': {'readonly': True}, + 'market_price': {'readonly': True}, + 'pricing_currency': {'readonly': True}, + 'service_period_start_date': {'readonly': True}, + 'service_period_end_date': {'readonly': True}, + 'sub_total': {'readonly': True}, + 'tax': {'readonly': True}, + 'unit_of_measure': {'readonly': True}, + 'units': {'readonly': True}, + 'unit_type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'properties.kind', 'type': 'str'}, + 'date': {'key': 'properties.date', 'type': 'iso-8601'}, + 'invoice': {'key': 'properties.invoice', 'type': 'str'}, + 'invoice_id': {'key': 'properties.invoiceId', 'type': 'str'}, + 'order_id': {'key': 'properties.orderId', 'type': 'str'}, + 'order_name': {'key': 'properties.orderName', 'type': 'str'}, + 'product_family': {'key': 'properties.productFamily', 'type': 'str'}, + 'product_type_id': {'key': 'properties.productTypeId', 'type': 'str'}, + 'product_type': {'key': 'properties.productType', 'type': 'str'}, + 'product_description': {'key': 'properties.productDescription', 'type': 'str'}, + 'transaction_type': {'key': 'properties.transactionType', 'type': 'str'}, + 'transaction_amount': {'key': 'properties.transactionAmount', 'type': 'Amount'}, + 'quantity': {'key': 'properties.quantity', 'type': 'int'}, + 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, + 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, + 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + 'subscription_name': {'key': 'properties.subscriptionName', 'type': 'str'}, + 'azure_plan': {'key': 'properties.azurePlan', 'type': 'str'}, + 'azure_credit_applied': {'key': 'properties.azureCreditApplied', 'type': 'Amount'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'discount': {'key': 'properties.discount', 'type': 'float'}, + 'effective_price': {'key': 'properties.effectivePrice', 'type': 'Amount'}, + 'exchange_rate': {'key': 'properties.exchangeRate', 'type': 'float'}, + 'market_price': {'key': 'properties.marketPrice', 'type': 'Amount'}, + 'pricing_currency': {'key': 'properties.pricingCurrency', 'type': 'str'}, + 'service_period_start_date': {'key': 'properties.servicePeriodStartDate', 'type': 'iso-8601'}, + 'service_period_end_date': {'key': 'properties.servicePeriodEndDate', 'type': 'iso-8601'}, + 'sub_total': {'key': 'properties.subTotal', 'type': 'Amount'}, + 'tax': {'key': 'properties.tax', 'type': 'Amount'}, + 'unit_of_measure': {'key': 'properties.unitOfMeasure', 'type': 'str'}, + 'units': {'key': 'properties.units', 'type': 'float'}, + 'unit_type': {'key': 'properties.unitType', 'type': 'str'}, + } + + def __init__( + self, + *, + kind: Optional[Union[str, "TransactionTypeKind"]] = None, + transaction_type: Optional[Union[str, "ReservationType"]] = None, + **kwargs + ): + super(Transaction, self).__init__(**kwargs) + self.kind = kind + self.date = None + self.invoice = None + self.invoice_id = None + self.order_id = None + self.order_name = None + self.product_family = None + self.product_type_id = None + self.product_type = None + self.product_description = None + self.transaction_type = transaction_type + self.transaction_amount = None + self.quantity = None + self.invoice_section_id = None + self.invoice_section_display_name = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.customer_id = None + self.customer_display_name = None + self.subscription_id = None + self.subscription_name = None + self.azure_plan = None + self.azure_credit_applied = None + self.billing_currency = None + self.discount = None + self.effective_price = None + self.exchange_rate = None + self.market_price = None + self.pricing_currency = None + self.service_period_start_date = None + self.service_period_end_date = None + self.sub_total = None + self.tax = None + self.unit_of_measure = None + self.units = None + self.unit_type = None + + +class TransactionListResult(msrest.serialization.Model): + """The list of transactions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of transactions. + :vartype value: list[~billing_management_client.models.Transaction] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Transaction]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TransactionListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class TransferBillingSubscriptionRequestProperties(msrest.serialization.Model): + """Request parameters to transfer billing subscription. + + All required parameters must be populated in order to send to Azure. + + :param destination_invoice_section_id: Required. The destination invoice section id. + :type destination_invoice_section_id: str + """ + + _validation = { + 'destination_invoice_section_id': {'required': True}, + } + + _attribute_map = { + 'destination_invoice_section_id': {'key': 'destinationInvoiceSectionId', 'type': 'str'}, + } + + def __init__( + self, + *, + destination_invoice_section_id: str, + **kwargs + ): + super(TransferBillingSubscriptionRequestProperties, self).__init__(**kwargs) + self.destination_invoice_section_id = destination_invoice_section_id + + +class TransferProductRequestProperties(msrest.serialization.Model): + """The properties of the product to initiate a transfer. + + :param destination_invoice_section_id: The 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: Optional[str] = None, + **kwargs + ): + super(TransferProductRequestProperties, self).__init__(**kwargs) + self.destination_invoice_section_id = destination_invoice_section_id + + +class ValidateAddressResponse(msrest.serialization.Model): + """Result of the address validation. + + :param status: status of the address validation. Possible values include: "Valid", "Invalid". + :type status: str or ~billing_management_client.models.AddressValidationStatus + :param suggested_addresses: The list of suggested addresses. + :type suggested_addresses: list[~billing_management_client.models.AddressDetails] + :param validation_message: Validation error message. + :type validation_message: str + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'suggested_addresses': {'key': 'suggestedAddresses', 'type': '[AddressDetails]'}, + 'validation_message': {'key': 'validationMessage', 'type': 'str'}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "AddressValidationStatus"]] = None, + suggested_addresses: Optional[List["AddressDetails"]] = None, + validation_message: Optional[str] = None, + **kwargs + ): + super(ValidateAddressResponse, self).__init__(**kwargs) + self.status = status + self.suggested_addresses = suggested_addresses + self.validation_message = validation_message + + +class ValidateProductTransferEligibilityError(msrest.serialization.Model): + """Error details of the product transfer eligibility validation. + + :param code: Error code for the product transfer validation. Possible values include: + "InvalidSource", "ProductNotActive", "InsufficientPermissionOnSource", + "InsufficientPermissionOnDestination", "DestinationBillingProfilePastDue", + "ProductTypeNotSupported", "CrossBillingAccountNotAllowed", "NotAvailableForDestinationMarket", + "OneTimePurchaseProductTransferNotAllowed". + :type code: str or ~billing_management_client.models.ProductTransferValidationErrorCode + :param message: The error message. + :type message: str + :param details: Detailed error message explaining the error. + :type details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[Union[str, "ProductTransferValidationErrorCode"]] = None, + message: Optional[str] = None, + details: Optional[str] = None, + **kwargs + ): + super(ValidateProductTransferEligibilityError, self).__init__(**kwargs) + self.code = code + self.message = message + self.details = details + + +class ValidateProductTransferEligibilityResult(msrest.serialization.Model): + """Result of the product transfer eligibility validation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar is_move_eligible: Specifies whether the transfer is eligible or not. + :vartype is_move_eligible: bool + :param error_details: Validation error details. + :type error_details: ~billing_management_client.models.ValidateProductTransferEligibilityError + """ + + _validation = { + 'is_move_eligible': {'readonly': True}, + } + + _attribute_map = { + 'is_move_eligible': {'key': 'isMoveEligible', 'type': 'bool'}, + 'error_details': {'key': 'errorDetails', 'type': 'ValidateProductTransferEligibilityError'}, + } + + def __init__( + self, + *, + error_details: Optional["ValidateProductTransferEligibilityError"] = None, + **kwargs + ): + super(ValidateProductTransferEligibilityResult, self).__init__(**kwargs) + self.is_move_eligible = None + self.error_details = error_details + + +class ValidateSubscriptionTransferEligibilityError(msrest.serialization.Model): + """Error details of the transfer eligibility validation. + + :param code: Error code for the product transfer validation. Possible values include: + "BillingAccountInactive", "CrossBillingAccountNotAllowed", "DestinationBillingProfileInactive", + "DestinationBillingProfileNotFound", "DestinationBillingProfilePastDue", + "DestinationInvoiceSectionInactive", "DestinationInvoiceSectionNotFound", + "InsufficientPermissionOnDestination", "InsufficientPermissionOnSource", "InvalidDestination", + "InvalidSource", "MarketplaceNotEnabledOnDestination", "NotAvailableForDestinationMarket", + "ProductInactive", "ProductNotFound", "ProductTypeNotSupported", "SourceBillingProfilePastDue", + "SourceInvoiceSectionInactive", "SubscriptionNotActive", "SubscriptionTypeNotSupported". + :type code: str or ~billing_management_client.models.SubscriptionTransferValidationErrorCode + :param message: The error message. + :type message: str + :param details: Detailed error message explaining the error. + :type details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[Union[str, "SubscriptionTransferValidationErrorCode"]] = None, + message: Optional[str] = None, + details: Optional[str] = None, + **kwargs + ): + super(ValidateSubscriptionTransferEligibilityError, self).__init__(**kwargs) + self.code = code + self.message = message + self.details = details + + +class ValidateSubscriptionTransferEligibilityResult(msrest.serialization.Model): + """Result of the transfer eligibility validation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar is_move_eligible: Specifies whether the subscription is eligible to be transferred. + :vartype is_move_eligible: bool + :param error_details: Validation error details. + :type error_details: + ~billing_management_client.models.ValidateSubscriptionTransferEligibilityError + """ + + _validation = { + 'is_move_eligible': {'readonly': True}, + } + + _attribute_map = { + 'is_move_eligible': {'key': 'isMoveEligible', 'type': 'bool'}, + 'error_details': {'key': 'errorDetails', 'type': 'ValidateSubscriptionTransferEligibilityError'}, + } + + def __init__( + self, + *, + error_details: Optional["ValidateSubscriptionTransferEligibilityError"] = None, + **kwargs + ): + super(ValidateSubscriptionTransferEligibilityResult, self).__init__(**kwargs) + self.is_move_eligible = None + self.error_details = error_details diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/__init__.py b/src/billing/azext_billing/vendored_sdks/billing/operations/__init__.py new file mode 100644 index 00000000000..34c9bbb2242 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/__init__.py @@ -0,0 +1,51 @@ +# 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 ._billing_accounts_operations import BillingAccountsOperations +from ._address_operations import AddressOperations +from ._available_balances_operations import AvailableBalancesOperations +from ._instructions_operations import InstructionsOperations +from ._billing_profiles_operations import BillingProfilesOperations +from ._customers_operations import CustomersOperations +from ._invoice_sections_operations import InvoiceSectionsOperations +from ._billing_permissions_operations import BillingPermissionsOperations +from ._billing_subscriptions_operations import BillingSubscriptionsOperations +from ._products_operations import ProductsOperations +from ._invoices_operations import InvoicesOperations +from ._transactions_operations import TransactionsOperations +from ._policies_operations import PoliciesOperations +from ._billing_property_operations import BillingPropertyOperations +from ._operations import Operations +from ._billing_role_definitions_operations import BillingRoleDefinitionsOperations +from ._billing_role_assignments_operations import BillingRoleAssignmentsOperations +from ._agreements_operations import AgreementsOperations +from ._enrollment_accounts_operations import EnrollmentAccountsOperations +from ._billing_periods_operations import BillingPeriodsOperations + +__all__ = [ + 'BillingAccountsOperations', + 'AddressOperations', + 'AvailableBalancesOperations', + 'InstructionsOperations', + 'BillingProfilesOperations', + 'CustomersOperations', + 'InvoiceSectionsOperations', + 'BillingPermissionsOperations', + 'BillingSubscriptionsOperations', + 'ProductsOperations', + 'InvoicesOperations', + 'TransactionsOperations', + 'PoliciesOperations', + 'BillingPropertyOperations', + 'Operations', + 'BillingRoleDefinitionsOperations', + 'BillingRoleAssignmentsOperations', + 'AgreementsOperations', + 'EnrollmentAccountsOperations', + 'BillingPeriodsOperations', +] diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_address_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_address_operations.py new file mode 100644 index 00000000000..6bc1297d3d0 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_address_operations.py @@ -0,0 +1,102 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AddressOperations(object): + """AddressOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def validate( + self, + address, # type: "models.AddressDetails" + **kwargs # type: Any + ): + # type: (...) -> "models.ValidateAddressResponse" + """Validates an address. Use the operation to validate an address before using it as soldTo or a + billTo address. + + :param address: + :type address: ~billing_management_client.models.AddressDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ValidateAddressResponse, or the result of cls(response) + :rtype: ~billing_management_client.models.ValidateAddressResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ValidateAddressResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.validate.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(address, 'AddressDetails') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ValidateAddressResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/providers/Microsoft.Billing/validateAddress'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_agreements_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_agreements_operations.py new file mode 100644 index 00000000000..7363e154a84 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_agreements_operations.py @@ -0,0 +1,186 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AgreementsOperations(object): + """AgreementsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_account( + self, + billing_account_name, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.AgreementListResult"] + """Lists the agreements for a billing account. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param expand: May be used to expand the participants. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AgreementListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.AgreementListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AgreementListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AgreementListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements'} # type: ignore + + def get( + self, + billing_account_name, # type: str + agreement_name, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Agreement" + """Gets an agreement by ID. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param agreement_name: The ID that uniquely identifies an agreement. + :type agreement_name: str + :param expand: May be used to expand the participants. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Agreement, or the result of cls(response) + :rtype: ~billing_management_client.models.Agreement + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Agreement"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'agreementName': self._serialize.url("agreement_name", agreement_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Agreement', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_available_balances_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_available_balances_operations.py new file mode 100644 index 00000000000..2e0f34e5456 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_available_balances_operations.py @@ -0,0 +1,106 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AvailableBalancesOperations(object): + """AvailableBalancesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.AvailableBalance" + """The available credit balance for a billing profile. This is the balance that can be used for + pay now to settle due or past due invoices. The operation is supported only for billing + accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailableBalance, or the result of cls(response) + :rtype: ~billing_management_client.models.AvailableBalance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AvailableBalance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AvailableBalance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_accounts_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_accounts_operations.py new file mode 100644 index 00000000000..80ba3f6eb9f --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_accounts_operations.py @@ -0,0 +1,373 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingAccountsOperations(object): + """BillingAccountsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingAccountListResult"] + """Lists the billing accounts that a user has access to. + + :param expand: May be used to expand the soldTo, invoice sections and billing profiles. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingAccountListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingAccountListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts'} # type: ignore + + def get( + self, + billing_account_name, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.BillingAccount" + """Gets a billing account by its ID. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param expand: May be used to expand the soldTo, invoice sections and billing profiles. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingAccount, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + def _update_initial( + self, + billing_account_name, # type: str + parameters, # type: "models.BillingAccountUpdateRequest" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.BillingAccount"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.BillingAccount"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingAccountUpdateRequest') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('BillingAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + def begin_update( + self, + billing_account_name, # type: str + parameters, # type: "models.BillingAccountUpdateRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.BillingAccount"] + """Updates the properties of a billing account. Currently, displayName and address can be updated. + The operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the update billing account + operation. + :type parameters: ~billing_management_client.models.BillingAccountUpdateRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either BillingAccount or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.BillingAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingAccount"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + billing_account_name=billing_account_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('BillingAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + def list_invoice_sections_by_create_subscription_permission( + self, + billing_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.InvoiceSectionListWithCreateSubPermissionResult"] + """Lists the invoice sections for which the user has permission to create Azure subscriptions. The + operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceSectionListWithCreateSubPermissionResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.InvoiceSectionListWithCreateSubPermissionResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSectionListWithCreateSubPermissionResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_invoice_sections_by_create_subscription_permission.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceSectionListWithCreateSubPermissionResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_invoice_sections_by_create_subscription_permission.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_periods_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_periods_operations.py new file mode 100644 index 00000000000..b11fc301c5f --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_periods_operations.py @@ -0,0 +1,193 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingPeriodsOperations(object): + """BillingPeriodsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + filter=None, # type: Optional[str] + skiptoken=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingPeriodsListResult"] + """Lists the available billing periods for a subscription in reverse chronological order. This is + only supported for Azure Web-Direct subscriptions. Other subscription types which were not + purchased directly through the Azure web portal are not supported through this preview API. + + :param filter: May be used to filter billing periods by billingPeriodEndDate. The filter + supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + 'not'. + :type filter: str + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: str + :param top: May be used to limit the number of results to the most recent N billing periods. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPeriodsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingPeriodsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPeriodsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=100, minimum=1) + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPeriodsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods'} # type: ignore + + def get( + self, + billing_period_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingPeriod" + """Gets a named billing period. This is only supported for Azure Web-Direct subscriptions. Other + subscription types which were not purchased directly through the Azure web portal are not + supported through this preview API. + + :param billing_period_name: The name of a BillingPeriod resource. + :type billing_period_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingPeriod, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingPeriod + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPeriod"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingPeriod', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_permissions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_permissions_operations.py new file mode 100644 index 00000000000..d394c8dc05b --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_permissions_operations.py @@ -0,0 +1,346 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingPermissionsOperations(object): + """BillingPermissionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_customer( + self, + billing_account_name, # type: str + customer_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingPermissionsListResult"] + """Lists the billing permissions the caller has for a customer. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/{billingAccountName}/customers/{customerName}/billingPermissions'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingPermissionsListResult"] + """Lists the billing permissions the caller has on a billing account. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions'} # type: ignore + + def list_by_invoice_sections( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingPermissionsListResult"] + """Lists the billing permissions the caller has on an invoice section. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_sections.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_invoice_sections.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingPermissionsListResult"] + """Lists the billing permissions the caller has on a billing profile. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingPermissionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingPermissionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingPermissionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingPermissions'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_profiles_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_profiles_operations.py new file mode 100644 index 00000000000..cf282170fa1 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_profiles_operations.py @@ -0,0 +1,323 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingProfilesOperations(object): + """BillingProfilesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_account( + self, + billing_account_name, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingProfileListResult"] + """Lists the billing profiles that a user has access to. The operation is supported for billing + accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param expand: May be used to expand the invoice sections. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingProfileListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingProfileListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProfileListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingProfileListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles'} # type: ignore + + def get( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.BillingProfile" + """Gets a billing profile by its ID. The operation is supported for billing accounts with + agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param expand: May be used to expand the invoice sections. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingProfile, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + + def _create_or_update_initial( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + parameters, # type: "models.BillingProfile" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.BillingProfile"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.BillingProfile"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingProfile') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('BillingProfile', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + + def begin_create_or_update( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + parameters, # type: "models.BillingProfile" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.BillingProfile"] + """Creates or updates a billing profile. The operation is supported for billing accounts with + agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param parameters: The new or updated billing profile. + :type parameters: ~billing_management_client.models.BillingProfile + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either BillingProfile or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.BillingProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProfile"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('BillingProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_property_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_property_operations.py new file mode 100644 index 00000000000..f1c099bb219 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_property_operations.py @@ -0,0 +1,161 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingPropertyOperations(object): + """BillingPropertyOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.BillingProperty" + """Get the billing properties for a subscription. This operation is not supported for billing + accounts with agreement type Enterprise Agreement. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingProperty, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProperty"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingProperty', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore + + def update( + self, + parameters, # type: "models.BillingProperty" + **kwargs # type: Any + ): + # type: (...) -> "models.BillingProperty" + """Updates the billing property of a subscription. Currently, cost center can be updated. The + operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param parameters: Request parameters that are provided to the update billing property + operation. + :type parameters: ~billing_management_client.models.BillingProperty + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingProperty, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingProperty"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingProperty') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingProperty', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_assignments_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_assignments_operations.py new file mode 100644 index 00000000000..d93059f9a48 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_assignments_operations.py @@ -0,0 +1,663 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingRoleAssignmentsOperations(object): + """BillingRoleAssignmentsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_by_billing_account( + self, + billing_account_name, # type: str + billing_role_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleAssignment" + """Gets a role assignment for the caller on a billing account. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + def delete_by_billing_account( + self, + billing_account_name, # type: str + billing_role_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleAssignment" + """Deletes a role assignment for the caller on a billing account. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + def get_by_invoice_section( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + billing_role_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleAssignment" + """Gets a role assignment for the caller on an invoice section. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + def delete_by_invoice_section( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + billing_role_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleAssignment" + """Deletes a role assignment for the caller on an invoice section. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + def get_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + billing_role_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleAssignment" + """Gets a role assignment for the caller on a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + def delete_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + billing_role_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleAssignment" + """Deletes a role assignment for the caller on a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param billing_role_assignment_name: The ID that uniquely identifies a role assignment. + :type billing_role_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleAssignment, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingRoleAssignmentListResult"] + """Lists the role assignments for the caller on a billing account. The operation is supported for + billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingRoleAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleAssignmentListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingRoleAssignmentListResult"] + """Lists the role assignments for the caller on an invoice section. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingRoleAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleAssignmentListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingRoleAssignmentListResult"] + """Lists the role assignments for the caller on a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingRoleAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleAssignmentListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_definitions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_definitions_operations.py new file mode 100644 index 00000000000..4bbfc7732e7 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_role_definitions_operations.py @@ -0,0 +1,466 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingRoleDefinitionsOperations(object): + """BillingRoleDefinitionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_by_billing_account( + self, + billing_account_name, # type: str + billing_role_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleDefinition" + """Gets the definition for a role on a billing account. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_role_definition_name: The ID that uniquely identifies a role definition. + :type billing_role_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleDefinition, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + def get_by_invoice_section( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + billing_role_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleDefinition" + """Gets the definition for a role on an invoice section. The operation is supported only for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param billing_role_definition_name: The ID that uniquely identifies a role definition. + :type billing_role_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleDefinition, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + def get_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + billing_role_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingRoleDefinition" + """Gets the definition for a role on a billing profile. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param billing_role_definition_name: The ID that uniquely identifies a role definition. + :type billing_role_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingRoleDefinition, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingRoleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingRoleDefinitionListResult"] + """Lists the role definitions for a billing account. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingRoleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleDefinitionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingRoleDefinitionListResult"] + """Lists the role definitions for an invoice section. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingRoleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleDefinitionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingRoleDefinitionListResult"] + """Lists the role definitions for a billing profile. The operation is supported for billing + accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingRoleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingRoleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingRoleDefinitionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_subscriptions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_subscriptions_operations.py new file mode 100644 index 00000000000..174eb1892b8 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_billing_subscriptions_operations.py @@ -0,0 +1,672 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class BillingSubscriptionsOperations(object): + """BillingSubscriptionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_customer( + self, + billing_account_name, # type: str + customer_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingSubscriptionsListResult"] + """Lists the subscriptions for a customer. The operation is supported only for billing accounts + with agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/{billingAccountName}/customers/{customerName}/billingSubscriptions'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingSubscriptionsListResult"] + """Lists the subscriptions for a billing account. The operation is supported for billing accounts + with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingSubscriptionsListResult"] + """Lists the subscriptions that are billed to a billing profile. The operation is supported for + billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BillingSubscriptionsListResult"] + """Lists the subscriptions that are billed to an invoice section. The operation is supported only + for billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.BillingSubscriptionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscriptionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('BillingSubscriptionsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingSubscriptions'} # type: ignore + + def get( + self, + billing_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BillingSubscription" + """Gets a subscription by its ID. The operation is supported for billing accounts with agreement + type Microsoft Customer Agreement and Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingSubscription, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingSubscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + + def update( + self, + billing_account_name, # type: str + parameters, # type: "models.BillingSubscription" + **kwargs # type: Any + ): + # type: (...) -> "models.BillingSubscription" + """Updates the properties of a billing subscription. Currently, cost center can be updated. The + operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the update billing subscription + operation. + :type parameters: ~billing_management_client.models.BillingSubscription + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingSubscription, or the result of cls(response) + :rtype: ~billing_management_client.models.BillingSubscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BillingSubscription') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + + def _move_initial( + self, + billing_account_name, # type: str + parameters, # type: "models.TransferBillingSubscriptionRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.BillingSubscription"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.BillingSubscription"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._move_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _move_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + + def begin_move( + self, + billing_account_name, # type: str + parameters, # type: "models.TransferBillingSubscriptionRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.BillingSubscription"] + """Moves a subscription's charges to a new invoice section. The new invoice section must belong to + the same billing profile as the existing invoice section. This operation is supported for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the move subscription operation. + :type parameters: ~billing_management_client.models.TransferBillingSubscriptionRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either BillingSubscription or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.BillingSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.BillingSubscription"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._move_initial( + billing_account_name=billing_account_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('BillingSubscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + + def validate_move( + self, + billing_account_name, # type: str + parameters, # type: "models.TransferBillingSubscriptionRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.ValidateSubscriptionTransferEligibilityResult" + """Validates if a subscription's charges can be moved to a new invoice section. This operation is + supported for billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param parameters: Request parameters that are provided to the validate move eligibility + operation. + :type parameters: ~billing_management_client.models.TransferBillingSubscriptionRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ValidateSubscriptionTransferEligibilityResult, or the result of cls(response) + :rtype: ~billing_management_client.models.ValidateSubscriptionTransferEligibilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ValidateSubscriptionTransferEligibilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.validate_move.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ValidateSubscriptionTransferEligibilityResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/validateMoveEligibility'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_customers_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_customers_operations.py new file mode 100644 index 00000000000..56a32d464e3 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_customers_operations.py @@ -0,0 +1,281 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CustomersOperations(object): + """CustomersOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + search=None, # type: Optional[str] + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CustomerListResult"] + """Lists the customers that are billed to a billing profile. The operation is supported only for + billing accounts with agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param search: Used for searching customers by their name. Any customer with name containing + the search text will be included in the response. + :type search: str + :param filter: May be used to filter the list of customers. + :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 CustomerListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.CustomerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if search is not None: + query_parameters['$search'] = self._serialize.query("search", search, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CustomerListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name, # type: str + search=None, # type: Optional[str] + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CustomerListResult"] + """Lists the customers that are billed to a billing account. The operation is supported only for + billing accounts with agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param search: Used for searching customers by their name. Any customer with name containing + the search text will be included in the response. + :type search: str + :param filter: May be used to filter the list of customers. + :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 CustomerListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.CustomerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if search is not None: + query_parameters['$search'] = self._serialize.query("search", search, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CustomerListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers'} # type: ignore + + def get( + self, + billing_account_name, # type: str + customer_name, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Customer" + """Gets a customer by its ID. The operation is supported only for billing accounts with agreement + type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :param expand: May be used to expand enabledAzurePlans and resellers. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Customer, or the result of cls(response) + :rtype: ~billing_management_client.models.Customer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Customer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Customer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_enrollment_accounts_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_enrollment_accounts_operations.py new file mode 100644 index 00000000000..c2a97744dc2 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_enrollment_accounts_operations.py @@ -0,0 +1,165 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class EnrollmentAccountsOperations(object): + """EnrollmentAccountsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.EnrollmentAccountListResult"] + """Lists the enrollment accounts the caller has access to. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EnrollmentAccountListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.EnrollmentAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EnrollmentAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('EnrollmentAccountListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts'} # type: ignore + + def get( + self, + name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.EnrollmentAccountSummary" + """Gets a enrollment account by name. + + :param name: Enrollment Account name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EnrollmentAccountSummary, or the result of cls(response) + :rtype: ~billing_management_client.models.EnrollmentAccountSummary + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EnrollmentAccountSummary"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'name': self._serialize.url("name", name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EnrollmentAccountSummary', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{name}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_instructions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_instructions_operations.py new file mode 100644 index 00000000000..a8ecb74e015 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_instructions_operations.py @@ -0,0 +1,257 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class InstructionsOperations(object): + """InstructionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.InstructionListResult"] + """Lists the instructions by billing profile id. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InstructionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.InstructionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InstructionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('InstructionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions'} # type: ignore + + def get( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + instruction_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Instruction" + """Get the instruction by name. These are custom billing instructions and are only applicable for + certain customers. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param instruction_name: Instruction Name. + :type instruction_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Instruction, or the result of cls(response) + :rtype: ~billing_management_client.models.Instruction + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Instruction"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Instruction', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore + + def put( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + instruction_name, # type: str + parameters, # type: "models.Instruction" + **kwargs # type: Any + ): + # type: (...) -> "models.Instruction" + """Creates or updates an instruction. These are custom billing instructions and are only + applicable for certain customers. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param instruction_name: Instruction Name. + :type instruction_name: str + :param parameters: The new instruction. + :type parameters: ~billing_management_client.models.Instruction + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Instruction, or the result of cls(response) + :rtype: ~billing_management_client.models.Instruction + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Instruction"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.put.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Instruction') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Instruction', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + put.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_invoice_sections_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_invoice_sections_operations.py new file mode 100644 index 00000000000..f7c393f8967 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_invoice_sections_operations.py @@ -0,0 +1,328 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class InvoiceSectionsOperations(object): + """InvoiceSectionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.InvoiceSectionListResult"] + """Lists the invoice sections that a user has access to. The operation is supported only for + billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceSectionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.InvoiceSectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceSectionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections'} # type: ignore + + def get( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.InvoiceSection" + """Gets an invoice section by its ID. The operation is supported only for billing accounts with + agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InvoiceSection, or the result of cls(response) + :rtype: ~billing_management_client.models.InvoiceSection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('InvoiceSection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + + def _create_or_update_initial( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + parameters, # type: "models.InvoiceSection" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.InvoiceSection"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.InvoiceSection"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'InvoiceSection') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('InvoiceSection', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + + def begin_create_or_update( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + parameters, # type: "models.InvoiceSection" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.InvoiceSection"] + """Creates or updates an invoice section. The operation is supported only for billing accounts + with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param parameters: The new or updated invoice section. + :type parameters: ~billing_management_client.models.InvoiceSection + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either InvoiceSection or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.InvoiceSection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceSection"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('InvoiceSection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_invoices_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_invoices_operations.py new file mode 100644 index 00000000000..4f86fc7b81c --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_invoices_operations.py @@ -0,0 +1,966 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class InvoicesOperations(object): + """InvoicesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_billing_account( + self, + billing_account_name, # type: str + period_start_date, # type: str + period_end_date, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.InvoiceListResult"] + """Lists the invoices for a billing account for a given start date and end date. The operation is + supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft + Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param period_start_date: The start date to fetch the invoices. The date should be specified in + MM-DD-YYYY format. + :type period_start_date: str + :param period_end_date: The end date to fetch the invoices. The date should be specified in MM- + DD-YYYY format. + :type period_end_date: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.InvoiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + period_start_date, # type: str + period_end_date, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.InvoiceListResult"] + """Lists the invoices for a billing profile for a given start date and end date. The operation is + supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft + Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param period_start_date: The start date to fetch the invoices. The date should be specified in + MM-DD-YYYY format. + :type period_start_date: str + :param period_end_date: The end date to fetch the invoices. The date should be specified in MM- + DD-YYYY format. + :type period_end_date: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.InvoiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices'} # type: ignore + + def get( + self, + billing_account_name, # type: str + invoice_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Invoice" + """Gets an invoice by billing account name and ID. The operation is supported for billing accounts + with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Invoice, or the result of cls(response) + :rtype: ~billing_management_client.models.Invoice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Invoice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Invoice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}'} # type: ignore + + def get_by_id( + self, + invoice_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Invoice" + """Gets an invoice by ID. The operation is supported for billing accounts with agreement type + Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Invoice, or the result of cls(response) + :rtype: ~billing_management_client.models.Invoice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Invoice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Invoice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}'} # type: ignore + + def _download_invoice_initial( + self, + billing_account_name, # type: str + invoice_name, # type: str + download_token, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["models.DownloadUrl"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self._download_invoice_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore + + def begin_download_invoice( + self, + billing_account_name, # type: str + invoice_name, # type: str + download_token, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.DownloadUrl"] + """Gets a URL to download an invoice. The operation is supported for billing accounts with + agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :param download_token: Download token with document source and document ID. + :type download_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._download_invoice_initial( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + download_token=download_token, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore + + def _download_multiple_billing_profile_invoices_initial( + self, + billing_account_name, # type: str + download_urls, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.DownloadUrl"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._download_multiple_billing_profile_invoices_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(download_urls, '[str]') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_multiple_billing_profile_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + + def begin_download_multiple_billing_profile_invoices( + self, + billing_account_name, # type: str + download_urls, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.DownloadUrl"] + """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as + a zip file. The operation is supported for billing accounts with agreement type Microsoft + Partner Agreement or Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param download_urls: An array of download urls for individual documents. + :type download_urls: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._download_multiple_billing_profile_invoices_initial( + billing_account_name=billing_account_name, + download_urls=download_urls, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_profile_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + + def list_by_billing_subscription( + self, + period_start_date, # type: str + period_end_date, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.InvoiceListResult"] + """Lists the invoices for a subscription. + + :param period_start_date: Invoice period start date. + :type period_start_date: str + :param period_end_date: Invoice period end date. + :type period_end_date: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InvoiceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.InvoiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.InvoiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('InvoiceListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices'} # type: ignore + + def get_by_subscription_and_invoice_id( + self, + invoice_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Invoice" + """Gets an invoice by subscription ID and invoice ID. + + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Invoice, or the result of cls(response) + :rtype: ~billing_management_client.models.Invoice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Invoice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_subscription_and_invoice_id.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Invoice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_subscription_and_invoice_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}'} # type: ignore + + def _download_billing_subscription_invoice_initial( + self, + invoice_name, # type: str + download_token, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["models.DownloadUrl"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self._download_billing_subscription_invoice_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_billing_subscription_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore + + def begin_download_billing_subscription_invoice( + self, + invoice_name, # type: str + download_token, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.DownloadUrl"] + """Gets a URL to download an invoice. + + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :param download_token: Download token with document source and document ID. + :type download_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._download_billing_subscription_invoice_initial( + invoice_name=invoice_name, + download_token=download_token, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_billing_subscription_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore + + def _download_multiple_billing_subscription_invoices_initial( + self, + download_urls, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.DownloadUrl"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DownloadUrl"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._download_multiple_billing_subscription_invoices_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(download_urls, '[str]') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _download_multiple_billing_subscription_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore + + def begin_download_multiple_billing_subscription_invoices( + self, + download_urls, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.DownloadUrl"] + """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as + a zip file. + + :param download_urls: An array of download urls for individual documents. + :type download_urls: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~billing_management_client.models.DownloadUrl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DownloadUrl"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._download_multiple_billing_subscription_invoices_initial( + download_urls=download_urls, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DownloadUrl', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_subscription_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_operations.py new file mode 100644 index 00000000000..a8b6aab9cb2 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_operations.py @@ -0,0 +1,110 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] + """Lists the available billing REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Billing/operations'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_policies_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_policies_operations.py new file mode 100644 index 00000000000..9e03accaf91 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_policies_operations.py @@ -0,0 +1,301 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class PoliciesOperations(object): + """PoliciesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Policy" + """Lists the policies for a billing profile. This operation is supported only for billing accounts + with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Policy, or the result of cls(response) + :rtype: ~billing_management_client.models.Policy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Policy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Policy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + def update( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + parameters, # type: "models.Policy" + **kwargs # type: Any + ): + # type: (...) -> "models.Policy" + """Updates the policies for a billing profile. This operation is supported only for billing + accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param parameters: Request parameters that are provided to the update policies operation. + :type parameters: ~billing_management_client.models.Policy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Policy, or the result of cls(response) + :rtype: ~billing_management_client.models.Policy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Policy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Policy') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Policy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + def get_by_customer( + self, + billing_account_name, # type: str + customer_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CustomerPolicy" + """Lists the policies for a customer. This operation is supported only for billing accounts with + agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomerPolicy, or the result of cls(response) + :rtype: ~billing_management_client.models.CustomerPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomerPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore + + def update_customer( + self, + billing_account_name, # type: str + customer_name, # type: str + parameters, # type: "models.CustomerPolicy" + **kwargs # type: Any + ): + # type: (...) -> "models.CustomerPolicy" + """Updates the policies for a customer. This operation is supported only for billing accounts with + agreement type Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :param parameters: Request parameters that are provided to the update policies operation. + :type parameters: ~billing_management_client.models.CustomerPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomerPolicy, or the result of cls(response) + :rtype: ~billing_management_client.models.CustomerPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomerPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'CustomerPolicy') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomerPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_products_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_products_operations.py new file mode 100644 index 00000000000..7641f60cf59 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_products_operations.py @@ -0,0 +1,650 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ProductsOperations(object): + """ProductsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_customer( + self, + billing_account_name, # type: str + customer_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProductsListResult"] + """Lists the products for a customer. These don't include products billed based on usage.The + operation is supported only for billing accounts with agreement type Microsoft Partner + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param customer_name: The ID that uniquely identifies a customer. + :type customer_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_customer.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'customerName': self._serialize.url("customer_name", customer_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/{billingAccountName}/customers/{customerName}/products'} # type: ignore + + def list_by_billing_account( + self, + billing_account_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProductsListResult"] + """Lists the products for a billing account. These don't include products billed based on usage. + The operation is supported for billing accounts with agreement type Microsoft Customer + Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param filter: May be used to filter by product type. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key + value pair string where key and value are 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 ProductsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products'} # type: ignore + + def list_by_billing_profile( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProductsListResult"] + """Lists the products for a billing profile. These don't include products billed based on usage. + The operation is supported for billing accounts with agreement type Microsoft Customer + Agreement or Microsoft Partner Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param filter: May be used to filter by product type. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key + value pair string where key and value are 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 ProductsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_billing_profile.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/products'} # type: ignore + + def list_by_invoice_section( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProductsListResult"] + """Lists the products for an invoice section. These don't include products billed based on usage. + The operation is supported only for billing accounts with agreement type Microsoft Customer + Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param billing_profile_name: The ID that uniquely identifies a billing profile. + :type billing_profile_name: str + :param invoice_section_name: The ID that uniquely identifies an invoice section. + :type invoice_section_name: str + :param filter: May be used to filter by product type. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key + value pair string where key and value are 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 ProductsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.ProductsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice_section.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), + 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductsListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/products'} # type: ignore + + def get( + self, + billing_account_name, # type: str + product_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Product" + """Gets a product by ID. The operation is supported only for billing accounts with agreement type + Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~billing_management_client.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Product', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + def update( + self, + billing_account_name, # type: str + product_name, # type: str + parameters, # type: "models.Product" + **kwargs # type: Any + ): + # type: (...) -> "models.Product" + """Updates the properties of a Product. Currently, auto renew can be updated. The operation is + supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :param parameters: Request parameters that are provided to the update product operation. + :type parameters: ~billing_management_client.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~billing_management_client.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Product') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Product', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + def move( + self, + billing_account_name, # type: str + product_name, # type: str + parameters, # type: "models.TransferProductRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.Product"] + """Moves a product's charges to a new invoice section. The new invoice section must belong to the + same billing profile as the existing invoice section. This operation is supported only for + products that are purchased with a recurring charge and for billing accounts with agreement + type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :param parameters: Request parameters that are provided to the move product operation. + :type parameters: ~billing_management_client.models.TransferProductRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~billing_management_client.models.Product or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.move.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Product', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move'} # type: ignore + + def validate_move( + self, + billing_account_name, # type: str + product_name, # type: str + parameters, # type: "models.TransferProductRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.ValidateProductTransferEligibilityResult" + """Validates if a product's charges can be moved to a new invoice section. This operation is + supported only for products that are purchased with a recurring charge and for billing accounts + with agreement type Microsoft Customer Agreement. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param product_name: The ID that uniquely identifies a product. + :type product_name: str + :param parameters: Request parameters that are provided to the validate move eligibility + operation. + :type parameters: ~billing_management_client.models.TransferProductRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ValidateProductTransferEligibilityResult, or the result of cls(response) + :rtype: ~billing_management_client.models.ValidateProductTransferEligibilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ValidateProductTransferEligibilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.validate_move.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'productName': self._serialize.url("product_name", product_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ValidateProductTransferEligibilityResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/operations/_transactions_operations.py b/src/billing/azext_billing/vendored_sdks/billing/operations/_transactions_operations.py new file mode 100644 index 00000000000..31a83ec8d97 --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/operations/_transactions_operations.py @@ -0,0 +1,122 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TransactionsOperations(object): + """TransactionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~billing_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_invoice( + self, + billing_account_name, # type: str + invoice_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TransactionListResult"] + """Lists the transactions for an invoice. Transactions include purchases, refunds and Azure usage + charges. + + :param billing_account_name: The ID that uniquely identifies a billing account. + :type billing_account_name: str + :param invoice_name: The ID that uniquely identifies an invoice. + :type invoice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TransactionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~billing_management_client.models.TransactionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TransactionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_invoice.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), + 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('TransactionListResult', 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]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactions'} # type: ignore diff --git a/src/billing/azext_billing/vendored_sdks/billing/py.typed b/src/billing/azext_billing/vendored_sdks/billing/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/billing/azext_billing/vendored_sdks/billing/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/billing/report.md b/src/billing/report.md new file mode 100644 index 00000000000..2581bb204aa --- /dev/null +++ b/src/billing/report.md @@ -0,0 +1,931 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az billing|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az billing` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az billing account|BillingAccounts|[commands](#CommandsInBillingAccounts)| +|az billing balance|AvailableBalances|[commands](#CommandsInAvailableBalances)| +|az billing instruction|Instructions|[commands](#CommandsInInstructions)| +|az billing profile|BillingProfiles|[commands](#CommandsInBillingProfiles)| +|az billing customer|Customers|[commands](#CommandsInCustomers)| +|az billing invoice section|InvoiceSections|[commands](#CommandsInInvoiceSections)| +|az billing permission|BillingPermissions|[commands](#CommandsInBillingPermissions)| +|az billing subscription|BillingSubscriptions|[commands](#CommandsInBillingSubscriptions)| +|az billing product|Products|[commands](#CommandsInProducts)| +|az billing invoice|Invoices|[commands](#CommandsInInvoices)| +|az billing transaction|Transactions|[commands](#CommandsInTransactions)| +|az billing policy|Policies|[commands](#CommandsInPolicies)| +|az billing property|BillingProperty|[commands](#CommandsInBillingProperty)| +|az billing role-definition|BillingRoleDefinitions|[commands](#CommandsInBillingRoleDefinitions)| +|az billing role-assignment|BillingRoleAssignments|[commands](#CommandsInBillingRoleAssignments)| +|az billing agreement|Agreements|[commands](#CommandsInAgreements)| + +## COMMANDS +### Commands in `az billing account` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing account list](#BillingAccountsList)|List|[Parameters](#ParametersBillingAccountsList)|[Example](#ExamplesBillingAccountsList)| +|[az billing account show](#BillingAccountsGet)|Get|[Parameters](#ParametersBillingAccountsGet)|[Example](#ExamplesBillingAccountsGet)| +|[az billing account update](#BillingAccountsUpdate)|Update|[Parameters](#ParametersBillingAccountsUpdate)|[Example](#ExamplesBillingAccountsUpdate)| + +### Commands in `az billing agreement` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing agreement list](#AgreementsListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersAgreementsListByBillingAccount)|[Example](#ExamplesAgreementsListByBillingAccount)| +|[az billing agreement show](#AgreementsGet)|Get|[Parameters](#ParametersAgreementsGet)|[Example](#ExamplesAgreementsGet)| + +### Commands in `az billing balance` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing balance show](#AvailableBalancesGet)|Get|[Parameters](#ParametersAvailableBalancesGet)|[Example](#ExamplesAvailableBalancesGet)| + +### Commands in `az billing customer` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing customer list](#CustomersListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersCustomersListByBillingProfile)|[Example](#ExamplesCustomersListByBillingProfile)| +|[az billing customer list](#CustomersListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersCustomersListByBillingAccount)|[Example](#ExamplesCustomersListByBillingAccount)| +|[az billing customer show](#CustomersGet)|Get|[Parameters](#ParametersCustomersGet)|[Example](#ExamplesCustomersGet)| + +### Commands in `az billing instruction` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing instruction list](#InstructionsListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersInstructionsListByBillingProfile)|[Example](#ExamplesInstructionsListByBillingProfile)| +|[az billing instruction show](#InstructionsGet)|Get|[Parameters](#ParametersInstructionsGet)|[Example](#ExamplesInstructionsGet)| +|[az billing instruction create](#InstructionsPut)|Put|[Parameters](#ParametersInstructionsPut)|[Example](#ExamplesInstructionsPut)| + +### Commands in `az billing invoice` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing invoice list](#InvoicesListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersInvoicesListByBillingProfile)|[Example](#ExamplesInvoicesListByBillingProfile)| +|[az billing invoice list](#InvoicesListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersInvoicesListByBillingAccount)|[Example](#ExamplesInvoicesListByBillingAccount)| +|[az billing invoice list](#InvoicesListByBillingSubscription)|ListByBillingSubscription|[Parameters](#ParametersInvoicesListByBillingSubscription)|[Example](#ExamplesInvoicesListByBillingSubscription)| +|[az billing invoice show](#InvoicesGet)|Get|[Parameters](#ParametersInvoicesGet)|[Example](#ExamplesInvoicesGet)| + +### Commands in `az billing invoice section` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing invoice section list](#InvoiceSectionsListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersInvoiceSectionsListByBillingProfile)|[Example](#ExamplesInvoiceSectionsListByBillingProfile)| +|[az billing invoice section show](#InvoiceSectionsGet)|Get|[Parameters](#ParametersInvoiceSectionsGet)|[Example](#ExamplesInvoiceSectionsGet)| +|[az billing invoice section create](#InvoiceSectionsCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersInvoiceSectionsCreateOrUpdate#Create)|[Example](#ExamplesInvoiceSectionsCreateOrUpdate#Create)| +|[az billing invoice section update](#InvoiceSectionsCreateOrUpdate#Update)|CreateOrUpdate#Update|[Parameters](#ParametersInvoiceSectionsCreateOrUpdate#Update)|Not Found| + +### Commands in `az billing permission` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing permission list](#BillingPermissionsListByInvoiceSections)|ListByInvoiceSections|[Parameters](#ParametersBillingPermissionsListByInvoiceSections)|[Example](#ExamplesBillingPermissionsListByInvoiceSections)| +|[az billing permission list](#BillingPermissionsListByCustomer)|ListByCustomer|[Parameters](#ParametersBillingPermissionsListByCustomer)|[Example](#ExamplesBillingPermissionsListByCustomer)| +|[az billing permission list](#BillingPermissionsListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersBillingPermissionsListByBillingProfile)|[Example](#ExamplesBillingPermissionsListByBillingProfile)| +|[az billing permission list](#BillingPermissionsListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersBillingPermissionsListByBillingAccount)|[Example](#ExamplesBillingPermissionsListByBillingAccount)| + +### Commands in `az billing policy` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing policy update](#PoliciesUpdate)|Update|[Parameters](#ParametersPoliciesUpdate)|[Example](#ExamplesPoliciesUpdate)| + +### Commands in `az billing product` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing product list](#ProductsListByInvoiceSection)|ListByInvoiceSection|[Parameters](#ParametersProductsListByInvoiceSection)|[Example](#ExamplesProductsListByInvoiceSection)| +|[az billing product list](#ProductsListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersProductsListByBillingProfile)|[Example](#ExamplesProductsListByBillingProfile)| +|[az billing product list](#ProductsListByCustomer)|ListByCustomer|[Parameters](#ParametersProductsListByCustomer)|[Example](#ExamplesProductsListByCustomer)| +|[az billing product list](#ProductsListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersProductsListByBillingAccount)|[Example](#ExamplesProductsListByBillingAccount)| +|[az billing product show](#ProductsGet)|Get|[Parameters](#ParametersProductsGet)|[Example](#ExamplesProductsGet)| +|[az billing product update](#ProductsUpdate)|Update|[Parameters](#ParametersProductsUpdate)|[Example](#ExamplesProductsUpdate)| +|[az billing product move](#ProductsMove)|Move|[Parameters](#ParametersProductsMove)|[Example](#ExamplesProductsMove)| +|[az billing product validate-move](#ProductsValidateMove)|ValidateMove|[Parameters](#ParametersProductsValidateMove)|[Example](#ExamplesProductsValidateMove)| + +### Commands in `az billing profile` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing profile list](#BillingProfilesListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersBillingProfilesListByBillingAccount)|[Example](#ExamplesBillingProfilesListByBillingAccount)| +|[az billing profile show](#BillingProfilesGet)|Get|[Parameters](#ParametersBillingProfilesGet)|[Example](#ExamplesBillingProfilesGet)| +|[az billing profile create](#BillingProfilesCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersBillingProfilesCreateOrUpdate#Create)|[Example](#ExamplesBillingProfilesCreateOrUpdate#Create)| +|[az billing profile update](#BillingProfilesCreateOrUpdate#Update)|CreateOrUpdate#Update|[Parameters](#ParametersBillingProfilesCreateOrUpdate#Update)|Not Found| + +### Commands in `az billing property` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing property show](#BillingPropertyGet)|Get|[Parameters](#ParametersBillingPropertyGet)|[Example](#ExamplesBillingPropertyGet)| +|[az billing property update](#BillingPropertyUpdate)|Update|[Parameters](#ParametersBillingPropertyUpdate)|[Example](#ExamplesBillingPropertyUpdate)| + +### Commands in `az billing role-assignment` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing role-assignment list](#BillingRoleAssignmentsListByInvoiceSection)|ListByInvoiceSection|[Parameters](#ParametersBillingRoleAssignmentsListByInvoiceSection)|[Example](#ExamplesBillingRoleAssignmentsListByInvoiceSection)| +|[az billing role-assignment list](#BillingRoleAssignmentsListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersBillingRoleAssignmentsListByBillingProfile)|[Example](#ExamplesBillingRoleAssignmentsListByBillingProfile)| +|[az billing role-assignment list](#BillingRoleAssignmentsListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersBillingRoleAssignmentsListByBillingAccount)|[Example](#ExamplesBillingRoleAssignmentsListByBillingAccount)| +|[az billing role-assignment delete](#BillingRoleAssignmentsDeleteByInvoiceSection)|DeleteByInvoiceSection|[Parameters](#ParametersBillingRoleAssignmentsDeleteByInvoiceSection)|[Example](#ExamplesBillingRoleAssignmentsDeleteByInvoiceSection)| +|[az billing role-assignment delete](#BillingRoleAssignmentsDeleteByBillingProfile)|DeleteByBillingProfile|[Parameters](#ParametersBillingRoleAssignmentsDeleteByBillingProfile)|[Example](#ExamplesBillingRoleAssignmentsDeleteByBillingProfile)| +|[az billing role-assignment delete](#BillingRoleAssignmentsDeleteByBillingAccount)|DeleteByBillingAccount|[Parameters](#ParametersBillingRoleAssignmentsDeleteByBillingAccount)|[Example](#ExamplesBillingRoleAssignmentsDeleteByBillingAccount)| + +### Commands in `az billing role-definition` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing role-definition list](#BillingRoleDefinitionsListByInvoiceSection)|ListByInvoiceSection|[Parameters](#ParametersBillingRoleDefinitionsListByInvoiceSection)|[Example](#ExamplesBillingRoleDefinitionsListByInvoiceSection)| +|[az billing role-definition list](#BillingRoleDefinitionsListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersBillingRoleDefinitionsListByBillingProfile)|[Example](#ExamplesBillingRoleDefinitionsListByBillingProfile)| +|[az billing role-definition list](#BillingRoleDefinitionsListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersBillingRoleDefinitionsListByBillingAccount)|[Example](#ExamplesBillingRoleDefinitionsListByBillingAccount)| + +### Commands in `az billing subscription` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing subscription list](#BillingSubscriptionsListByInvoiceSection)|ListByInvoiceSection|[Parameters](#ParametersBillingSubscriptionsListByInvoiceSection)|[Example](#ExamplesBillingSubscriptionsListByInvoiceSection)| +|[az billing subscription list](#BillingSubscriptionsListByCustomer)|ListByCustomer|[Parameters](#ParametersBillingSubscriptionsListByCustomer)|[Example](#ExamplesBillingSubscriptionsListByCustomer)| +|[az billing subscription list](#BillingSubscriptionsListByBillingProfile)|ListByBillingProfile|[Parameters](#ParametersBillingSubscriptionsListByBillingProfile)|[Example](#ExamplesBillingSubscriptionsListByBillingProfile)| +|[az billing subscription list](#BillingSubscriptionsListByBillingAccount)|ListByBillingAccount|[Parameters](#ParametersBillingSubscriptionsListByBillingAccount)|[Example](#ExamplesBillingSubscriptionsListByBillingAccount)| +|[az billing subscription show](#BillingSubscriptionsGet)|Get|[Parameters](#ParametersBillingSubscriptionsGet)|[Example](#ExamplesBillingSubscriptionsGet)| +|[az billing subscription update](#BillingSubscriptionsUpdate)|Update|[Parameters](#ParametersBillingSubscriptionsUpdate)|[Example](#ExamplesBillingSubscriptionsUpdate)| +|[az billing subscription move](#BillingSubscriptionsMove)|Move|[Parameters](#ParametersBillingSubscriptionsMove)|[Example](#ExamplesBillingSubscriptionsMove)| +|[az billing subscription validate-move](#BillingSubscriptionsValidateMove)|ValidateMove|[Parameters](#ParametersBillingSubscriptionsValidateMove)|[Example](#ExamplesBillingSubscriptionsValidateMove)| + +### Commands in `az billing transaction` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az billing transaction list](#TransactionsListByInvoice)|ListByInvoice|[Parameters](#ParametersTransactionsListByInvoice)|[Example](#ExamplesTransactionsListByInvoice)| + + +## COMMAND DETAILS + +### group `az billing account` +#### Command `az billing account list` + +##### Example +``` +az billing account list +``` +##### Example +``` +az billing account list --expand "soldTo,billingProfiles,billingProfiles/invoiceSections" +``` +##### Example +``` +az billing account list --expand "enrollmentDetails,departments,enrollmentAccounts" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--expand**|string|May be used to expand the soldTo, invoice sections and billing profiles.|expand|$expand| + +#### Command `az billing account show` + +##### Example +``` +az billing account show --expand "soldTo,billingProfiles,billingProfiles/invoiceSections" --name \ +"{billingAccountName}" +``` +##### Example +``` +az billing account show --name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--expand**|string|May be used to expand the soldTo, invoice sections and billing profiles.|expand|$expand| + +#### Command `az billing account update` + +##### Example +``` +az billing account update --name "{billingAccountName}" --display-name "Test Account" --sold-to address-line1="Test \ +Address 1" city="Redmond" company-name="Contoso" country="US" first-name="Test" last-name="User" postal-code="12345" \ +region="WA" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--display-name**|string|The billing account name.|display_name|displayName| +|**--sold-to**|object|The address of the individual or organization that is responsible for the billing account.|sold_to|soldTo| +|**--departments**|array|The departments associated to the enrollment.|departments|departments| +|**--enrollment-accounts**|array|The accounts associated to the enrollment.|enrollment_accounts|enrollmentAccounts| +|**--value**|array|The billing profiles associated with the billing account.|value|value| + +### group `az billing agreement` +#### Command `az billing agreement list` + +##### Example +``` +az billing agreement list --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--expand**|string|May be used to expand the participants.|expand|$expand| + +#### Command `az billing agreement show` + +##### Example +``` +az billing agreement show --name "{agreementName}" --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--name**|string|The ID that uniquely identifies an agreement.|name|agreementName| +|**--expand**|string|May be used to expand the participants.|expand|$expand| + +### group `az billing balance` +#### Command `az billing balance show` + +##### Example +``` +az billing balance show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| + +### group `az billing customer` +#### Command `az billing customer list` + +##### Example +``` +az billing customer list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--search**|string|Used for searching customers by their name. Any customer with name containing the search text will be included in the response|search|$search| +|**--filter**|string|May be used to filter the list of customers.|filter|$filter| + +#### Command `az billing customer list` + +##### Example +``` +az billing customer list --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing customer show` + +##### Example +``` +az billing customer show --account-name "{billingAccountName}" --name "{customerName}" +``` +##### Example +``` +az billing customer show --expand "enabledAzurePlans,resellers" --account-name "{billingAccountName}" --name \ +"{customerName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--customer-name**|string|The ID that uniquely identifies a customer.|customer_name|customerName| +|**--expand**|string|May be used to expand enabledAzurePlans and resellers|expand|$expand| + +### group `az billing instruction` +#### Command `az billing instruction list` + +##### Example +``` +az billing instruction list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| + +#### Command `az billing instruction show` + +##### Example +``` +az billing instruction show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --name \ +"{instructionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--name**|string|Instruction Name.|name|instructionName| + +#### Command `az billing instruction create` + +##### Example +``` +az billing instruction create --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --name \ +"{instructionName}" --amount 5000 --end-date "2020-12-30T21:26:47.997Z" --start-date "2019-12-30T21:26:47.997Z" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--name**|string|Instruction Name.|name|instructionName| +|**--amount**|number|The amount budgeted for this billing instruction.|amount|amount| +|**--start-date**|date-time|The date this billing instruction goes into effect.|start_date|startDate| +|**--end-date**|date-time|The date this billing instruction is no longer in effect.|end_date|endDate| +|**--creation-date**|date-time|The date this billing instruction was created.|creation_date|creationDate| + +### group `az billing invoice` +#### Command `az billing invoice list` + +##### Example +``` +az billing invoice list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --period-end-date \ +"2018-06-30" --period-start-date "2018-01-01" +``` +##### Example +``` +az billing invoice list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --period-end-date \ +"2018-06-30" --period-start-date "2018-01-01" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--period-start-date**|string|The start date to fetch the invoices. The date should be specified in MM-DD-YYYY format.|period_start_date|periodStartDate| +|**--period-end-date**|string|The end date to fetch the invoices. The date should be specified in MM-DD-YYYY format.|period_end_date|periodEndDate| + +#### Command `az billing invoice list` + +##### Example +``` +az billing invoice list --account-name "{billingAccountName}" --period-end-date "2018-06-30" --period-start-date \ +"2018-01-01" +``` +##### Example +``` +az billing invoice list --account-name "{billingAccountName}" --period-end-date "2018-06-30" --period-start-date \ +"2018-01-01" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing invoice list` + +##### Example +``` +az billing invoice list --period-end-date "2018-06-30" --period-start-date "2018-01-01" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing invoice show` + +##### Example +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +##### Example +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +##### Example +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +##### Example +``` +az billing invoice show --account-name "{billingAccountName}" --name "{invoiceName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--name**|string|The ID that uniquely identifies an invoice.|name|invoiceName| + +### group `az billing invoice section` +#### Command `az billing invoice section list` + +##### Example +``` +az billing invoice section list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| + +#### Command `az billing invoice section show` + +##### Example +``` +az billing invoice section show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --name \ +"{invoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| + +#### Command `az billing invoice section create` + +##### Example +``` +az billing invoice section create --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --name \ +"{invoiceSectionName}" --display-name "invoiceSection1" --labels costCategory="Support" pcCode="A123456" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| +|**--display-name**|string|The name of the invoice section.|display_name|displayName| +|**--labels**|dictionary|Dictionary of metadata associated with the invoice section.|labels|labels| + +#### Command `az billing invoice section update` + +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| +|**--display-name**|string|The name of the invoice section.|display_name|displayName| +|**--labels**|dictionary|Dictionary of metadata associated with the invoice section.|labels|labels| + +### group `az billing permission` +#### Command `az billing permission list` + +##### Example +``` +az billing permission list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--invoice-section-name "{invoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| + +#### Command `az billing permission list` + +##### Example +``` +az billing permission list --account-name "{billingAccountName}" --customer-name "{customerName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--customer-name**|string|The ID that uniquely identifies a customer.|customer_name|customerName| + +#### Command `az billing permission list` + +##### Example +``` +az billing permission list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing permission list` + +##### Example +``` +az billing permission list --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +### group `az billing policy` +#### Command `az billing policy update` + +##### Example +``` +az billing policy update --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--marketplace-purchases "OnlyFreeAllowed" --reservation-purchases "NotAllowed" --view-charges "Allowed" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--marketplace-purchases**|choice|The policy that controls whether Azure marketplace purchases are allowed for a billing profile.|marketplace_purchases|marketplacePurchases| +|**--reservation-purchases**|choice|The policy that controls whether Azure reservation purchases are allowed for a billing profile.|reservation_purchases|reservationPurchases| +|**--view-charges**|choice|The policy that controls whether users with Azure RBAC access to a subscription can view its charges.|view_charges|viewCharges| + +### group `az billing product` +#### Command `az billing product list` + +##### Example +``` +az billing product list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--invoice-section-name "{invoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| +|**--filter**|string|May be used to filter by product type. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value are separated by a colon (:).|filter|$filter| + +#### Command `az billing product list` + +##### Example +``` +az billing product list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing product list` + +##### Example +``` +az billing product list --account-name "{billingAccountName}" --customer-name "{customerName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--customer-name**|string|The ID that uniquely identifies a customer.|customer_name|customerName| + +#### Command `az billing product list` + +##### Example +``` +az billing product list --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing product show` + +##### Example +``` +az billing product show --account-name "{billingAccountName}" --name "{productName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--product-name**|string|The ID that uniquely identifies a product.|product_name|productName| + +#### Command `az billing product update` + +##### Example +``` +az billing product update --account-name "{billingAccountName}" --auto-renew "Off" --name "{productName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--product-name**|string|The ID that uniquely identifies a product.|product_name|productName| +|**--auto-renew**|choice|Indicates whether auto renewal is turned on or off for a product.|auto_renew|autoRenew| +|**--status**|choice|The current status of the product.|status|status| +|**--billing-frequency**|choice|The frequency at which the product will be billed.|billing_frequency|billingFrequency| + +#### Command `az billing product move` + +##### Example +``` +az billing product move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" --name "{productName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--product-name**|string|The ID that uniquely identifies a product.|product_name|productName| +|**--destination-invoice-section-id**|string|The destination invoice section id.|destination_invoice_section_id|destinationInvoiceSectionId| + +#### Command `az billing product validate-move` + +##### Example +``` +az billing product validate-move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" --name "{productName}" +``` +##### Example +``` +az billing product validate-move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" --name "{productName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--product-name**|string|The ID that uniquely identifies a product.|product_name|productName| +|**--destination-invoice-section-id**|string|The destination invoice section id.|destination_invoice_section_id|destinationInvoiceSectionId| + +### group `az billing profile` +#### Command `az billing profile list` + +##### Example +``` +az billing profile list --account-name "{billingAccountName}" +``` +##### Example +``` +az billing profile list --expand "invoiceSections" --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--expand**|string|May be used to expand the invoice sections.|expand|$expand| + +#### Command `az billing profile show` + +##### Example +``` +az billing profile show --account-name "{billingAccountName}" --name "{billingProfileName}" +``` +##### Example +``` +az billing profile show --expand "invoiceSections" --account-name "{billingAccountName}" --name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--expand**|string|May be used to expand the invoice sections.|expand|$expand| + +#### Command `az billing profile create` + +##### Example +``` +az billing profile create --account-name "{billingAccountName}" --name "{billingProfileName}" --bill-to \ +address-line1="Test Address 1" city="Redmond" country="US" first-name="Test" last-name="User" postal-code="12345" \ +region="WA" --display-name "Finance" --enabled-azure-plans sku-id="0001" --enabled-azure-plans sku-id="0002" \ +--invoice-email-opt-in true --po-number "ABC12345" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--display-name**|string|The name of the billing profile.|display_name|displayName| +|**--po-number**|string|The purchase order name that will appear on the invoices generated for the billing profile.|po_number|poNumber| +|**--bill-to**|object|Billing address.|bill_to|billTo| +|**--invoice-email-opt-in**|boolean|Flag controlling whether the invoices for the billing profile are sent through email.|invoice_email_opt_in|invoiceEmailOptIn| +|**--enabled-azure-plans**|array|Information about the enabled azure plans.|enabled_azure_plans|enabledAzurePlans| +|**--value**|array|The invoice sections associated to the billing profile.|value|value| + +#### Command `az billing profile update` + +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--display-name**|string|The name of the billing profile.|display_name|displayName| +|**--po-number**|string|The purchase order name that will appear on the invoices generated for the billing profile.|po_number|poNumber| +|**--bill-to**|object|Billing address.|bill_to|billTo| +|**--invoice-email-opt-in**|boolean|Flag controlling whether the invoices for the billing profile are sent through email.|invoice_email_opt_in|invoiceEmailOptIn| +|**--enabled-azure-plans**|array|Information about the enabled azure plans.|enabled_azure_plans|enabledAzurePlans| +|**--value**|array|The invoice sections associated to the billing profile.|value|value| + +### group `az billing property` +#### Command `az billing property show` + +##### Example +``` +az billing property show +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing property update` + +##### Example +``` +az billing property update --cost-center "1010" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--cost-center**|string|The cost center applied to the subscription.|cost_center|costCenter| + +### group `az billing role-assignment` +#### Command `az billing role-assignment list` + +##### Example +``` +az billing role-assignment list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--invoice-section-name "{invoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| + +#### Command `az billing role-assignment list` + +##### Example +``` +az billing role-assignment list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing role-assignment list` + +##### Example +``` +az billing role-assignment list --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing role-assignment delete` + +##### Example +``` +az billing role-assignment delete --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --name \ +"{billingRoleAssignmentName}" --invoice-section-name "{invoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| +|**--name**|string|The ID that uniquely identifies a role assignment.|name|billingRoleAssignmentName| + +#### Command `az billing role-assignment delete` + +##### Example +``` +az billing role-assignment delete --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --name \ +"{billingRoleAssignmentName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing role-assignment delete` + +##### Example +``` +az billing role-assignment delete --account-name "{billingAccountName}" --name "{billingRoleAssignmentName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +### group `az billing role-definition` +#### Command `az billing role-definition list` + +##### Example +``` +az billing role-definition list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--invoice-section-name "{invoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| + +#### Command `az billing role-definition list` + +##### Example +``` +az billing role-definition list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing role-definition list` + +##### Example +``` +az billing role-definition list --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +### group `az billing subscription` +#### Command `az billing subscription list` + +##### Example +``` +az billing subscription list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" \ +--invoice-section-name "{invoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--profile-name**|string|The ID that uniquely identifies a billing profile.|profile_name|billingProfileName| +|**--invoice-section-name**|string|The ID that uniquely identifies an invoice section.|invoice_section_name|invoiceSectionName| + +#### Command `az billing subscription list` + +##### Example +``` +az billing subscription list --account-name "{billingAccountName}" --customer-name "{customerName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--customer-name**|string|The ID that uniquely identifies a customer.|customer_name|customerName| + +#### Command `az billing subscription list` + +##### Example +``` +az billing subscription list --account-name "{billingAccountName}" --profile-name "{billingProfileName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing subscription list` + +##### Example +``` +az billing subscription list --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az billing subscription show` + +##### Example +``` +az billing subscription show --account-name "{billingAccountName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| + +#### Command `az billing subscription update` + +##### Example +``` +az billing subscription update --account-name "{billingAccountName}" --cost-center "ABC1234" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--subscription-billing-status**|choice|The current billing status of the subscription.|subscription_billing_status|subscriptionBillingStatus| +|**--cost-center**|string|The cost center applied to the subscription.|cost_center|costCenter| +|**--sku-id**|string|The sku ID of the Azure plan for the subscription.|sku_id|skuId| + +#### Command `az billing subscription move` + +##### Example +``` +az billing subscription move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--destination-invoice-section-id**|string|The destination invoice section id.|destination_invoice_section_id|destinationInvoiceSectionId| + +#### Command `az billing subscription validate-move` + +##### Example +``` +az billing subscription validate-move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" +``` +##### Example +``` +az billing subscription validate-move --account-name "{billingAccountName}" --destination-invoice-section-id \ +"/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections\ +/{newInvoiceSectionName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--destination-invoice-section-id**|string|The destination invoice section id.|destination_invoice_section_id|destinationInvoiceSectionId| + +### group `az billing transaction` +#### Command `az billing transaction list` + +##### Example +``` +az billing transaction list --account-name "{billingAccountName}" --invoice-name "{invoiceName}" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--account-name**|string|The ID that uniquely identifies a billing account.|account_name|billingAccountName| +|**--invoice-name**|string|The ID that uniquely identifies an invoice.|invoice_name|invoiceName| diff --git a/src/billing/setup.cfg b/src/billing/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/billing/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/billing/setup.py b/src/billing/setup.py new file mode 100644 index 00000000000..7947864f082 --- /dev/null +++ b/src/billing/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from azext_billing.manual.version import VERSION +except ImportError: + pass + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +try: + from azext_billing.manual.dependency import DEPENDENCIES +except ImportError: + pass + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='billing', + version=VERSION, + description='Microsoft Azure Command-Line Tools BillingManagementClient Extension', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/billing', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_billing': ['azext_metadata.json']}, +)