diff --git a/src/billing/HISTORY.rst b/src/billing/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/billing/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/billing/README.md b/src/billing/README.md new file mode 100644 index 00000000000..ce157b31617 --- /dev/null +++ b/src/billing/README.md @@ -0,0 +1,5 @@ +# Azure CLI Billing Extension # +This is an extension to Azure CLI to manage Billing resources. + +## How to use ## +Please add commands usage here. \ 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..adeab9c35c9 --- /dev/null +++ b/src/billing/azext_billing/__init__.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_billing._help import helps # pylint: disable=unused-import + + +class BillingCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_billing.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_billing.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_billing._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = BillingCommandsLoader diff --git a/src/billing/azext_billing/_help.py b/src/billing/azext_billing/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/billing/azext_billing/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/billing/azext_billing/_params.py b/src/billing/azext_billing/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/billing/azext_billing/_params.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/billing/azext_billing/aaz/__init__.py b/src/billing/azext_billing/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/billing/azext_billing/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/billing/azext_billing/aaz/latest/__init__.py b/src/billing/azext_billing/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/__init__.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + diff --git a/src/billing/azext_billing/aaz/latest/billing/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/__cmd_group.py new file mode 100644 index 00000000000..4d32c8b49b3 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing", +) +class __CMDGroup(AAZCommandGroup): + """Manage Azure Billing. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/__init__.py b/src/billing/azext_billing/aaz/latest/billing/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/billing/azext_billing/aaz/latest/billing/account/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/account/__cmd_group.py new file mode 100644 index 00000000000..55f7d192840 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing account", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations for billing accounts around payment, subscriptions, invoice sections + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/__init__.py b/src/billing/azext_billing/aaz/latest/billing/account/__init__.py new file mode 100644 index 00000000000..a8e961d820d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/__init__.py @@ -0,0 +1,21 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._add_payment_term import * +from ._cancel_payment_term import * +from ._confirm_transition import * +from ._get import * +from ._list import * +from ._list_invoice_section import * +from ._list_invoice_sections_with_create_subscription_permission import * +from ._update import * +from ._validate_payment_term import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_add_payment_term.py b/src/billing/azext_billing/aaz/latest/billing/account/_add_payment_term.py new file mode 100644 index 00000000000..040b0782f8a --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_add_payment_term.py @@ -0,0 +1,444 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account add-payment-term", +) +class AddPaymentTerm(AAZCommand): + """Adds payment terms to all the billing profiles under the billing account. Currently, payment terms can be added only on billing accounts that have Agreement Type as 'Microsoft Customer Agreement' and AccountType as 'Enterprise'. This action needs pre-authorization and only Field Sellers are authorized to add the payment terms and is not a self-serve action. + + :example: PaymentTermsAdd + az billing account add-payment-term --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --parameters "[{term:net10,start-date:'2023-01-05T22:39:34.2606750Z',end-date:'2023-01-25T22:39:34.2606750Z'}]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/addpaymentterms", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.parameters = AAZListArg( + options=["--parameters"], + required=True, + ) + + parameters = cls._args_schema.parameters + parameters.Element = AAZObjectArg() + + _element = cls._args_schema.parameters.Element + _element.end_date = AAZDateTimeArg( + options=["end-date"], + help="The date on when the defined 'Payment Term' will end and is always in UTC.", + ) + _element.start_date = AAZDateTimeArg( + options=["start-date"], + help="The date on when the defined 'Payment Term' will be effective from and is always in UTC.", + ) + _element.term = AAZStrArg( + options=["term"], + help="Represents duration in netXX format. Always in days.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingAccountsAddPaymentTerms(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingAccountsAddPaymentTerms(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/addPaymentTerms", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args.parameters, + typ=AAZListType, + typ_kwargs={"flags": {"required": True}} + ) + _builder.set_elements(AAZObjectType, ".") + + _elements = _builder.get("[]") + if _elements is not None: + _elements.set_prop("endDate", AAZStrType, ".end_date") + _elements.set_prop("startDate", AAZStrType, ".start_date") + _elements.set_prop("term", AAZStrType, ".term") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_status = AAZStrType( + serialized_name="accountStatus", + flags={"read_only": True}, + ) + properties.account_status_reason_code = AAZStrType( + serialized_name="accountStatusReasonCode", + flags={"read_only": True}, + ) + properties.account_sub_type = AAZStrType( + serialized_name="accountSubType", + flags={"read_only": True}, + ) + properties.account_type = AAZStrType( + serialized_name="accountType", + flags={"read_only": True}, + ) + properties.agreement_type = AAZStrType( + serialized_name="agreementType", + flags={"read_only": True}, + ) + properties.billing_relationship_types = AAZListType( + serialized_name="billingRelationshipTypes", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.has_no_billing_profiles = AAZBoolType( + serialized_name="hasNoBillingProfiles", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + ) + properties.notification_email_address = AAZStrType( + serialized_name="notificationEmailAddress", + ) + properties.primary_billing_tenant_id = AAZStrType( + serialized_name="primaryBillingTenantId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.qualifications = AAZListType( + flags={"read_only": True}, + ) + properties.registration_number = AAZObjectType( + serialized_name="registrationNumber", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.tax_ids = AAZListType( + serialized_name="taxIds", + ) + + billing_relationship_types = cls._schema_on_200.properties.billing_relationship_types + billing_relationship_types.Element = AAZStrType() + + enrollment_details = cls._schema_on_200.properties.enrollment_details + enrollment_details.billing_cycle = AAZStrType( + serialized_name="billingCycle", + flags={"read_only": True}, + ) + enrollment_details.channel = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.cloud = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.country_code = AAZStrType( + serialized_name="countryCode", + flags={"read_only": True}, + ) + enrollment_details.currency = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.end_date = AAZStrType( + serialized_name="endDate", + ) + enrollment_details.extended_term_option = AAZStrType( + serialized_name="extendedTermOption", + flags={"read_only": True}, + ) + enrollment_details.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + enrollment_details.invoice_recipient = AAZStrType( + serialized_name="invoiceRecipient", + flags={"read_only": True}, + ) + enrollment_details.language = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.markup_status = AAZStrType( + serialized_name="markupStatus", + flags={"read_only": True}, + ) + enrollment_details.po_number = AAZStrType( + serialized_name="poNumber", + ) + enrollment_details.start_date = AAZStrType( + serialized_name="startDate", + ) + enrollment_details.support_coverage = AAZStrType( + serialized_name="supportCoverage", + flags={"read_only": True}, + ) + enrollment_details.support_level = AAZStrType( + serialized_name="supportLevel", + flags={"read_only": True}, + ) + + indirect_relationship_info = cls._schema_on_200.properties.enrollment_details.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + qualifications = cls._schema_on_200.properties.qualifications + qualifications.Element = AAZStrType() + + registration_number = cls._schema_on_200.properties.registration_number + registration_number.id = AAZStrType() + registration_number.required = AAZBoolType( + flags={"read_only": True}, + ) + registration_number.type = AAZListType( + flags={"read_only": True}, + ) + + type = cls._schema_on_200.properties.registration_number.type + type.Element = AAZStrType() + + sold_to = cls._schema_on_200.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + tax_ids = cls._schema_on_200.properties.tax_ids + tax_ids.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.tax_ids.Element + _element.country = AAZStrType() + _element.id = AAZStrType() + _element.scope = AAZStrType() + _element.status = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _AddPaymentTermHelper: + """Helper class for AddPaymentTerm""" + + +__all__ = ["AddPaymentTerm"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_cancel_payment_term.py b/src/billing/azext_billing/aaz/latest/billing/account/_cancel_payment_term.py new file mode 100644 index 00000000000..2d03b3ce2ea --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_cancel_payment_term.py @@ -0,0 +1,420 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account cancel-payment-term", +) +class CancelPaymentTerm(AAZCommand): + """Cancels all the payment terms on billing account that falls after the cancellation date in the request. Currently, cancel payment terms is only served by admin actions and is not a self-serve action. + + :example: PaymentTermsCancel + az billing account cancel-payment-term --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --parameters 2023-01-05T22:39:34.2606750Z + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/cancelpaymentterms", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.parameters = AAZDateTimeArg( + options=["--parameters"], + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingAccountsCancelPaymentTerms(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingAccountsCancelPaymentTerms(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/cancelPaymentTerms", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args.parameters, + typ=AAZStrType, + typ_kwargs={"flags": {"required": True}} + ) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_status = AAZStrType( + serialized_name="accountStatus", + flags={"read_only": True}, + ) + properties.account_status_reason_code = AAZStrType( + serialized_name="accountStatusReasonCode", + flags={"read_only": True}, + ) + properties.account_sub_type = AAZStrType( + serialized_name="accountSubType", + flags={"read_only": True}, + ) + properties.account_type = AAZStrType( + serialized_name="accountType", + flags={"read_only": True}, + ) + properties.agreement_type = AAZStrType( + serialized_name="agreementType", + flags={"read_only": True}, + ) + properties.billing_relationship_types = AAZListType( + serialized_name="billingRelationshipTypes", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.has_no_billing_profiles = AAZBoolType( + serialized_name="hasNoBillingProfiles", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + ) + properties.notification_email_address = AAZStrType( + serialized_name="notificationEmailAddress", + ) + properties.primary_billing_tenant_id = AAZStrType( + serialized_name="primaryBillingTenantId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.qualifications = AAZListType( + flags={"read_only": True}, + ) + properties.registration_number = AAZObjectType( + serialized_name="registrationNumber", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.tax_ids = AAZListType( + serialized_name="taxIds", + ) + + billing_relationship_types = cls._schema_on_200.properties.billing_relationship_types + billing_relationship_types.Element = AAZStrType() + + enrollment_details = cls._schema_on_200.properties.enrollment_details + enrollment_details.billing_cycle = AAZStrType( + serialized_name="billingCycle", + flags={"read_only": True}, + ) + enrollment_details.channel = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.cloud = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.country_code = AAZStrType( + serialized_name="countryCode", + flags={"read_only": True}, + ) + enrollment_details.currency = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.end_date = AAZStrType( + serialized_name="endDate", + ) + enrollment_details.extended_term_option = AAZStrType( + serialized_name="extendedTermOption", + flags={"read_only": True}, + ) + enrollment_details.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + enrollment_details.invoice_recipient = AAZStrType( + serialized_name="invoiceRecipient", + flags={"read_only": True}, + ) + enrollment_details.language = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.markup_status = AAZStrType( + serialized_name="markupStatus", + flags={"read_only": True}, + ) + enrollment_details.po_number = AAZStrType( + serialized_name="poNumber", + ) + enrollment_details.start_date = AAZStrType( + serialized_name="startDate", + ) + enrollment_details.support_coverage = AAZStrType( + serialized_name="supportCoverage", + flags={"read_only": True}, + ) + enrollment_details.support_level = AAZStrType( + serialized_name="supportLevel", + flags={"read_only": True}, + ) + + indirect_relationship_info = cls._schema_on_200.properties.enrollment_details.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + qualifications = cls._schema_on_200.properties.qualifications + qualifications.Element = AAZStrType() + + registration_number = cls._schema_on_200.properties.registration_number + registration_number.id = AAZStrType() + registration_number.required = AAZBoolType( + flags={"read_only": True}, + ) + registration_number.type = AAZListType( + flags={"read_only": True}, + ) + + type = cls._schema_on_200.properties.registration_number.type + type.Element = AAZStrType() + + sold_to = cls._schema_on_200.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + tax_ids = cls._schema_on_200.properties.tax_ids + tax_ids.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.tax_ids.Element + _element.country = AAZStrType() + _element.id = AAZStrType() + _element.scope = AAZStrType() + _element.status = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CancelPaymentTermHelper: + """Helper class for CancelPaymentTerm""" + + +__all__ = ["CancelPaymentTerm"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_confirm_transition.py b/src/billing/azext_billing/aaz/latest/billing/account/_confirm_transition.py new file mode 100644 index 00000000000..b262d6fe5aa --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_confirm_transition.py @@ -0,0 +1,163 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account confirm-transition", +) +class ConfirmTransition(AAZCommand): + """Gets the transition details for a billing account that has transitioned from agreement type Microsoft Online Services Program to agreement type Microsoft Customer Agreement. + + :example: BillingAccountsConfirmTransition + az billing account confirm-transition --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/confirmtransition", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingAccountsConfirmTransition(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingAccountsConfirmTransition(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/confirmTransition", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.anniversary_day = AAZIntType( + serialized_name="anniversaryDay", + flags={"read_only": True}, + ) + _schema_on_200.transition_date = AAZStrType( + serialized_name="transitionDate", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ConfirmTransitionHelper: + """Helper class for ConfirmTransition""" + + +__all__ = ["ConfirmTransition"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_get.py b/src/billing/azext_billing/aaz/latest/billing/account/_get.py new file mode 100644 index 00000000000..6b1bd6aa4c7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_get.py @@ -0,0 +1,386 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account get", +) +class Get(AAZCommand): + """Get a billing account by its ID. + + :example: BillingAccountsGet + az billing account get --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingAccountsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingAccountsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_status = AAZStrType( + serialized_name="accountStatus", + flags={"read_only": True}, + ) + properties.account_status_reason_code = AAZStrType( + serialized_name="accountStatusReasonCode", + flags={"read_only": True}, + ) + properties.account_sub_type = AAZStrType( + serialized_name="accountSubType", + flags={"read_only": True}, + ) + properties.account_type = AAZStrType( + serialized_name="accountType", + flags={"read_only": True}, + ) + properties.agreement_type = AAZStrType( + serialized_name="agreementType", + flags={"read_only": True}, + ) + properties.billing_relationship_types = AAZListType( + serialized_name="billingRelationshipTypes", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.has_no_billing_profiles = AAZBoolType( + serialized_name="hasNoBillingProfiles", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + ) + properties.notification_email_address = AAZStrType( + serialized_name="notificationEmailAddress", + ) + properties.primary_billing_tenant_id = AAZStrType( + serialized_name="primaryBillingTenantId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.qualifications = AAZListType( + flags={"read_only": True}, + ) + properties.registration_number = AAZObjectType( + serialized_name="registrationNumber", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.tax_ids = AAZListType( + serialized_name="taxIds", + ) + + billing_relationship_types = cls._schema_on_200.properties.billing_relationship_types + billing_relationship_types.Element = AAZStrType() + + enrollment_details = cls._schema_on_200.properties.enrollment_details + enrollment_details.billing_cycle = AAZStrType( + serialized_name="billingCycle", + flags={"read_only": True}, + ) + enrollment_details.channel = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.cloud = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.country_code = AAZStrType( + serialized_name="countryCode", + flags={"read_only": True}, + ) + enrollment_details.currency = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.end_date = AAZStrType( + serialized_name="endDate", + ) + enrollment_details.extended_term_option = AAZStrType( + serialized_name="extendedTermOption", + flags={"read_only": True}, + ) + enrollment_details.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + enrollment_details.invoice_recipient = AAZStrType( + serialized_name="invoiceRecipient", + flags={"read_only": True}, + ) + enrollment_details.language = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.markup_status = AAZStrType( + serialized_name="markupStatus", + flags={"read_only": True}, + ) + enrollment_details.po_number = AAZStrType( + serialized_name="poNumber", + ) + enrollment_details.start_date = AAZStrType( + serialized_name="startDate", + ) + enrollment_details.support_coverage = AAZStrType( + serialized_name="supportCoverage", + flags={"read_only": True}, + ) + enrollment_details.support_level = AAZStrType( + serialized_name="supportLevel", + flags={"read_only": True}, + ) + + indirect_relationship_info = cls._schema_on_200.properties.enrollment_details.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + qualifications = cls._schema_on_200.properties.qualifications + qualifications.Element = AAZStrType() + + registration_number = cls._schema_on_200.properties.registration_number + registration_number.id = AAZStrType() + registration_number.required = AAZBoolType( + flags={"read_only": True}, + ) + registration_number.type = AAZListType( + flags={"read_only": True}, + ) + + type = cls._schema_on_200.properties.registration_number.type + type.Element = AAZStrType() + + sold_to = cls._schema_on_200.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + tax_ids = cls._schema_on_200.properties.tax_ids + tax_ids.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.tax_ids.Element + _element.country = AAZStrType() + _element.id = AAZStrType() + _element.scope = AAZStrType() + _element.status = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_list.py b/src/billing/azext_billing/aaz/latest/billing/account/_list.py new file mode 100644 index 00000000000..be11d8e4377 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_list.py @@ -0,0 +1,471 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account list", +) +class List(AAZCommand): + """List the billing accounts that a user has access to. + + :example: BillingAccountsList + az billing account list + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Expand is allowed for SoldTo and EnrollmentDetails/PONumber.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_all = AAZBoolArg( + options=["--include-all"], + help="When true, results will include Billing Accounts that the user does not have a direct role assignment on if the user has one of the following AAD roles: Global Administrator, Global Reader, Billing Administrator.", + default=False, + ) + _args_schema.include_all_without_billing_profiles = AAZBoolArg( + options=["--include-all-without-billing-profiles"], + help="When true, results will include Billing Accounts that are not fully created if the user has one of the following AAD roles: Global Administrator, Global Reader, Billing Administrator.", + default=False, + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="When true, results will include any billing accounts in a deleted state.", + default=False, + ) + _args_schema.include_pending_agreement = AAZBoolArg( + options=["--include-pending-agreement"], + help="Includes billing accounts with agreement pending signature that the user has access to.", + default=False, + ) + _args_schema.include_resellee = AAZBoolArg( + options=["--include-resellee"], + help="Includes the customer's billing account of Microsoft Partner Agreement that the user has access to.", + default=False, + ) + _args_schema.legal_owner_oid = AAZStrArg( + options=["--legal-owner-oid"], + help="Must be combined with legalOwnerTID, results will only include Billing Accounts for whom is legally responsible for the Billing Accounts. Optional.", + ) + _args_schema.legal_owner_tid = AAZStrArg( + options=["--legal-owner-tid"], + help="Must be combined with legalOwnerOID, results will only include Billing Accounts for whom is legally responsible for the Billing Accounts. Optional.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingAccountsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingAccountsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeAll", self.ctx.args.include_all, + ), + **self.serialize_query_param( + "includeAllWithoutBillingProfiles", self.ctx.args.include_all_without_billing_profiles, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "includePendingAgreement", self.ctx.args.include_pending_agreement, + ), + **self.serialize_query_param( + "includeResellee", self.ctx.args.include_resellee, + ), + **self.serialize_query_param( + "legalOwnerOID", self.ctx.args.legal_owner_oid, + ), + **self.serialize_query_param( + "legalOwnerTID", self.ctx.args.legal_owner_tid, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.account_status = AAZStrType( + serialized_name="accountStatus", + flags={"read_only": True}, + ) + properties.account_status_reason_code = AAZStrType( + serialized_name="accountStatusReasonCode", + flags={"read_only": True}, + ) + properties.account_sub_type = AAZStrType( + serialized_name="accountSubType", + flags={"read_only": True}, + ) + properties.account_type = AAZStrType( + serialized_name="accountType", + flags={"read_only": True}, + ) + properties.agreement_type = AAZStrType( + serialized_name="agreementType", + flags={"read_only": True}, + ) + properties.billing_relationship_types = AAZListType( + serialized_name="billingRelationshipTypes", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.has_no_billing_profiles = AAZBoolType( + serialized_name="hasNoBillingProfiles", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + ) + properties.notification_email_address = AAZStrType( + serialized_name="notificationEmailAddress", + ) + properties.primary_billing_tenant_id = AAZStrType( + serialized_name="primaryBillingTenantId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.qualifications = AAZListType( + flags={"read_only": True}, + ) + properties.registration_number = AAZObjectType( + serialized_name="registrationNumber", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.tax_ids = AAZListType( + serialized_name="taxIds", + ) + + billing_relationship_types = cls._schema_on_200.value.Element.properties.billing_relationship_types + billing_relationship_types.Element = AAZStrType() + + enrollment_details = cls._schema_on_200.value.Element.properties.enrollment_details + enrollment_details.billing_cycle = AAZStrType( + serialized_name="billingCycle", + flags={"read_only": True}, + ) + enrollment_details.channel = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.cloud = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.country_code = AAZStrType( + serialized_name="countryCode", + flags={"read_only": True}, + ) + enrollment_details.currency = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.end_date = AAZStrType( + serialized_name="endDate", + ) + enrollment_details.extended_term_option = AAZStrType( + serialized_name="extendedTermOption", + flags={"read_only": True}, + ) + enrollment_details.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + enrollment_details.invoice_recipient = AAZStrType( + serialized_name="invoiceRecipient", + flags={"read_only": True}, + ) + enrollment_details.language = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.markup_status = AAZStrType( + serialized_name="markupStatus", + flags={"read_only": True}, + ) + enrollment_details.po_number = AAZStrType( + serialized_name="poNumber", + ) + enrollment_details.start_date = AAZStrType( + serialized_name="startDate", + ) + enrollment_details.support_coverage = AAZStrType( + serialized_name="supportCoverage", + flags={"read_only": True}, + ) + enrollment_details.support_level = AAZStrType( + serialized_name="supportLevel", + flags={"read_only": True}, + ) + + indirect_relationship_info = cls._schema_on_200.value.Element.properties.enrollment_details.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + qualifications = cls._schema_on_200.value.Element.properties.qualifications + qualifications.Element = AAZStrType() + + registration_number = cls._schema_on_200.value.Element.properties.registration_number + registration_number.id = AAZStrType() + registration_number.required = AAZBoolType( + flags={"read_only": True}, + ) + registration_number.type = AAZListType( + flags={"read_only": True}, + ) + + type = cls._schema_on_200.value.Element.properties.registration_number.type + type.Element = AAZStrType() + + sold_to = cls._schema_on_200.value.Element.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + tax_ids = cls._schema_on_200.value.Element.properties.tax_ids + tax_ids.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.tax_ids.Element + _element.country = AAZStrType() + _element.id = AAZStrType() + _element.scope = AAZStrType() + _element.status = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_list_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/account/_list_invoice_section.py new file mode 100644 index 00000000000..abc685ed6ae --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_list_invoice_section.py @@ -0,0 +1,212 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account list-invoice-section", +) +class ListInvoiceSection(AAZCommand): + """List 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. + """ + + _aaz_info = { + "version": "2020-05-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/listinvoicesectionswithcreatesubscriptionpermission", "2020-05-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingAccountsListInvoiceSectionsByCreateSubscriptionPermission(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingAccountsListInvoiceSectionsByCreateSubscriptionPermission(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2020-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + _element.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + _element.billing_profile_spending_limit = AAZStrType( + serialized_name="billingProfileSpendingLimit", + flags={"read_only": True}, + ) + _element.billing_profile_status = AAZStrType( + serialized_name="billingProfileStatus", + flags={"read_only": True}, + ) + _element.billing_profile_status_reason_code = AAZStrType( + serialized_name="billingProfileStatusReasonCode", + flags={"read_only": True}, + ) + _element.billing_profile_system_id = AAZStrType( + serialized_name="billingProfileSystemId", + flags={"read_only": True}, + ) + _element.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + _element.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + _element.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + _element.invoice_section_system_id = AAZStrType( + serialized_name="invoiceSectionSystemId", + flags={"read_only": True}, + ) + + enabled_azure_plans = cls._schema_on_200.value.Element.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.enabled_azure_plans.Element + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + return cls._schema_on_200 + + +class _ListInvoiceSectionHelper: + """Helper class for ListInvoiceSection""" + + +__all__ = ["ListInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_list_invoice_sections_with_create_subscription_permission.py b/src/billing/azext_billing/aaz/latest/billing/account/_list_invoice_sections_with_create_subscription_permission.py new file mode 100644 index 00000000000..e8cff91a081 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_list_invoice_sections_with_create_subscription_permission.py @@ -0,0 +1,230 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account list-invoice-sections-with-create-subscription-permission", +) +class ListInvoiceSectionsWithCreateSubscriptionPermission(AAZCommand): + """List 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. + + :example: InvoiceSectionsWithCreateSubscriptionPermissionList + az billing account list-invoice-sections-with-create-subscription-permission --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/listinvoicesectionswithcreatesubscriptionpermission", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingAccountsListInvoiceSectionsByCreateSubscriptionPermission(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingAccountsListInvoiceSectionsByCreateSubscriptionPermission(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + _element.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + _element.billing_profile_spending_limit = AAZStrType( + serialized_name="billingProfileSpendingLimit", + flags={"read_only": True}, + ) + _element.billing_profile_status = AAZStrType( + serialized_name="billingProfileStatus", + flags={"read_only": True}, + ) + _element.billing_profile_status_reason_code = AAZStrType( + serialized_name="billingProfileStatusReasonCode", + flags={"read_only": True}, + ) + _element.billing_profile_system_id = AAZStrType( + serialized_name="billingProfileSystemId", + flags={"read_only": True}, + ) + _element.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + flags={"read_only": True}, + ) + _element.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + _element.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + _element.invoice_section_system_id = AAZStrType( + serialized_name="invoiceSectionSystemId", + flags={"read_only": True}, + ) + + enabled_azure_plans = cls._schema_on_200.value.Element.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + return cls._schema_on_200 + + +class _ListInvoiceSectionsWithCreateSubscriptionPermissionHelper: + """Helper class for ListInvoiceSectionsWithCreateSubscriptionPermission""" + + +__all__ = ["ListInvoiceSectionsWithCreateSubscriptionPermission"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_update.py b/src/billing/azext_billing/aaz/latest/billing/account/_update.py new file mode 100644 index 00000000000..4d8e57f2595 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_update.py @@ -0,0 +1,674 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account update", +) +class Update(AAZCommand): + """Update the properties of a billing account. Currently, displayName and address can be updated for billing accounts with agreement type Microsoft Customer Agreement. Currently address and notification email address can be updated for billing accounts with agreement type Microsoft Online Services Agreement. Currently, purchase order number can be edited for billing accounts with agreement type Enterprise Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The billing account name.", + ) + _args_schema.enrollment_details = AAZObjectArg( + options=["--enrollment-details"], + arg_group="Properties", + help="The properties of an enrollment.", + ) + _args_schema.has_no_billing_profiles = AAZBoolArg( + options=["--has-no-billing-profiles"], + arg_group="Properties", + help="Indicates whether or not the billing account has any billing profiles.", + ) + _args_schema.has_read_access = AAZBoolArg( + options=["--has-read-access"], + arg_group="Properties", + help="Indicates whether user has read access to the billing account.", + ) + _args_schema.notification_email_address = AAZStrArg( + options=["--notification-email-address"], + arg_group="Properties", + help="Notification email address for legacy account. Available for agreement type Microsoft Online Services Program.", + ) + _args_schema.primary_billing_tenant_id = AAZStrArg( + options=["--primary-billing-tenant-id"], + arg_group="Properties", + help="The tenant that was used to set up the billing account. By default, only users from this tenant can get role assignments on the billing account and all purchases are provisioned in this tenant.", + ) + _args_schema.registration_number = AAZObjectArg( + options=["--registration-number"], + arg_group="Properties", + help="Describes the registration number of the organization linked with the billing account.", + ) + _args_schema.sold_to = AAZObjectArg( + options=["--sold-to"], + arg_group="Properties", + help="The address of the individual or organization that is responsible for the billing account.", + ) + _args_schema.tax_ids = AAZListArg( + options=["--tax-ids"], + arg_group="Properties", + help="A list of tax identifiers for the billing account.", + ) + + enrollment_details = cls._args_schema.enrollment_details + enrollment_details.end_date = AAZDateTimeArg( + options=["end-date"], + help="The end date of the enrollment.", + ) + enrollment_details.indirect_relationship_info = AAZObjectArg( + options=["indirect-relationship-info"], + help="The properties of an enrollment which are applicable only for indirect enrollments.", + ) + enrollment_details.po_number = AAZStrArg( + options=["po-number"], + help="The purchase order number of the enrollment.", + ) + enrollment_details.start_date = AAZDateTimeArg( + options=["start-date"], + help="The start date of the enrollment.", + ) + + indirect_relationship_info = cls._args_schema.enrollment_details.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrArg( + options=["billing-account-name"], + help="The billing account name of the partner or the customer for an indirect motion.", + ) + indirect_relationship_info.billing_profile_name = AAZStrArg( + options=["billing-profile-name"], + help="The billing profile name of the partner or the customer for an indirect motion.", + ) + indirect_relationship_info.display_name = AAZStrArg( + options=["display-name"], + help="The display name of the partner or customer for an indirect motion.", + ) + + registration_number = cls._args_schema.registration_number + registration_number.id = AAZStrArg( + options=["id"], + help="The unique identification number of the organization linked with the billing account.", + ) + + sold_to = cls._args_schema.sold_to + sold_to.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + sold_to.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + ) + sold_to.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + ) + sold_to.city = AAZStrArg( + options=["city"], + help="Address city.", + ) + sold_to.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + ) + sold_to.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + sold_to.district = AAZStrArg( + options=["district"], + help="Address district.", + ) + sold_to.email = AAZStrArg( + options=["email"], + help="Email address.", + ) + sold_to.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + ) + sold_to.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + ) + sold_to.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + ) + sold_to.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + ) + sold_to.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + ) + sold_to.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + ) + sold_to.region = AAZStrArg( + options=["region"], + help="Address region.", + ) + + tax_ids = cls._args_schema.tax_ids + tax_ids.Element = AAZObjectArg() + + _element = cls._args_schema.tax_ids.Element + _element.country = AAZStrArg( + options=["country"], + help="The country of the tax identifier.", + ) + _element.id = AAZStrArg( + options=["id"], + help="The id of the tax identifier.", + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope of the tax identifier.", + ) + _element.status = AAZStrArg( + options=["status"], + help="The status of the tax identifier.", + enum={"Invalid": "Invalid", "Other": "Other", "Valid": "Valid"}, + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of the tax identifier.", + enum={"BrazilCcmId": "BrazilCcmId", "BrazilCnpjId": "BrazilCnpjId", "BrazilCpfId": "BrazilCpfId", "CanadianFederalExempt": "CanadianFederalExempt", "CanadianProvinceExempt": "CanadianProvinceExempt", "ExternalTaxation": "ExternalTaxation", "IndiaFederalServiceTaxId": "IndiaFederalServiceTaxId", "IndiaFederalTanId": "IndiaFederalTanId", "IndiaPanId": "IndiaPanId", "IndiaStateCstId": "IndiaStateCstId", "IndiaStateGstINId": "IndiaStateGstINId", "IndiaStateVatId": "IndiaStateVatId", "IntlExempt": "IntlExempt", "LoveCode": "LoveCode", "MobileBarCode": "MobileBarCode", "NationalIdentificationNumber": "NationalIdentificationNumber", "Other": "Other", "PublicSectorId": "PublicSectorId", "USExempt": "USExempt", "VatId": "VatId"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingAccountsUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingAccountsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("enrollmentDetails", AAZObjectType, ".enrollment_details") + properties.set_prop("hasNoBillingProfiles", AAZBoolType, ".has_no_billing_profiles") + properties.set_prop("hasReadAccess", AAZBoolType, ".has_read_access") + properties.set_prop("notificationEmailAddress", AAZStrType, ".notification_email_address") + properties.set_prop("primaryBillingTenantId", AAZStrType, ".primary_billing_tenant_id") + properties.set_prop("registrationNumber", AAZObjectType, ".registration_number") + properties.set_prop("soldTo", AAZObjectType, ".sold_to") + properties.set_prop("taxIds", AAZListType, ".tax_ids") + + enrollment_details = _builder.get(".properties.enrollmentDetails") + if enrollment_details is not None: + enrollment_details.set_prop("endDate", AAZStrType, ".end_date") + enrollment_details.set_prop("indirectRelationshipInfo", AAZObjectType, ".indirect_relationship_info") + enrollment_details.set_prop("poNumber", AAZStrType, ".po_number") + enrollment_details.set_prop("startDate", AAZStrType, ".start_date") + + indirect_relationship_info = _builder.get(".properties.enrollmentDetails.indirectRelationshipInfo") + if indirect_relationship_info is not None: + indirect_relationship_info.set_prop("billingAccountName", AAZStrType, ".billing_account_name") + indirect_relationship_info.set_prop("billingProfileName", AAZStrType, ".billing_profile_name") + indirect_relationship_info.set_prop("displayName", AAZStrType, ".display_name") + + registration_number = _builder.get(".properties.registrationNumber") + if registration_number is not None: + registration_number.set_prop("id", AAZStrType, ".id") + + sold_to = _builder.get(".properties.soldTo") + if sold_to is not None: + sold_to.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + sold_to.set_prop("addressLine2", AAZStrType, ".address_line2") + sold_to.set_prop("addressLine3", AAZStrType, ".address_line3") + sold_to.set_prop("city", AAZStrType, ".city") + sold_to.set_prop("companyName", AAZStrType, ".company_name") + sold_to.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + sold_to.set_prop("district", AAZStrType, ".district") + sold_to.set_prop("email", AAZStrType, ".email") + sold_to.set_prop("firstName", AAZStrType, ".first_name") + sold_to.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + sold_to.set_prop("lastName", AAZStrType, ".last_name") + sold_to.set_prop("middleName", AAZStrType, ".middle_name") + sold_to.set_prop("phoneNumber", AAZStrType, ".phone_number") + sold_to.set_prop("postalCode", AAZStrType, ".postal_code") + sold_to.set_prop("region", AAZStrType, ".region") + + tax_ids = _builder.get(".properties.taxIds") + if tax_ids is not None: + tax_ids.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.taxIds[]") + if _elements is not None: + _elements.set_prop("country", AAZStrType, ".country") + _elements.set_prop("id", AAZStrType, ".id") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("status", AAZStrType, ".status") + _elements.set_prop("type", AAZStrType, ".type") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_status = AAZStrType( + serialized_name="accountStatus", + flags={"read_only": True}, + ) + properties.account_status_reason_code = AAZStrType( + serialized_name="accountStatusReasonCode", + flags={"read_only": True}, + ) + properties.account_sub_type = AAZStrType( + serialized_name="accountSubType", + flags={"read_only": True}, + ) + properties.account_type = AAZStrType( + serialized_name="accountType", + flags={"read_only": True}, + ) + properties.agreement_type = AAZStrType( + serialized_name="agreementType", + flags={"read_only": True}, + ) + properties.billing_relationship_types = AAZListType( + serialized_name="billingRelationshipTypes", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.has_no_billing_profiles = AAZBoolType( + serialized_name="hasNoBillingProfiles", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + ) + properties.notification_email_address = AAZStrType( + serialized_name="notificationEmailAddress", + ) + properties.primary_billing_tenant_id = AAZStrType( + serialized_name="primaryBillingTenantId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.qualifications = AAZListType( + flags={"read_only": True}, + ) + properties.registration_number = AAZObjectType( + serialized_name="registrationNumber", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.tax_ids = AAZListType( + serialized_name="taxIds", + ) + + billing_relationship_types = cls._schema_on_200.properties.billing_relationship_types + billing_relationship_types.Element = AAZStrType() + + enrollment_details = cls._schema_on_200.properties.enrollment_details + enrollment_details.billing_cycle = AAZStrType( + serialized_name="billingCycle", + flags={"read_only": True}, + ) + enrollment_details.channel = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.cloud = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.country_code = AAZStrType( + serialized_name="countryCode", + flags={"read_only": True}, + ) + enrollment_details.currency = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.end_date = AAZStrType( + serialized_name="endDate", + ) + enrollment_details.extended_term_option = AAZStrType( + serialized_name="extendedTermOption", + flags={"read_only": True}, + ) + enrollment_details.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + enrollment_details.invoice_recipient = AAZStrType( + serialized_name="invoiceRecipient", + flags={"read_only": True}, + ) + enrollment_details.language = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.markup_status = AAZStrType( + serialized_name="markupStatus", + flags={"read_only": True}, + ) + enrollment_details.po_number = AAZStrType( + serialized_name="poNumber", + ) + enrollment_details.start_date = AAZStrType( + serialized_name="startDate", + ) + enrollment_details.support_coverage = AAZStrType( + serialized_name="supportCoverage", + flags={"read_only": True}, + ) + enrollment_details.support_level = AAZStrType( + serialized_name="supportLevel", + flags={"read_only": True}, + ) + + indirect_relationship_info = cls._schema_on_200.properties.enrollment_details.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + qualifications = cls._schema_on_200.properties.qualifications + qualifications.Element = AAZStrType() + + registration_number = cls._schema_on_200.properties.registration_number + registration_number.id = AAZStrType() + registration_number.required = AAZBoolType( + flags={"read_only": True}, + ) + registration_number.type = AAZListType( + flags={"read_only": True}, + ) + + type = cls._schema_on_200.properties.registration_number.type + type.Element = AAZStrType() + + sold_to = cls._schema_on_200.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + tax_ids = cls._schema_on_200.properties.tax_ids + tax_ids.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.tax_ids.Element + _element.country = AAZStrType() + _element.id = AAZStrType() + _element.scope = AAZStrType() + _element.status = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_validate_payment_term.py b/src/billing/azext_billing/aaz/latest/billing/account/_validate_payment_term.py new file mode 100644 index 00000000000..32c603bbbed --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_validate_payment_term.py @@ -0,0 +1,209 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account validate-payment-term", +) +class ValidatePaymentTerm(AAZCommand): + """Validates payment terms on a billing account with agreement type 'Microsoft Customer Agreement' and account type 'Enterprise'. + + :example: PaymentTermInvalid + az billing account validate-payment-term --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --parameters "[{term:net10,start-date:'2023-02-05T22:39:34.2606750Z',end-date:'2023-01-25T22:39:34.2606750Z'}]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/validatepaymentterms", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.parameters = AAZListArg( + options=["--parameters"], + required=True, + ) + + parameters = cls._args_schema.parameters + parameters.Element = AAZObjectArg() + + _element = cls._args_schema.parameters.Element + _element.end_date = AAZDateTimeArg( + options=["end-date"], + help="The date on when the defined 'Payment Term' will end and is always in UTC.", + ) + _element.start_date = AAZDateTimeArg( + options=["start-date"], + help="The date on when the defined 'Payment Term' will be effective from and is always in UTC.", + ) + _element.term = AAZStrArg( + options=["term"], + help="Represents duration in netXX format. Always in days.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingAccountsValidatePaymentTerms(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingAccountsValidatePaymentTerms(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/validatePaymentTerms", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args.parameters, + typ=AAZListType, + typ_kwargs={"flags": {"required": True}} + ) + _builder.set_elements(AAZObjectType, ".") + + _elements = _builder.get("[]") + if _elements is not None: + _elements.set_prop("endDate", AAZStrType, ".end_date") + _elements.set_prop("startDate", AAZStrType, ".start_date") + _elements.set_prop("term", AAZStrType, ".term") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.eligibility_details = AAZListType( + serialized_name="eligibilityDetails", + ) + _schema_on_200.eligibility_status = AAZStrType( + serialized_name="eligibilityStatus", + ) + + eligibility_details = cls._schema_on_200.eligibility_details + eligibility_details.Element = AAZObjectType() + + _element = cls._schema_on_200.eligibility_details.Element + _element.code = AAZStrType() + _element.message = AAZStrType() + + return cls._schema_on_200 + + +class _ValidatePaymentTermHelper: + """Helper class for ValidatePaymentTerm""" + + +__all__ = ["ValidatePaymentTerm"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/_wait.py b/src/billing/azext_billing/aaz/latest/billing/account/_wait.py new file mode 100644 index 00000000000..d2bd73b2136 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/_wait.py @@ -0,0 +1,382 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingAccountsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class BillingAccountsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_status = AAZStrType( + serialized_name="accountStatus", + flags={"read_only": True}, + ) + properties.account_status_reason_code = AAZStrType( + serialized_name="accountStatusReasonCode", + flags={"read_only": True}, + ) + properties.account_sub_type = AAZStrType( + serialized_name="accountSubType", + flags={"read_only": True}, + ) + properties.account_type = AAZStrType( + serialized_name="accountType", + flags={"read_only": True}, + ) + properties.agreement_type = AAZStrType( + serialized_name="agreementType", + flags={"read_only": True}, + ) + properties.billing_relationship_types = AAZListType( + serialized_name="billingRelationshipTypes", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.has_no_billing_profiles = AAZBoolType( + serialized_name="hasNoBillingProfiles", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + ) + properties.notification_email_address = AAZStrType( + serialized_name="notificationEmailAddress", + ) + properties.primary_billing_tenant_id = AAZStrType( + serialized_name="primaryBillingTenantId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.qualifications = AAZListType( + flags={"read_only": True}, + ) + properties.registration_number = AAZObjectType( + serialized_name="registrationNumber", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.tax_ids = AAZListType( + serialized_name="taxIds", + ) + + billing_relationship_types = cls._schema_on_200.properties.billing_relationship_types + billing_relationship_types.Element = AAZStrType() + + enrollment_details = cls._schema_on_200.properties.enrollment_details + enrollment_details.billing_cycle = AAZStrType( + serialized_name="billingCycle", + flags={"read_only": True}, + ) + enrollment_details.channel = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.cloud = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.country_code = AAZStrType( + serialized_name="countryCode", + flags={"read_only": True}, + ) + enrollment_details.currency = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.end_date = AAZStrType( + serialized_name="endDate", + ) + enrollment_details.extended_term_option = AAZStrType( + serialized_name="extendedTermOption", + flags={"read_only": True}, + ) + enrollment_details.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + enrollment_details.invoice_recipient = AAZStrType( + serialized_name="invoiceRecipient", + flags={"read_only": True}, + ) + enrollment_details.language = AAZStrType( + flags={"read_only": True}, + ) + enrollment_details.markup_status = AAZStrType( + serialized_name="markupStatus", + flags={"read_only": True}, + ) + enrollment_details.po_number = AAZStrType( + serialized_name="poNumber", + ) + enrollment_details.start_date = AAZStrType( + serialized_name="startDate", + ) + enrollment_details.support_coverage = AAZStrType( + serialized_name="supportCoverage", + flags={"read_only": True}, + ) + enrollment_details.support_level = AAZStrType( + serialized_name="supportLevel", + flags={"read_only": True}, + ) + + indirect_relationship_info = cls._schema_on_200.properties.enrollment_details.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + qualifications = cls._schema_on_200.properties.qualifications + qualifications.Element = AAZStrType() + + registration_number = cls._schema_on_200.properties.registration_number + registration_number.id = AAZStrType() + registration_number.required = AAZBoolType( + flags={"read_only": True}, + ) + registration_number.type = AAZListType( + flags={"read_only": True}, + ) + + type = cls._schema_on_200.properties.registration_number.type + type.Element = AAZStrType() + + sold_to = cls._schema_on_200.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + tax_ids = cls._schema_on_200.properties.tax_ids + tax_ids.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.tax_ids.Element + _element.country = AAZStrType() + _element.id = AAZStrType() + _element.scope = AAZStrType() + _element.status = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/__cmd_group.py new file mode 100644 index 00000000000..8fd6c60d9d3 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing account invoice-section", +) +class __CMDGroup(AAZCommandGroup): + """Manage account invoice section + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/__init__.py b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/__init__.py new file mode 100644 index 00000000000..1f4c1e91ddd --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._create_untitled1 import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_create.py b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_create.py new file mode 100644 index 00000000000..5aa69f9a147 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_create.py @@ -0,0 +1,578 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account invoice-section create", +) +class Create(AAZCommand): + """Create operation to update a InvoiceSection. + """ + + _aaz_info = { + "version": "2018-11-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoicesections/{}", "2018-11-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="Billing Account Id.", + required=True, + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="InvoiceSection Id.", + required=True, + ) + _args_schema.parameters = AAZObjectArg( + options=["--parameters"], + help="An InvoiceSection resource.", + required=True, + ) + + parameters = cls._args_schema.parameters + parameters.billing_profiles = AAZListArg( + options=["billing-profiles"], + ) + parameters.display_name = AAZStrArg( + options=["display-name"], + ) + + billing_profiles = cls._args_schema.parameters.billing_profiles + billing_profiles.Element = AAZObjectArg() + + _element = cls._args_schema.parameters.billing_profiles.Element + _element.address = AAZObjectArg( + options=["address"], + ) + _element.display_name = AAZStrArg( + options=["display-name"], + ) + _element.enabled_azure_sk_us = AAZListArg( + options=["enabled-azure-sk-us"], + ) + _element.invoice_sections = AAZListArg( + options=["invoice-sections"], + ) + _element.po_number = AAZStrArg( + options=["po-number"], + ) + + address = cls._args_schema.parameters.billing_profiles.Element.address + address.address_line1 = AAZStrArg( + options=["address-line1"], + ) + address.address_line2 = AAZStrArg( + options=["address-line2"], + ) + address.address_line3 = AAZStrArg( + options=["address-line3"], + ) + address.city = AAZStrArg( + options=["city"], + ) + address.company_name = AAZStrArg( + options=["company-name"], + ) + address.country = AAZStrArg( + options=["country"], + ) + address.first_name = AAZStrArg( + options=["first-name"], + ) + address.last_name = AAZStrArg( + options=["last-name"], + ) + address.postal_code = AAZStrArg( + options=["postal-code"], + ) + address.region = AAZStrArg( + options=["region"], + ) + + enabled_azure_sk_us = cls._args_schema.parameters.billing_profiles.Element.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectArg() + + _element = cls._args_schema.parameters.billing_profiles.Element.enabled_azure_sk_us.Element + _element.sku_id = AAZStrArg( + options=["sku-id"], + ) + + invoice_sections = cls._args_schema.parameters.billing_profiles.Element.invoice_sections + invoice_sections.Element = AAZObjectArg() + cls._build_args_invoice_section_create(invoice_sections.Element) + return cls._args_schema + + _args_invoice_section_create = None + + @classmethod + def _build_args_invoice_section_create(cls, _schema): + if cls._args_invoice_section_create is not None: + _schema.billing_profiles = cls._args_invoice_section_create.billing_profiles + _schema.display_name = cls._args_invoice_section_create.display_name + return + + cls._args_invoice_section_create = AAZObjectArg() + + invoice_section_create = cls._args_invoice_section_create + invoice_section_create.billing_profiles = AAZListArg( + options=["billing-profiles"], + ) + invoice_section_create.display_name = AAZStrArg( + options=["display-name"], + ) + + billing_profiles = cls._args_invoice_section_create.billing_profiles + billing_profiles.Element = AAZObjectArg() + + _element = cls._args_invoice_section_create.billing_profiles.Element + _element.address = AAZObjectArg( + options=["address"], + ) + _element.display_name = AAZStrArg( + options=["display-name"], + ) + _element.enabled_azure_sk_us = AAZListArg( + options=["enabled-azure-sk-us"], + ) + _element.invoice_sections = AAZListArg( + options=["invoice-sections"], + ) + _element.po_number = AAZStrArg( + options=["po-number"], + ) + + address = cls._args_invoice_section_create.billing_profiles.Element.address + address.address_line1 = AAZStrArg( + options=["address-line1"], + ) + address.address_line2 = AAZStrArg( + options=["address-line2"], + ) + address.address_line3 = AAZStrArg( + options=["address-line3"], + ) + address.city = AAZStrArg( + options=["city"], + ) + address.company_name = AAZStrArg( + options=["company-name"], + ) + address.country = AAZStrArg( + options=["country"], + ) + address.first_name = AAZStrArg( + options=["first-name"], + ) + address.last_name = AAZStrArg( + options=["last-name"], + ) + address.postal_code = AAZStrArg( + options=["postal-code"], + ) + address.region = AAZStrArg( + options=["region"], + ) + + enabled_azure_sk_us = cls._args_invoice_section_create.billing_profiles.Element.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectArg() + + _element = cls._args_invoice_section_create.billing_profiles.Element.enabled_azure_sk_us.Element + _element.sku_id = AAZStrArg( + options=["sku-id"], + ) + + invoice_sections = cls._args_invoice_section_create.billing_profiles.Element.invoice_sections + invoice_sections.Element = AAZObjectArg() + cls._build_args_invoice_section_create(invoice_sections.Element) + + _schema.billing_profiles = cls._args_invoice_section_create.billing_profiles + _schema.display_name = cls._args_invoice_section_create.display_name + + def _execute_operations(self): + self.pre_operations() + yield self.InvoiceSectionsUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2018-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args.parameters, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billingProfiles", AAZListType, ".billing_profiles") + properties.set_prop("displayName", AAZStrType, ".display_name") + + billing_profiles = _builder.get(".properties.billingProfiles") + if billing_profiles is not None: + billing_profiles.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[]") + if _elements is not None: + _elements.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties.billingProfiles[].properties") + if properties is not None: + properties.set_prop("address", AAZObjectType, ".address") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("enabledAzureSKUs", AAZListType, ".enabled_azure_sk_us") + properties.set_prop("invoiceSections", AAZListType, ".invoice_sections") + properties.set_prop("poNumber", AAZStrType, ".po_number") + + address = _builder.get(".properties.billingProfiles[].properties.address") + if address is not None: + address.set_prop("addressLine1", AAZStrType, ".address_line1") + address.set_prop("addressLine2", AAZStrType, ".address_line2") + address.set_prop("addressLine3", AAZStrType, ".address_line3") + address.set_prop("city", AAZStrType, ".city") + address.set_prop("companyName", AAZStrType, ".company_name") + address.set_prop("country", AAZStrType, ".country") + address.set_prop("firstName", AAZStrType, ".first_name") + address.set_prop("lastName", AAZStrType, ".last_name") + address.set_prop("postalCode", AAZStrType, ".postal_code") + address.set_prop("region", AAZStrType, ".region") + + enabled_azure_sk_us = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs") + if enabled_azure_sk_us is not None: + enabled_azure_sk_us.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs[]") + if _elements is not None: + _elements.set_prop("skuId", AAZStrType, ".sku_id") + + invoice_sections = _builder.get(".properties.billingProfiles[].properties.invoiceSections") + if invoice_sections is not None: + _CreateHelper._build_schema_invoice_section_create(invoice_sections.set_elements(AAZObjectType, ".")) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _CreateHelper._build_schema_invoice_section_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _CreateHelper: + """Helper class for Create""" + + @classmethod + def _build_schema_invoice_section_create(cls, _builder): + if _builder is None: + return + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billingProfiles", AAZListType, ".billing_profiles") + properties.set_prop("displayName", AAZStrType, ".display_name") + + billing_profiles = _builder.get(".properties.billingProfiles") + if billing_profiles is not None: + billing_profiles.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[]") + if _elements is not None: + _elements.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties.billingProfiles[].properties") + if properties is not None: + properties.set_prop("address", AAZObjectType, ".address") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("enabledAzureSKUs", AAZListType, ".enabled_azure_sk_us") + properties.set_prop("invoiceSections", AAZListType, ".invoice_sections") + properties.set_prop("poNumber", AAZStrType, ".po_number") + + address = _builder.get(".properties.billingProfiles[].properties.address") + if address is not None: + address.set_prop("addressLine1", AAZStrType, ".address_line1") + address.set_prop("addressLine2", AAZStrType, ".address_line2") + address.set_prop("addressLine3", AAZStrType, ".address_line3") + address.set_prop("city", AAZStrType, ".city") + address.set_prop("companyName", AAZStrType, ".company_name") + address.set_prop("country", AAZStrType, ".country") + address.set_prop("firstName", AAZStrType, ".first_name") + address.set_prop("lastName", AAZStrType, ".last_name") + address.set_prop("postalCode", AAZStrType, ".postal_code") + address.set_prop("region", AAZStrType, ".region") + + enabled_azure_sk_us = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs") + if enabled_azure_sk_us is not None: + enabled_azure_sk_us.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs[]") + if _elements is not None: + _elements.set_prop("skuId", AAZStrType, ".sku_id") + + invoice_sections = _builder.get(".properties.billingProfiles[].properties.invoiceSections") + if invoice_sections is not None: + cls._build_schema_invoice_section_create(invoice_sections.set_elements(AAZObjectType, ".")) + + _schema_invoice_section_read = None + + @classmethod + def _build_schema_invoice_section_read(cls, _schema): + if cls._schema_invoice_section_read is not None: + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + return + + cls._schema_invoice_section_read = _schema_invoice_section_read = AAZObjectType() + + invoice_section_read = _schema_invoice_section_read + invoice_section_read.id = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.name = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + invoice_section_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties + properties.billing_profiles = AAZListType( + serialized_name="billingProfiles", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + + billing_profiles = _schema_invoice_section_read.properties.billing_profiles + billing_profiles.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties.billing_profiles.Element.properties + properties.address = AAZObjectType() + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_sk_us = AAZListType( + serialized_name="enabledAzureSKUs", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + flags={"read_only": True}, + ) + properties.invoice_sections = AAZListType( + serialized_name="invoiceSections", + ) + properties.is_classic = AAZBoolType( + serialized_name="isClassic", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + + address = _schema_invoice_section_read.properties.billing_profiles.Element.properties.address + address.address_line1 = AAZStrType( + serialized_name="addressLine1", + ) + address.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + address.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + address.city = AAZStrType() + address.company_name = AAZStrType( + serialized_name="companyName", + ) + address.country = AAZStrType() + address.first_name = AAZStrType( + serialized_name="firstName", + ) + address.last_name = AAZStrType( + serialized_name="lastName", + ) + address.postal_code = AAZStrType( + serialized_name="postalCode", + ) + address.region = AAZStrType() + + enabled_azure_sk_us = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us.Element + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + invoice_sections = _schema_invoice_section_read.properties.billing_profiles.Element.properties.invoice_sections + invoice_sections.Element = AAZObjectType() + cls._build_schema_invoice_section_read(invoice_sections.Element) + + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + + +__all__ = ["Create"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_create_untitled1.py b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_create_untitled1.py new file mode 100644 index 00000000000..16d2e59ad24 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_create_untitled1.py @@ -0,0 +1,323 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account invoice-section create-untitled1", +) +class CreateUntitled1(AAZCommand): + """Create operation to create a InvoiceSection. + """ + + _aaz_info = { + "version": "2018-11-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoicesections", "2018-11-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="Billing Account Id.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.billing_profile_id = AAZStrArg( + options=["--billing-profile-id"], + arg_group="Parameters", + help="The billing profile id.", + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Parameters", + help="The name of the InvoiceSection.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoiceSectionsCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2018-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("billingProfileId", AAZStrType, ".billing_profile_id") + _builder.set_prop("displayName", AAZStrType, ".display_name") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _CreateUntitled1Helper._build_schema_invoice_section_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _CreateUntitled1Helper: + """Helper class for CreateUntitled1""" + + _schema_invoice_section_read = None + + @classmethod + def _build_schema_invoice_section_read(cls, _schema): + if cls._schema_invoice_section_read is not None: + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + return + + cls._schema_invoice_section_read = _schema_invoice_section_read = AAZObjectType() + + invoice_section_read = _schema_invoice_section_read + invoice_section_read.id = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.name = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + invoice_section_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties + properties.billing_profiles = AAZListType( + serialized_name="billingProfiles", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + + billing_profiles = _schema_invoice_section_read.properties.billing_profiles + billing_profiles.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties.billing_profiles.Element.properties + properties.address = AAZObjectType() + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_sk_us = AAZListType( + serialized_name="enabledAzureSKUs", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + flags={"read_only": True}, + ) + properties.invoice_sections = AAZListType( + serialized_name="invoiceSections", + ) + properties.is_classic = AAZBoolType( + serialized_name="isClassic", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + + address = _schema_invoice_section_read.properties.billing_profiles.Element.properties.address + address.address_line1 = AAZStrType( + serialized_name="addressLine1", + ) + address.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + address.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + address.city = AAZStrType() + address.company_name = AAZStrType( + serialized_name="companyName", + ) + address.country = AAZStrType() + address.first_name = AAZStrType( + serialized_name="firstName", + ) + address.last_name = AAZStrType( + serialized_name="lastName", + ) + address.postal_code = AAZStrType( + serialized_name="postalCode", + ) + address.region = AAZStrType() + + enabled_azure_sk_us = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us.Element + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + invoice_sections = _schema_invoice_section_read.properties.billing_profiles.Element.properties.invoice_sections + invoice_sections.Element = AAZObjectType() + cls._build_schema_invoice_section_read(invoice_sections.Element) + + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + + +__all__ = ["CreateUntitled1"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_list.py b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_list.py new file mode 100644 index 00000000000..867183f3cfc --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_list.py @@ -0,0 +1,298 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account invoice-section list", +) +class List(AAZCommand): + """List all invoice sections for which a user has access. + """ + + _aaz_info = { + "version": "2018-11-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoicesections", "2018-11-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="Billing Account Id.", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the billingProfiles.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsListByBillingAccountName(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class InvoiceSectionsListByBillingAccountName(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2018-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + _ListHelper._build_schema_invoice_section_read(value.Element) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_invoice_section_read = None + + @classmethod + def _build_schema_invoice_section_read(cls, _schema): + if cls._schema_invoice_section_read is not None: + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + return + + cls._schema_invoice_section_read = _schema_invoice_section_read = AAZObjectType() + + invoice_section_read = _schema_invoice_section_read + invoice_section_read.id = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.name = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + invoice_section_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties + properties.billing_profiles = AAZListType( + serialized_name="billingProfiles", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + + billing_profiles = _schema_invoice_section_read.properties.billing_profiles + billing_profiles.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties.billing_profiles.Element.properties + properties.address = AAZObjectType() + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_sk_us = AAZListType( + serialized_name="enabledAzureSKUs", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + flags={"read_only": True}, + ) + properties.invoice_sections = AAZListType( + serialized_name="invoiceSections", + ) + properties.is_classic = AAZBoolType( + serialized_name="isClassic", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + + address = _schema_invoice_section_read.properties.billing_profiles.Element.properties.address + address.address_line1 = AAZStrType( + serialized_name="addressLine1", + ) + address.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + address.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + address.city = AAZStrType() + address.company_name = AAZStrType( + serialized_name="companyName", + ) + address.country = AAZStrType() + address.first_name = AAZStrType( + serialized_name="firstName", + ) + address.last_name = AAZStrType( + serialized_name="lastName", + ) + address.postal_code = AAZStrType( + serialized_name="postalCode", + ) + address.region = AAZStrType() + + enabled_azure_sk_us = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us.Element + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + invoice_sections = _schema_invoice_section_read.properties.billing_profiles.Element.properties.invoice_sections + invoice_sections.Element = AAZObjectType() + cls._build_schema_invoice_section_read(invoice_sections.Element) + + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_show.py b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_show.py new file mode 100644 index 00000000000..dc0282a3948 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_show.py @@ -0,0 +1,293 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account invoice-section show", +) +class Show(AAZCommand): + """Get the InvoiceSection by id. + """ + + _aaz_info = { + "version": "2018-11-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoicesections/{}", "2018-11-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="Billing Account Id.", + required=True, + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="InvoiceSection Id.", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the billingProfiles.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2018-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_invoice_section_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_invoice_section_read = None + + @classmethod + def _build_schema_invoice_section_read(cls, _schema): + if cls._schema_invoice_section_read is not None: + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + return + + cls._schema_invoice_section_read = _schema_invoice_section_read = AAZObjectType() + + invoice_section_read = _schema_invoice_section_read + invoice_section_read.id = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.name = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + invoice_section_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties + properties.billing_profiles = AAZListType( + serialized_name="billingProfiles", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + + billing_profiles = _schema_invoice_section_read.properties.billing_profiles + billing_profiles.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties.billing_profiles.Element.properties + properties.address = AAZObjectType() + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_sk_us = AAZListType( + serialized_name="enabledAzureSKUs", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + flags={"read_only": True}, + ) + properties.invoice_sections = AAZListType( + serialized_name="invoiceSections", + ) + properties.is_classic = AAZBoolType( + serialized_name="isClassic", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + + address = _schema_invoice_section_read.properties.billing_profiles.Element.properties.address + address.address_line1 = AAZStrType( + serialized_name="addressLine1", + ) + address.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + address.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + address.city = AAZStrType() + address.company_name = AAZStrType( + serialized_name="companyName", + ) + address.country = AAZStrType() + address.first_name = AAZStrType( + serialized_name="firstName", + ) + address.last_name = AAZStrType( + serialized_name="lastName", + ) + address.postal_code = AAZStrType( + serialized_name="postalCode", + ) + address.region = AAZStrType() + + enabled_azure_sk_us = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us.Element + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + invoice_sections = _schema_invoice_section_read.properties.billing_profiles.Element.properties.invoice_sections + invoice_sections.Element = AAZObjectType() + cls._build_schema_invoice_section_read(invoice_sections.Element) + + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + + +__all__ = ["Show"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_update.py b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_update.py new file mode 100644 index 00000000000..10e3a088323 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/invoice_section/_update.py @@ -0,0 +1,742 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account invoice-section update", +) +class Update(AAZCommand): + """Update operation to update a InvoiceSection. + """ + + _aaz_info = { + "version": "2018-11-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoicesections/{}", "2018-11-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="Billing Account Id.", + required=True, + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="InvoiceSection Id.", + required=True, + ) + _args_schema.parameters = AAZObjectArg( + options=["--parameters"], + help="An InvoiceSection resource.", + ) + + parameters = cls._args_schema.parameters + parameters.billing_profiles = AAZListArg( + options=["billing-profiles"], + nullable=True, + ) + parameters.display_name = AAZStrArg( + options=["display-name"], + nullable=True, + ) + + billing_profiles = cls._args_schema.parameters.billing_profiles + billing_profiles.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.parameters.billing_profiles.Element + _element.address = AAZObjectArg( + options=["address"], + nullable=True, + ) + _element.display_name = AAZStrArg( + options=["display-name"], + nullable=True, + ) + _element.enabled_azure_sk_us = AAZListArg( + options=["enabled-azure-sk-us"], + nullable=True, + ) + _element.invoice_sections = AAZListArg( + options=["invoice-sections"], + nullable=True, + ) + _element.po_number = AAZStrArg( + options=["po-number"], + nullable=True, + ) + + address = cls._args_schema.parameters.billing_profiles.Element.address + address.address_line1 = AAZStrArg( + options=["address-line1"], + nullable=True, + ) + address.address_line2 = AAZStrArg( + options=["address-line2"], + nullable=True, + ) + address.address_line3 = AAZStrArg( + options=["address-line3"], + nullable=True, + ) + address.city = AAZStrArg( + options=["city"], + nullable=True, + ) + address.company_name = AAZStrArg( + options=["company-name"], + nullable=True, + ) + address.country = AAZStrArg( + options=["country"], + nullable=True, + ) + address.first_name = AAZStrArg( + options=["first-name"], + nullable=True, + ) + address.last_name = AAZStrArg( + options=["last-name"], + nullable=True, + ) + address.postal_code = AAZStrArg( + options=["postal-code"], + nullable=True, + ) + address.region = AAZStrArg( + options=["region"], + nullable=True, + ) + + enabled_azure_sk_us = cls._args_schema.parameters.billing_profiles.Element.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.parameters.billing_profiles.Element.enabled_azure_sk_us.Element + _element.sku_id = AAZStrArg( + options=["sku-id"], + nullable=True, + ) + + invoice_sections = cls._args_schema.parameters.billing_profiles.Element.invoice_sections + invoice_sections.Element = AAZObjectArg( + nullable=True, + ) + cls._build_args_invoice_section_update(invoice_sections.Element) + return cls._args_schema + + _args_invoice_section_update = None + + @classmethod + def _build_args_invoice_section_update(cls, _schema): + if cls._args_invoice_section_update is not None: + _schema.billing_profiles = cls._args_invoice_section_update.billing_profiles + _schema.display_name = cls._args_invoice_section_update.display_name + return + + cls._args_invoice_section_update = AAZObjectArg( + nullable=True, + ) + + invoice_section_update = cls._args_invoice_section_update + invoice_section_update.billing_profiles = AAZListArg( + options=["billing-profiles"], + nullable=True, + ) + invoice_section_update.display_name = AAZStrArg( + options=["display-name"], + nullable=True, + ) + + billing_profiles = cls._args_invoice_section_update.billing_profiles + billing_profiles.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_invoice_section_update.billing_profiles.Element + _element.address = AAZObjectArg( + options=["address"], + nullable=True, + ) + _element.display_name = AAZStrArg( + options=["display-name"], + nullable=True, + ) + _element.enabled_azure_sk_us = AAZListArg( + options=["enabled-azure-sk-us"], + nullable=True, + ) + _element.invoice_sections = AAZListArg( + options=["invoice-sections"], + nullable=True, + ) + _element.po_number = AAZStrArg( + options=["po-number"], + nullable=True, + ) + + address = cls._args_invoice_section_update.billing_profiles.Element.address + address.address_line1 = AAZStrArg( + options=["address-line1"], + nullable=True, + ) + address.address_line2 = AAZStrArg( + options=["address-line2"], + nullable=True, + ) + address.address_line3 = AAZStrArg( + options=["address-line3"], + nullable=True, + ) + address.city = AAZStrArg( + options=["city"], + nullable=True, + ) + address.company_name = AAZStrArg( + options=["company-name"], + nullable=True, + ) + address.country = AAZStrArg( + options=["country"], + nullable=True, + ) + address.first_name = AAZStrArg( + options=["first-name"], + nullable=True, + ) + address.last_name = AAZStrArg( + options=["last-name"], + nullable=True, + ) + address.postal_code = AAZStrArg( + options=["postal-code"], + nullable=True, + ) + address.region = AAZStrArg( + options=["region"], + nullable=True, + ) + + enabled_azure_sk_us = cls._args_invoice_section_update.billing_profiles.Element.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_invoice_section_update.billing_profiles.Element.enabled_azure_sk_us.Element + _element.sku_id = AAZStrArg( + options=["sku-id"], + nullable=True, + ) + + invoice_sections = cls._args_invoice_section_update.billing_profiles.Element.invoice_sections + invoice_sections.Element = AAZObjectArg( + nullable=True, + ) + cls._build_args_invoice_section_update(invoice_sections.Element) + + _schema.billing_profiles = cls._args_invoice_section_update.billing_profiles + _schema.display_name = cls._args_invoice_section_update.display_name + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.InvoiceSectionsUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2018-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_invoice_section_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InvoiceSectionsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2018-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_invoice_section_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args.parameters, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billingProfiles", AAZListType, ".billing_profiles") + properties.set_prop("displayName", AAZStrType, ".display_name") + + billing_profiles = _builder.get(".properties.billingProfiles") + if billing_profiles is not None: + billing_profiles.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[]") + if _elements is not None: + _elements.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties.billingProfiles[].properties") + if properties is not None: + properties.set_prop("address", AAZObjectType, ".address") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("enabledAzureSKUs", AAZListType, ".enabled_azure_sk_us") + properties.set_prop("invoiceSections", AAZListType, ".invoice_sections") + properties.set_prop("poNumber", AAZStrType, ".po_number") + + address = _builder.get(".properties.billingProfiles[].properties.address") + if address is not None: + address.set_prop("addressLine1", AAZStrType, ".address_line1") + address.set_prop("addressLine2", AAZStrType, ".address_line2") + address.set_prop("addressLine3", AAZStrType, ".address_line3") + address.set_prop("city", AAZStrType, ".city") + address.set_prop("companyName", AAZStrType, ".company_name") + address.set_prop("country", AAZStrType, ".country") + address.set_prop("firstName", AAZStrType, ".first_name") + address.set_prop("lastName", AAZStrType, ".last_name") + address.set_prop("postalCode", AAZStrType, ".postal_code") + address.set_prop("region", AAZStrType, ".region") + + enabled_azure_sk_us = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs") + if enabled_azure_sk_us is not None: + enabled_azure_sk_us.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs[]") + if _elements is not None: + _elements.set_prop("skuId", AAZStrType, ".sku_id") + + invoice_sections = _builder.get(".properties.billingProfiles[].properties.invoiceSections") + if invoice_sections is not None: + _UpdateHelper._build_schema_invoice_section_update(invoice_sections.set_elements(AAZObjectType, ".")) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + @classmethod + def _build_schema_invoice_section_update(cls, _builder): + if _builder is None: + return + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billingProfiles", AAZListType, ".billing_profiles") + properties.set_prop("displayName", AAZStrType, ".display_name") + + billing_profiles = _builder.get(".properties.billingProfiles") + if billing_profiles is not None: + billing_profiles.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[]") + if _elements is not None: + _elements.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties.billingProfiles[].properties") + if properties is not None: + properties.set_prop("address", AAZObjectType, ".address") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("enabledAzureSKUs", AAZListType, ".enabled_azure_sk_us") + properties.set_prop("invoiceSections", AAZListType, ".invoice_sections") + properties.set_prop("poNumber", AAZStrType, ".po_number") + + address = _builder.get(".properties.billingProfiles[].properties.address") + if address is not None: + address.set_prop("addressLine1", AAZStrType, ".address_line1") + address.set_prop("addressLine2", AAZStrType, ".address_line2") + address.set_prop("addressLine3", AAZStrType, ".address_line3") + address.set_prop("city", AAZStrType, ".city") + address.set_prop("companyName", AAZStrType, ".company_name") + address.set_prop("country", AAZStrType, ".country") + address.set_prop("firstName", AAZStrType, ".first_name") + address.set_prop("lastName", AAZStrType, ".last_name") + address.set_prop("postalCode", AAZStrType, ".postal_code") + address.set_prop("region", AAZStrType, ".region") + + enabled_azure_sk_us = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs") + if enabled_azure_sk_us is not None: + enabled_azure_sk_us.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.billingProfiles[].properties.enabledAzureSKUs[]") + if _elements is not None: + _elements.set_prop("skuId", AAZStrType, ".sku_id") + + invoice_sections = _builder.get(".properties.billingProfiles[].properties.invoiceSections") + if invoice_sections is not None: + cls._build_schema_invoice_section_update(invoice_sections.set_elements(AAZObjectType, ".")) + + _schema_invoice_section_read = None + + @classmethod + def _build_schema_invoice_section_read(cls, _schema): + if cls._schema_invoice_section_read is not None: + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + return + + cls._schema_invoice_section_read = _schema_invoice_section_read = AAZObjectType() + + invoice_section_read = _schema_invoice_section_read + invoice_section_read.id = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.name = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + invoice_section_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties + properties.billing_profiles = AAZListType( + serialized_name="billingProfiles", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + + billing_profiles = _schema_invoice_section_read.properties.billing_profiles + billing_profiles.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties.billing_profiles.Element.properties + properties.address = AAZObjectType() + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_sk_us = AAZListType( + serialized_name="enabledAzureSKUs", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + flags={"read_only": True}, + ) + properties.invoice_sections = AAZListType( + serialized_name="invoiceSections", + ) + properties.is_classic = AAZBoolType( + serialized_name="isClassic", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + + address = _schema_invoice_section_read.properties.billing_profiles.Element.properties.address + address.address_line1 = AAZStrType( + serialized_name="addressLine1", + ) + address.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + address.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + address.city = AAZStrType() + address.company_name = AAZStrType( + serialized_name="companyName", + ) + address.country = AAZStrType() + address.first_name = AAZStrType( + serialized_name="firstName", + ) + address.last_name = AAZStrType( + serialized_name="lastName", + ) + address.postal_code = AAZStrType( + serialized_name="postalCode", + ) + address.region = AAZStrType() + + enabled_azure_sk_us = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us + enabled_azure_sk_us.Element = AAZObjectType() + + _element = _schema_invoice_section_read.properties.billing_profiles.Element.properties.enabled_azure_sk_us.Element + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + invoice_sections = _schema_invoice_section_read.properties.billing_profiles.Element.properties.invoice_sections + invoice_sections.Element = AAZObjectType() + cls._build_schema_invoice_section_read(invoice_sections.Element) + + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.type = cls._schema_invoice_section_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/reservation/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/account/reservation/__cmd_group.py new file mode 100644 index 00000000000..5726aa98c45 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/reservation/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing account reservation", +) +class __CMDGroup(AAZCommandGroup): + """Manage account reservation + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/reservation/__init__.py b/src/billing/azext_billing/aaz/latest/billing/account/reservation/__init__.py new file mode 100644 index 00000000000..d63ae5a6fc9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/reservation/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * diff --git a/src/billing/azext_billing/aaz/latest/billing/account/reservation/_list.py b/src/billing/azext_billing/aaz/latest/billing/account/reservation/_list.py new file mode 100644 index 00000000000..5bf4ec5a9a9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/reservation/_list.py @@ -0,0 +1,334 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account reservation list", +) +class List(AAZCommand): + """List the reservations for a billing account and the roll up counts of reservations group by provisioning states. + """ + + _aaz_info = { + "version": "2020-05-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservations", "2020-05-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support 'ne', 'gt', 'le', 'ge', or 'not'.", + ) + _args_schema.orderby = AAZStrArg( + options=["--orderby"], + help="May be used to sort order by reservation properties.", + ) + _args_schema.refresh_summary = AAZStrArg( + options=["--refresh-summary"], + help="To indicate whether to refresh the roll up counts of the reservations group by provisioning states", + ) + _args_schema.selected_state = AAZStrArg( + options=["--selected-state"], + help="The selected provisioning state", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ReservationsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "$orderby", self.ctx.args.orderby, + ), + **self.serialize_query_param( + "refreshSummary", self.ctx.args.refresh_summary, + ), + **self.serialize_query_param( + "selectedState", self.ctx.args.selected_state, + ), + **self.serialize_query_param( + "api-version", "2020-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.summary = AAZObjectType() + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + summary = cls._schema_on_200.summary + summary.cancelled_count = AAZFloatType( + serialized_name="cancelledCount", + flags={"read_only": True}, + ) + summary.expired_count = AAZFloatType( + serialized_name="expiredCount", + flags={"read_only": True}, + ) + summary.expiring_count = AAZFloatType( + serialized_name="expiringCount", + flags={"read_only": True}, + ) + summary.failed_count = AAZFloatType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + summary.pending_count = AAZFloatType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + summary.succeeded_count = AAZFloatType( + serialized_name="succeededCount", + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + utilization = cls._schema_on_200.value.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/transaction/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/account/transaction/__cmd_group.py new file mode 100644 index 00000000000..2cbfb31068f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/transaction/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing account transaction", +) +class __CMDGroup(AAZCommandGroup): + """Manage billing acount transaction + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/account/transaction/__init__.py b/src/billing/azext_billing/aaz/latest/billing/account/transaction/__init__.py new file mode 100644 index 00000000000..d63ae5a6fc9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/transaction/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * diff --git a/src/billing/azext_billing/aaz/latest/billing/account/transaction/_list.py b/src/billing/azext_billing/aaz/latest/billing/account/transaction/_list.py new file mode 100644 index 00000000000..242b114024f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/account/transaction/_list.py @@ -0,0 +1,353 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing account transaction list", +) +class List(AAZCommand): + """List the billed and unbilled transactions by billing account name for given start and end date. Transactions include purchases, refunds and Azure usage charges. Unbilled transactions are listed under pending invoice ID and do not include tax. Tax is added to the amount once an invoice is generated. + """ + + _aaz_info = { + "version": "2019-10-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/transactions", "2019-10-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="May be used to filter by transaction 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 (:).", + ) + _args_schema.period_end_date = AAZStrArg( + options=["--period-end-date"], + help="The end date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + _args_schema.period_start_date = AAZStrArg( + options=["--period-start-date"], + help="The start date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransactionsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class TransactionsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/transactions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "periodEndDate", self.ctx.args.period_end_date, + required=True, + ), + **self.serialize_query_param( + "periodStartDate", self.ctx.args.period_start_date, + required=True, + ), + **self.serialize_query_param( + "api-version", "2019-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.azure_credit_applied = AAZObjectType( + serialized_name="azureCreditApplied", + flags={"read_only": True}, + ) + _ListHelper._build_schema_amount_read(properties.azure_credit_applied) + properties.billing_currency = AAZStrType( + serialized_name="billingCurrency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.date = AAZStrType( + flags={"read_only": True}, + ) + properties.discount = AAZFloatType( + flags={"read_only": True}, + ) + properties.effective_price = AAZObjectType( + serialized_name="effectivePrice", + flags={"read_only": True}, + ) + _ListHelper._build_schema_amount_read(properties.effective_price) + properties.exchange_rate = AAZFloatType( + serialized_name="exchangeRate", + flags={"read_only": True}, + ) + properties.invoice = AAZStrType( + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.kind = AAZStrType() + properties.market_price = AAZObjectType( + serialized_name="marketPrice", + flags={"read_only": True}, + ) + _ListHelper._build_schema_amount_read(properties.market_price) + properties.order_id = AAZStrType( + serialized_name="orderId", + flags={"read_only": True}, + ) + properties.order_name = AAZStrType( + serialized_name="orderName", + flags={"read_only": True}, + ) + properties.pricing_currency = AAZStrType( + serialized_name="pricingCurrency", + flags={"read_only": True}, + ) + properties.product_description = AAZStrType( + serialized_name="productDescription", + flags={"read_only": True}, + ) + properties.product_family = AAZStrType( + serialized_name="productFamily", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.service_period_end_date = AAZStrType( + serialized_name="servicePeriodEndDate", + flags={"read_only": True}, + ) + properties.service_period_start_date = AAZStrType( + serialized_name="servicePeriodStartDate", + flags={"read_only": True}, + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + flags={"read_only": True}, + ) + _ListHelper._build_schema_amount_read(properties.sub_total) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.tax = AAZObjectType( + flags={"read_only": True}, + ) + _ListHelper._build_schema_amount_read(properties.tax) + properties.transaction_amount = AAZObjectType( + serialized_name="transactionAmount", + ) + _ListHelper._build_schema_amount_read(properties.transaction_amount) + properties.transaction_type = AAZStrType( + serialized_name="transactionType", + ) + properties.unit_of_measure = AAZStrType( + serialized_name="unitOfMeasure", + flags={"read_only": True}, + ) + properties.unit_type = AAZStrType( + serialized_name="unitType", + flags={"read_only": True}, + ) + properties.units = AAZFloatType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType() + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType() + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/address/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/address/__cmd_group.py new file mode 100644 index 00000000000..67248bbad1d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/address/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing address", +) +class __CMDGroup(AAZCommandGroup): + """Group of api's to validate address. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/address/__init__.py b/src/billing/azext_billing/aaz/latest/billing/address/__init__.py new file mode 100644 index 00000000000..173259fdb81 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/address/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._validate import * diff --git a/src/billing/azext_billing/aaz/latest/billing/address/_validate.py b/src/billing/azext_billing/aaz/latest/billing/address/_validate.py new file mode 100644 index 00000000000..de5a39c2b1b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/address/_validate.py @@ -0,0 +1,302 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing address validate", +) +class Validate(AAZCommand): + """Validates an address. Use the operation to validate an address before using it as soldTo or a billTo address. + + :example: AddressValidateValid + az billing address validate --address-line1 1 Test --city bellevue --country us --postal-code 12345 --region wa + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/validateaddress", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.address_line1 = AAZStrArg( + options=["--address-line1"], + arg_group="Parameters", + help="Address line 1.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.address_line2 = AAZStrArg( + options=["--address-line2"], + arg_group="Parameters", + help="Address line 2.", + ) + _args_schema.address_line3 = AAZStrArg( + options=["--address-line3"], + arg_group="Parameters", + help="Address line 3.", + ) + _args_schema.city = AAZStrArg( + options=["--city"], + arg_group="Parameters", + help="Address city.", + ) + _args_schema.company_name = AAZStrArg( + options=["--company-name"], + arg_group="Parameters", + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + ) + _args_schema.country = AAZStrArg( + options=["--country"], + arg_group="Parameters", + help="Country code uses ISO 3166-1 Alpha-2 format.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.district = AAZStrArg( + options=["--district"], + arg_group="Parameters", + help="Address district.", + ) + _args_schema.email = AAZStrArg( + options=["--email"], + arg_group="Parameters", + help="Email address.", + ) + _args_schema.first_name = AAZStrArg( + options=["--first-name"], + arg_group="Parameters", + help="First name. Optional for MCA Enterprise.", + ) + _args_schema.is_valid_address = AAZBoolArg( + options=["--is-valid-address"], + arg_group="Parameters", + help="Indicates if the address is incomplete.", + ) + _args_schema.last_name = AAZStrArg( + options=["--last-name"], + arg_group="Parameters", + help="Last name. Optional for MCA Enterprise.", + ) + _args_schema.middle_name = AAZStrArg( + options=["--middle-name"], + arg_group="Parameters", + help="Middle name.", + ) + _args_schema.phone_number = AAZStrArg( + options=["--phone-number"], + arg_group="Parameters", + help="Phone number.", + ) + _args_schema.postal_code = AAZStrArg( + options=["--postal-code"], + arg_group="Parameters", + help="Postal code.", + ) + _args_schema.region = AAZStrArg( + options=["--region"], + arg_group="Parameters", + help="Address region.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AddressValidate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AddressValidate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/validateAddress", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("addressLine2", AAZStrType, ".address_line2") + _builder.set_prop("addressLine3", AAZStrType, ".address_line3") + _builder.set_prop("city", AAZStrType, ".city") + _builder.set_prop("companyName", AAZStrType, ".company_name") + _builder.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("district", AAZStrType, ".district") + _builder.set_prop("email", AAZStrType, ".email") + _builder.set_prop("firstName", AAZStrType, ".first_name") + _builder.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + _builder.set_prop("lastName", AAZStrType, ".last_name") + _builder.set_prop("middleName", AAZStrType, ".middle_name") + _builder.set_prop("phoneNumber", AAZStrType, ".phone_number") + _builder.set_prop("postalCode", AAZStrType, ".postal_code") + _builder.set_prop("region", AAZStrType, ".region") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.status = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.suggested_addresses = AAZListType( + serialized_name="suggestedAddresses", + flags={"read_only": True}, + ) + _schema_on_200.validation_message = AAZStrType( + serialized_name="validationMessage", + flags={"read_only": True}, + ) + + suggested_addresses = cls._schema_on_200.suggested_addresses + suggested_addresses.Element = AAZObjectType() + + _element = cls._schema_on_200.suggested_addresses.Element + _element.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + _element.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + _element.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + _element.city = AAZStrType() + _element.company_name = AAZStrType( + serialized_name="companyName", + ) + _element.country = AAZStrType( + flags={"required": True}, + ) + _element.district = AAZStrType() + _element.email = AAZStrType() + _element.first_name = AAZStrType( + serialized_name="firstName", + ) + _element.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + _element.last_name = AAZStrType( + serialized_name="lastName", + ) + _element.middle_name = AAZStrType( + serialized_name="middleName", + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + _element.postal_code = AAZStrType( + serialized_name="postalCode", + ) + _element.region = AAZStrType() + + return cls._schema_on_200 + + +class _ValidateHelper: + """Helper class for Validate""" + + +__all__ = ["Validate"] diff --git a/src/billing/azext_billing/aaz/latest/billing/agreement/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/agreement/__cmd_group.py new file mode 100644 index 00000000000..5dcbedd855b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/agreement/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing agreement", +) +class __CMDGroup(AAZCommandGroup): + """Operations for viewing agreements for a billing account. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/agreement/__init__.py b/src/billing/azext_billing/aaz/latest/billing/agreement/__init__.py new file mode 100644 index 00000000000..400055b1bbd --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/agreement/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get import * +from ._list_by_billing_account import * diff --git a/src/billing/azext_billing/aaz/latest/billing/agreement/_get.py b/src/billing/azext_billing/aaz/latest/billing/agreement/_get.py new file mode 100644 index 00000000000..1e1e004b0b1 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/agreement/_get.py @@ -0,0 +1,279 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing agreement get", +) +class Get(AAZCommand): + """Get an agreement by ID. + + :example: AgreementByName + az billing agreement get --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --agreement-name ABC123 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/agreements/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.agreement_name = AAZStrArg( + options=["--agreement-name"], + help="The ID that uniquely identifies an agreement.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{1,12}$", + ), + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AgreementsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AgreementsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "agreementName", self.ctx.args.agreement_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.acceptance_mode = AAZStrType( + serialized_name="acceptanceMode", + flags={"read_only": True}, + ) + properties.agreement_link = AAZStrType( + serialized_name="agreementLink", + flags={"read_only": True}, + ) + properties.billing_profile_info = AAZListType( + serialized_name="billingProfileInfo", + flags={"read_only": True}, + ) + properties.category = AAZStrType( + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.lead_billing_account_name = AAZStrType( + serialized_name="leadBillingAccountName", + flags={"read_only": True}, + ) + properties.participants = AAZListType( + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + billing_profile_info = cls._schema_on_200.properties.billing_profile_info + billing_profile_info.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.billing_profile_info.Element + _element.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + ) + _element.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + ) + _element.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + _element.billing_profile_system_id = AAZStrType( + serialized_name="billingProfileSystemId", + ) + _element.indirect_relationship_organization_name = AAZStrType( + serialized_name="indirectRelationshipOrganizationName", + ) + + participants = cls._schema_on_200.properties.participants + participants.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.participants.Element + _element.email = AAZStrType( + flags={"read_only": True}, + ) + _element.status = AAZStrType( + flags={"read_only": True}, + ) + _element.status_date = AAZStrType( + serialized_name="statusDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/agreement/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/agreement/_list_by_billing_account.py new file mode 100644 index 00000000000..475f563fcaf --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/agreement/_list_by_billing_account.py @@ -0,0 +1,288 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing agreement list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the agreements for a billing account. + + :example: AgreementsListByBillingAccount + az billing agreement list-by-billing-account --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --expand Participants + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/agreements", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the participants.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AgreementsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class AgreementsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.acceptance_mode = AAZStrType( + serialized_name="acceptanceMode", + flags={"read_only": True}, + ) + properties.agreement_link = AAZStrType( + serialized_name="agreementLink", + flags={"read_only": True}, + ) + properties.billing_profile_info = AAZListType( + serialized_name="billingProfileInfo", + flags={"read_only": True}, + ) + properties.category = AAZStrType( + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.lead_billing_account_name = AAZStrType( + serialized_name="leadBillingAccountName", + flags={"read_only": True}, + ) + properties.participants = AAZListType( + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + billing_profile_info = cls._schema_on_200.value.Element.properties.billing_profile_info + billing_profile_info.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.billing_profile_info.Element + _element.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + ) + _element.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + ) + _element.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + _element.billing_profile_system_id = AAZStrType( + serialized_name="billingProfileSystemId", + ) + _element.indirect_relationship_organization_name = AAZStrType( + serialized_name="indirectRelationshipOrganizationName", + ) + + participants = cls._schema_on_200.value.Element.properties.participants + participants.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.participants.Element + _element.email = AAZStrType( + flags={"read_only": True}, + ) + _element.status = AAZStrType( + flags={"read_only": True}, + ) + _element.status_date = AAZStrType( + serialized_name="statusDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/__cmd_group.py new file mode 100644 index 00000000000..153e16db130 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing associated-tenant", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations for associated tenants that can collaborate with the billing account. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/__init__.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/__init__.py new file mode 100644 index 00000000000..bcaa9552ceb --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/__init__.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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._get import * +from ._list_by_billing_account import * +from ._update import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_create.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_create.py new file mode 100644 index 00000000000..3af36588fc8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_create.py @@ -0,0 +1,308 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing associated-tenant create", +) +class Create(AAZCommand): + """Create an associated tenant for the billing account. + + :example: AssociatedTenantsCreateOrUpdate + az billing associated-tenant create --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --associated-tenant-name 11111111-1111-1111-1111-111111111111 --display-name Contoso Finance --billing-management-state Active --provisioning-management-state Pending + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/associatedtenants/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.associated_tenant_name = AAZStrArg( + options=["--associated-tenant-name"], + help="The ID that uniquely identifies a tenant.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.billing_management_state = AAZStrArg( + options=["--billing-management-state"], + arg_group="Properties", + help="The state determines whether users from the associated tenant can be assigned roles for commerce activities like viewing and downloading invoices, managing payments, and making purchases.", + enum={"Active": "Active", "NotAllowed": "NotAllowed", "Other": "Other", "Revoked": "Revoked"}, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the associated tenant.", + ) + _args_schema.provisioning_management_state = AAZStrArg( + options=["--provisioning-management-state"], + arg_group="Properties", + help="The state determines whether subscriptions and licenses can be provisioned in the associated tenant. It can be set to 'Pending' to initiate a billing request.", + enum={"Active": "Active", "BillingRequestDeclined": "BillingRequestDeclined", "BillingRequestExpired": "BillingRequestExpired", "NotRequested": "NotRequested", "Other": "Other", "Pending": "Pending", "Revoked": "Revoked"}, + ) + _args_schema.tenant_id = AAZStrArg( + options=["--tenant-id"], + arg_group="Properties", + help="The ID that uniquely identifies a tenant.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.AssociatedTenantsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AssociatedTenantsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "associatedTenantName", self.ctx.args.associated_tenant_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billingManagementState", AAZStrType, ".billing_management_state") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("provisioningManagementState", AAZStrType, ".provisioning_management_state") + properties.set_prop("tenantId", AAZStrType, ".tenant_id") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.billing_management_state = AAZStrType( + serialized_name="billingManagementState", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_billing_request_id = AAZStrType( + serialized_name="provisioningBillingRequestId", + flags={"read_only": True}, + ) + properties.provisioning_management_state = AAZStrType( + serialized_name="provisioningManagementState", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_delete.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_delete.py new file mode 100644 index 00000000000..bab3c43983f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_delete.py @@ -0,0 +1,166 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing associated-tenant delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an associated tenant for a billing account. + + :example: AssociatedTenantsDelete + az billing associated-tenant delete --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --associated-tenant-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/associatedtenants/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.associated_tenant_name = AAZStrArg( + options=["--associated-tenant-name"], + help="The ID that uniquely identifies a tenant.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.AssociatedTenantsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class AssociatedTenantsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "associatedTenantName", self.ctx.args.associated_tenant_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_get.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_get.py new file mode 100644 index 00000000000..d76e0887dfd --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_get.py @@ -0,0 +1,227 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing associated-tenant get", +) +class Get(AAZCommand): + """Get an associated tenant by ID. + + :example: AssociatedTenantsGet + az billing associated-tenant get --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --associated-tenant-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/associatedtenants/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.associated_tenant_name = AAZStrArg( + options=["--associated-tenant-name"], + help="The ID that uniquely identifies a tenant.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AssociatedTenantsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AssociatedTenantsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "associatedTenantName", self.ctx.args.associated_tenant_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_management_state = AAZStrType( + serialized_name="billingManagementState", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_billing_request_id = AAZStrType( + serialized_name="provisioningBillingRequestId", + flags={"read_only": True}, + ) + properties.provisioning_management_state = AAZStrType( + serialized_name="provisioningManagementState", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_list_by_billing_account.py new file mode 100644 index 00000000000..99e3c7e3cd8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_list_by_billing_account.py @@ -0,0 +1,279 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing associated-tenant list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the associated tenants that can collaborate with the billing account on commerce activities like viewing and downloading invoices, managing payments, making purchases, and managing or provisioning licenses. + + :example: AssociatedTenantsListByBillingAccount + az billing associated-tenant list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/associatedtenants", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_revoked = AAZBoolArg( + options=["--include-revoked"], + help="Can be used to get revoked associated tenants.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AssociatedTenantsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class AssociatedTenantsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeRevoked", self.ctx.args.include_revoked, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_management_state = AAZStrType( + serialized_name="billingManagementState", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_billing_request_id = AAZStrType( + serialized_name="provisioningBillingRequestId", + flags={"read_only": True}, + ) + properties.provisioning_management_state = AAZStrType( + serialized_name="provisioningManagementState", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_update.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_update.py new file mode 100644 index 00000000000..fe33904c651 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_update.py @@ -0,0 +1,450 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing associated-tenant update", +) +class Update(AAZCommand): + """Update an associated tenant for the billing account. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/associatedtenants/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.associated_tenant_name = AAZStrArg( + options=["--associated-tenant-name"], + help="The ID that uniquely identifies a tenant.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.billing_management_state = AAZStrArg( + options=["--billing-management-state"], + arg_group="Properties", + help="The state determines whether users from the associated tenant can be assigned roles for commerce activities like viewing and downloading invoices, managing payments, and making purchases.", + nullable=True, + enum={"Active": "Active", "NotAllowed": "NotAllowed", "Other": "Other", "Revoked": "Revoked"}, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the associated tenant.", + nullable=True, + ) + _args_schema.provisioning_management_state = AAZStrArg( + options=["--provisioning-management-state"], + arg_group="Properties", + help="The state determines whether subscriptions and licenses can be provisioned in the associated tenant. It can be set to 'Pending' to initiate a billing request.", + nullable=True, + enum={"Active": "Active", "BillingRequestDeclined": "BillingRequestDeclined", "BillingRequestExpired": "BillingRequestExpired", "NotRequested": "NotRequested", "Other": "Other", "Pending": "Pending", "Revoked": "Revoked"}, + ) + _args_schema.tenant_id = AAZStrArg( + options=["--tenant-id"], + arg_group="Properties", + help="The ID that uniquely identifies a tenant.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AssociatedTenantsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.AssociatedTenantsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AssociatedTenantsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "associatedTenantName", self.ctx.args.associated_tenant_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_associated_tenant_read(cls._schema_on_200) + + return cls._schema_on_200 + + class AssociatedTenantsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "associatedTenantName", self.ctx.args.associated_tenant_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_associated_tenant_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billingManagementState", AAZStrType, ".billing_management_state") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("provisioningManagementState", AAZStrType, ".provisioning_management_state") + properties.set_prop("tenantId", AAZStrType, ".tenant_id") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_associated_tenant_read = None + + @classmethod + def _build_schema_associated_tenant_read(cls, _schema): + if cls._schema_associated_tenant_read is not None: + _schema.id = cls._schema_associated_tenant_read.id + _schema.name = cls._schema_associated_tenant_read.name + _schema.properties = cls._schema_associated_tenant_read.properties + _schema.system_data = cls._schema_associated_tenant_read.system_data + _schema.tags = cls._schema_associated_tenant_read.tags + _schema.type = cls._schema_associated_tenant_read.type + return + + cls._schema_associated_tenant_read = _schema_associated_tenant_read = AAZObjectType() + + associated_tenant_read = _schema_associated_tenant_read + associated_tenant_read.id = AAZStrType( + flags={"read_only": True}, + ) + associated_tenant_read.name = AAZStrType( + flags={"read_only": True}, + ) + associated_tenant_read.properties = AAZObjectType() + associated_tenant_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + associated_tenant_read.tags = AAZDictType() + associated_tenant_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_associated_tenant_read.properties + properties.billing_management_state = AAZStrType( + serialized_name="billingManagementState", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_billing_request_id = AAZStrType( + serialized_name="provisioningBillingRequestId", + flags={"read_only": True}, + ) + properties.provisioning_management_state = AAZStrType( + serialized_name="provisioningManagementState", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + system_data = _schema_associated_tenant_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_associated_tenant_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_associated_tenant_read.id + _schema.name = cls._schema_associated_tenant_read.name + _schema.properties = cls._schema_associated_tenant_read.properties + _schema.system_data = cls._schema_associated_tenant_read.system_data + _schema.tags = cls._schema_associated_tenant_read.tags + _schema.type = cls._schema_associated_tenant_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_wait.py b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_wait.py new file mode 100644 index 00000000000..a233f269775 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/associated_tenant/_wait.py @@ -0,0 +1,223 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing associated-tenant wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/associatedtenants/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.associated_tenant_name = AAZStrArg( + options=["--associated-tenant-name"], + help="The ID that uniquely identifies a tenant.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AssociatedTenantsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class AssociatedTenantsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "associatedTenantName", self.ctx.args.associated_tenant_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_management_state = AAZStrType( + serialized_name="billingManagementState", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_billing_request_id = AAZStrType( + serialized_name="provisioningBillingRequestId", + flags={"read_only": True}, + ) + properties.provisioning_management_state = AAZStrType( + serialized_name="provisioningManagementState", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/available_balance/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/available_balance/__cmd_group.py new file mode 100644 index 00000000000..9334682fcab --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/available_balance/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing available-balance", +) +class __CMDGroup(AAZCommandGroup): + """Available Credit or Payment on Account Balance for a billing account and billing profile. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/available_balance/__init__.py b/src/billing/azext_billing/aaz/latest/billing/available_balance/__init__.py new file mode 100644 index 00000000000..220d26fa20e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/available_balance/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_by_billing_account import * +from ._get_by_billing_profile import * diff --git a/src/billing/azext_billing/aaz/latest/billing/available_balance/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/available_balance/_get_by_billing_account.py new file mode 100644 index 00000000000..4f400798fc0 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/available_balance/_get_by_billing_account.py @@ -0,0 +1,256 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing available-balance get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get Available Credit or Payment on Account Balance for a billing account. The credit balance can be used to settle due or past due invoices and is supported for billing accounts with agreement type Microsoft Customer Agreement. The payment on account balance is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Online Services Program. + + :example: AvailableBalanceGetByBillingAccount + az billing available-balance get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/availablebalance/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AvailableBalancesGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AvailableBalancesGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/availableBalance/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.amount = AAZObjectType() + properties.payments_on_account = AAZListType( + serialized_name="paymentsOnAccount", + flags={"read_only": True}, + ) + properties.total_payments_on_account = AAZObjectType( + serialized_name="totalPaymentsOnAccount", + ) + + amount = cls._schema_on_200.properties.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments_on_account = cls._schema_on_200.properties.payments_on_account + payments_on_account.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.payments_on_account.Element + _element.amount = AAZObjectType() + _element.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + _element.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.invoice_id = AAZStrType( + serialized_name="invoiceId", + flags={"read_only": True}, + ) + _element.invoice_name = AAZStrType( + serialized_name="invoiceName", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.properties.payments_on_account.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_payments_on_account = cls._schema_on_200.properties.total_payments_on_account + total_payments_on_account.currency = AAZStrType( + flags={"read_only": True}, + ) + total_payments_on_account.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/available_balance/_get_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/available_balance/_get_by_billing_profile.py new file mode 100644 index 00000000000..af7b23775cb --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/available_balance/_get_by_billing_profile.py @@ -0,0 +1,268 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing available-balance get-by-billing-profile", +) +class GetByBillingProfile(AAZCommand): + """Get Available Credit or Payment on Account Balance for a billing profile. The credit balance can be used to settle due or past due invoices and is supported for billing accounts with agreement type Microsoft Customer Agreement. The payment on account balance is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: AvailableBalanceGetByBillingProfile + az billing available-balance get-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/availablebalance/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AvailableBalancesGetByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AvailableBalancesGetByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.amount = AAZObjectType() + properties.payments_on_account = AAZListType( + serialized_name="paymentsOnAccount", + flags={"read_only": True}, + ) + properties.total_payments_on_account = AAZObjectType( + serialized_name="totalPaymentsOnAccount", + ) + + amount = cls._schema_on_200.properties.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments_on_account = cls._schema_on_200.properties.payments_on_account + payments_on_account.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.payments_on_account.Element + _element.amount = AAZObjectType() + _element.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + _element.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.invoice_id = AAZStrType( + serialized_name="invoiceId", + flags={"read_only": True}, + ) + _element.invoice_name = AAZStrType( + serialized_name="invoiceName", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.properties.payments_on_account.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_payments_on_account = cls._schema_on_200.properties.total_payments_on_account + total_payments_on_account.currency = AAZStrType( + flags={"read_only": True}, + ) + total_payments_on_account.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingProfileHelper: + """Helper class for GetByBillingProfile""" + + +__all__ = ["GetByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_property/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/billing_property/__cmd_group.py new file mode 100644 index 00000000000..68b259610e8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_property/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing billing-property", +) +class __CMDGroup(AAZCommandGroup): + """Get and Update operations for billing properties at subscription scope. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_property/__init__.py b/src/billing/azext_billing/aaz/latest/billing/billing_property/__init__.py new file mode 100644 index 00000000000..36b53fce008 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_property/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get import * +from ._update import * diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_property/_get.py b/src/billing/azext_billing/aaz/latest/billing/billing_property/_get.py new file mode 100644 index 00000000000..8d87ebbb4f2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_property/_get.py @@ -0,0 +1,440 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing billing-property get", +) +class Get(AAZCommand): + """Get the billing properties for a subscription + + :example: BillingPropertyGetMCA + az billing billing-property get + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.billing/billingproperty/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.include_billing_country = AAZBoolArg( + options=["--include-billing-country"], + help="A flag that specifies whether or not to include billing country.", + default=False, + ) + _args_schema.include_transition_status = AAZBoolArg( + options=["--include-transition-status"], + help="A flag that specifies whether or not to include transition status for billing accounts with agreement type Microsoft Customer Agreement.", + default=False, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPropertyGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPropertyGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "includeBillingCountry", self.ctx.args.include_billing_country, + ), + **self.serialize_query_param( + "includeTransitionStatus", self.ctx.args.include_transition_status, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_admin_notification_email_address = AAZStrType( + serialized_name="accountAdminNotificationEmailAddress", + flags={"read_only": True}, + ) + properties.billing_account_agreement_type = AAZStrType( + serialized_name="billingAccountAgreementType", + flags={"read_only": True}, + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_sold_to_country = AAZStrType( + serialized_name="billingAccountSoldToCountry", + flags={"read_only": True}, + ) + properties.billing_account_status = AAZStrType( + serialized_name="billingAccountStatus", + flags={"read_only": True}, + ) + properties.billing_account_status_reason_code = AAZStrType( + serialized_name="billingAccountStatusReasonCode", + flags={"read_only": True}, + ) + properties.billing_account_sub_type = AAZStrType( + serialized_name="billingAccountSubType", + flags={"read_only": True}, + ) + properties.billing_account_type = AAZStrType( + serialized_name="billingAccountType", + flags={"read_only": True}, + ) + properties.billing_currency = AAZStrType( + serialized_name="billingCurrency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_payment_method_family = AAZStrType( + serialized_name="billingProfilePaymentMethodFamily", + flags={"read_only": True}, + ) + properties.billing_profile_payment_method_type = AAZStrType( + serialized_name="billingProfilePaymentMethodType", + flags={"read_only": True}, + ) + properties.billing_profile_spending_limit = AAZStrType( + serialized_name="billingProfileSpendingLimit", + flags={"read_only": True}, + ) + properties.billing_profile_spending_limit_details = AAZListType( + serialized_name="billingProfileSpendingLimitDetails", + flags={"read_only": True}, + ) + properties.billing_profile_status = AAZStrType( + serialized_name="billingProfileStatus", + flags={"read_only": True}, + ) + properties.billing_profile_status_reason_code = AAZStrType( + serialized_name="billingProfileStatusReasonCode", + flags={"read_only": True}, + ) + properties.billing_tenant_id = AAZStrType( + serialized_name="billingTenantId", + flags={"read_only": True}, + ) + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_status = AAZStrType( + serialized_name="customerStatus", + flags={"read_only": True}, + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_status = AAZStrType( + serialized_name="invoiceSectionStatus", + flags={"read_only": True}, + ) + properties.invoice_section_status_reason_code = AAZStrType( + serialized_name="invoiceSectionStatusReasonCode", + flags={"read_only": True}, + ) + properties.is_account_admin = AAZBoolType( + serialized_name="isAccountAdmin", + flags={"read_only": True}, + ) + properties.is_transitioned_billing_account = AAZBoolType( + serialized_name="isTransitionedBillingAccount", + flags={"read_only": True}, + ) + properties.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + properties.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.subscription_billing_status = AAZStrType( + serialized_name="subscriptionBillingStatus", + flags={"read_only": True}, + ) + properties.subscription_billing_status_details = AAZListType( + serialized_name="subscriptionBillingStatusDetails", + flags={"read_only": True}, + ) + properties.subscription_billing_type = AAZStrType( + serialized_name="subscriptionBillingType", + flags={"read_only": True}, + ) + properties.subscription_service_usage_address = AAZObjectType( + serialized_name="subscriptionServiceUsageAddress", + ) + properties.subscription_workload_type = AAZStrType( + serialized_name="subscriptionWorkloadType", + flags={"read_only": True}, + ) + + billing_profile_spending_limit_details = cls._schema_on_200.properties.billing_profile_spending_limit_details + billing_profile_spending_limit_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.billing_profile_spending_limit_details.Element + _element.amount = AAZFloatType() + _element.currency = AAZStrType() + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.status = AAZStrType() + _element.type = AAZStrType() + + enrollment_details = cls._schema_on_200.properties.enrollment_details + enrollment_details.department_display_name = AAZStrType( + serialized_name="departmentDisplayName", + ) + enrollment_details.department_id = AAZStrType( + serialized_name="departmentId", + ) + enrollment_details.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + ) + enrollment_details.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + ) + enrollment_details.enrollment_account_status = AAZStrType( + serialized_name="enrollmentAccountStatus", + ) + + subscription_billing_status_details = cls._schema_on_200.properties.subscription_billing_status_details + subscription_billing_status_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.subscription_billing_status_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + subscription_service_usage_address = cls._schema_on_200.properties.subscription_service_usage_address + subscription_service_usage_address.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + subscription_service_usage_address.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + subscription_service_usage_address.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + subscription_service_usage_address.city = AAZStrType() + subscription_service_usage_address.company_name = AAZStrType( + serialized_name="companyName", + ) + subscription_service_usage_address.country = AAZStrType( + flags={"required": True}, + ) + subscription_service_usage_address.district = AAZStrType() + subscription_service_usage_address.email = AAZStrType() + subscription_service_usage_address.first_name = AAZStrType( + serialized_name="firstName", + ) + subscription_service_usage_address.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + subscription_service_usage_address.last_name = AAZStrType( + serialized_name="lastName", + ) + subscription_service_usage_address.middle_name = AAZStrType( + serialized_name="middleName", + ) + subscription_service_usage_address.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + subscription_service_usage_address.postal_code = AAZStrType( + serialized_name="postalCode", + ) + subscription_service_usage_address.region = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_property/_update.py b/src/billing/azext_billing/aaz/latest/billing/billing_property/_update.py new file mode 100644 index 00000000000..698a13a901b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_property/_update.py @@ -0,0 +1,593 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing billing-property update", +) +class Update(AAZCommand): + """Update the billing property of a subscription. Currently, cost center can be updated for billing accounts with agreement type Microsoft Customer Agreement and subscription service usage address can be updated for billing accounts with agreement type Microsoft Online Service Program. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.billing/billingproperty/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.cost_center = AAZStrArg( + options=["--cost-center"], + arg_group="Properties", + help="The cost center applied to the subscription. Available for agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. This property can be updated via patch.", + ) + _args_schema.enrollment_details = AAZObjectArg( + options=["--enrollment-details"], + arg_group="Properties", + help="The enrollment details for the subscription. Available for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.subscription_service_usage_address = AAZObjectArg( + options=["--subscription-service-usage-address"], + arg_group="Properties", + help="The address of the individual or organization where service subscription is being used. Available for agreement type Microsoft Online Services Program. This property can be updated via patch.", + ) + + enrollment_details = cls._args_schema.enrollment_details + enrollment_details.department_display_name = AAZStrArg( + options=["department-display-name"], + help="The name of the department", + ) + enrollment_details.department_id = AAZStrArg( + options=["department-id"], + help="The ID that uniquely identifies the department.", + ) + enrollment_details.enrollment_account_display_name = AAZStrArg( + options=["enrollment-account-display-name"], + help="The name of the enrollment account.", + ) + enrollment_details.enrollment_account_id = AAZStrArg( + options=["enrollment-account-id"], + help="The ID that uniquely identifies an enrollment account.", + ) + enrollment_details.enrollment_account_status = AAZStrArg( + options=["enrollment-account-status"], + help="The status of the enrollment account.", + ) + + subscription_service_usage_address = cls._args_schema.subscription_service_usage_address + subscription_service_usage_address.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + subscription_service_usage_address.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + ) + subscription_service_usage_address.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + ) + subscription_service_usage_address.city = AAZStrArg( + options=["city"], + help="Address city.", + ) + subscription_service_usage_address.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + ) + subscription_service_usage_address.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + subscription_service_usage_address.district = AAZStrArg( + options=["district"], + help="Address district.", + ) + subscription_service_usage_address.email = AAZStrArg( + options=["email"], + help="Email address.", + ) + subscription_service_usage_address.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + ) + subscription_service_usage_address.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + ) + subscription_service_usage_address.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + ) + subscription_service_usage_address.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + ) + subscription_service_usage_address.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + ) + subscription_service_usage_address.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + ) + subscription_service_usage_address.region = AAZStrArg( + options=["region"], + help="Address region.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPropertyUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPropertyUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("costCenter", AAZStrType, ".cost_center") + properties.set_prop("enrollmentDetails", AAZObjectType, ".enrollment_details") + properties.set_prop("subscriptionServiceUsageAddress", AAZObjectType, ".subscription_service_usage_address") + + enrollment_details = _builder.get(".properties.enrollmentDetails") + if enrollment_details is not None: + enrollment_details.set_prop("departmentDisplayName", AAZStrType, ".department_display_name") + enrollment_details.set_prop("departmentId", AAZStrType, ".department_id") + enrollment_details.set_prop("enrollmentAccountDisplayName", AAZStrType, ".enrollment_account_display_name") + enrollment_details.set_prop("enrollmentAccountId", AAZStrType, ".enrollment_account_id") + enrollment_details.set_prop("enrollmentAccountStatus", AAZStrType, ".enrollment_account_status") + + subscription_service_usage_address = _builder.get(".properties.subscriptionServiceUsageAddress") + if subscription_service_usage_address is not None: + subscription_service_usage_address.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + subscription_service_usage_address.set_prop("addressLine2", AAZStrType, ".address_line2") + subscription_service_usage_address.set_prop("addressLine3", AAZStrType, ".address_line3") + subscription_service_usage_address.set_prop("city", AAZStrType, ".city") + subscription_service_usage_address.set_prop("companyName", AAZStrType, ".company_name") + subscription_service_usage_address.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + subscription_service_usage_address.set_prop("district", AAZStrType, ".district") + subscription_service_usage_address.set_prop("email", AAZStrType, ".email") + subscription_service_usage_address.set_prop("firstName", AAZStrType, ".first_name") + subscription_service_usage_address.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + subscription_service_usage_address.set_prop("lastName", AAZStrType, ".last_name") + subscription_service_usage_address.set_prop("middleName", AAZStrType, ".middle_name") + subscription_service_usage_address.set_prop("phoneNumber", AAZStrType, ".phone_number") + subscription_service_usage_address.set_prop("postalCode", AAZStrType, ".postal_code") + subscription_service_usage_address.set_prop("region", AAZStrType, ".region") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_admin_notification_email_address = AAZStrType( + serialized_name="accountAdminNotificationEmailAddress", + flags={"read_only": True}, + ) + properties.billing_account_agreement_type = AAZStrType( + serialized_name="billingAccountAgreementType", + flags={"read_only": True}, + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_sold_to_country = AAZStrType( + serialized_name="billingAccountSoldToCountry", + flags={"read_only": True}, + ) + properties.billing_account_status = AAZStrType( + serialized_name="billingAccountStatus", + flags={"read_only": True}, + ) + properties.billing_account_status_reason_code = AAZStrType( + serialized_name="billingAccountStatusReasonCode", + flags={"read_only": True}, + ) + properties.billing_account_sub_type = AAZStrType( + serialized_name="billingAccountSubType", + flags={"read_only": True}, + ) + properties.billing_account_type = AAZStrType( + serialized_name="billingAccountType", + flags={"read_only": True}, + ) + properties.billing_currency = AAZStrType( + serialized_name="billingCurrency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_payment_method_family = AAZStrType( + serialized_name="billingProfilePaymentMethodFamily", + flags={"read_only": True}, + ) + properties.billing_profile_payment_method_type = AAZStrType( + serialized_name="billingProfilePaymentMethodType", + flags={"read_only": True}, + ) + properties.billing_profile_spending_limit = AAZStrType( + serialized_name="billingProfileSpendingLimit", + flags={"read_only": True}, + ) + properties.billing_profile_spending_limit_details = AAZListType( + serialized_name="billingProfileSpendingLimitDetails", + flags={"read_only": True}, + ) + properties.billing_profile_status = AAZStrType( + serialized_name="billingProfileStatus", + flags={"read_only": True}, + ) + properties.billing_profile_status_reason_code = AAZStrType( + serialized_name="billingProfileStatusReasonCode", + flags={"read_only": True}, + ) + properties.billing_tenant_id = AAZStrType( + serialized_name="billingTenantId", + flags={"read_only": True}, + ) + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_status = AAZStrType( + serialized_name="customerStatus", + flags={"read_only": True}, + ) + properties.enrollment_details = AAZObjectType( + serialized_name="enrollmentDetails", + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_status = AAZStrType( + serialized_name="invoiceSectionStatus", + flags={"read_only": True}, + ) + properties.invoice_section_status_reason_code = AAZStrType( + serialized_name="invoiceSectionStatusReasonCode", + flags={"read_only": True}, + ) + properties.is_account_admin = AAZBoolType( + serialized_name="isAccountAdmin", + flags={"read_only": True}, + ) + properties.is_transitioned_billing_account = AAZBoolType( + serialized_name="isTransitionedBillingAccount", + flags={"read_only": True}, + ) + properties.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + properties.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.subscription_billing_status = AAZStrType( + serialized_name="subscriptionBillingStatus", + flags={"read_only": True}, + ) + properties.subscription_billing_status_details = AAZListType( + serialized_name="subscriptionBillingStatusDetails", + flags={"read_only": True}, + ) + properties.subscription_billing_type = AAZStrType( + serialized_name="subscriptionBillingType", + flags={"read_only": True}, + ) + properties.subscription_service_usage_address = AAZObjectType( + serialized_name="subscriptionServiceUsageAddress", + ) + properties.subscription_workload_type = AAZStrType( + serialized_name="subscriptionWorkloadType", + flags={"read_only": True}, + ) + + billing_profile_spending_limit_details = cls._schema_on_200.properties.billing_profile_spending_limit_details + billing_profile_spending_limit_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.billing_profile_spending_limit_details.Element + _element.amount = AAZFloatType() + _element.currency = AAZStrType() + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.status = AAZStrType() + _element.type = AAZStrType() + + enrollment_details = cls._schema_on_200.properties.enrollment_details + enrollment_details.department_display_name = AAZStrType( + serialized_name="departmentDisplayName", + ) + enrollment_details.department_id = AAZStrType( + serialized_name="departmentId", + ) + enrollment_details.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + ) + enrollment_details.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + ) + enrollment_details.enrollment_account_status = AAZStrType( + serialized_name="enrollmentAccountStatus", + ) + + subscription_billing_status_details = cls._schema_on_200.properties.subscription_billing_status_details + subscription_billing_status_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.subscription_billing_status_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + subscription_service_usage_address = cls._schema_on_200.properties.subscription_service_usage_address + subscription_service_usage_address.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + subscription_service_usage_address.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + subscription_service_usage_address.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + subscription_service_usage_address.city = AAZStrType() + subscription_service_usage_address.company_name = AAZStrType( + serialized_name="companyName", + ) + subscription_service_usage_address.country = AAZStrType( + flags={"required": True}, + ) + subscription_service_usage_address.district = AAZStrType() + subscription_service_usage_address.email = AAZStrType() + subscription_service_usage_address.first_name = AAZStrType( + serialized_name="firstName", + ) + subscription_service_usage_address.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + subscription_service_usage_address.last_name = AAZStrType( + serialized_name="lastName", + ) + subscription_service_usage_address.middle_name = AAZStrType( + serialized_name="middleName", + ) + subscription_service_usage_address.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + subscription_service_usage_address.postal_code = AAZStrType( + serialized_name="postalCode", + ) + subscription_service_usage_address.region = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/__cmd_group.py new file mode 100644 index 00000000000..5c0bd94a9b7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing billing-subscription-aliases", +) +class __CMDGroup(AAZCommandGroup): + """Create, Update, Get and List operations on billing subscription scope for alias Id. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/__init__.py b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/__init__.py new file mode 100644 index 00000000000..ec61f84eabc --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._get import * +from ._list_by_billing_account import * +from ._update import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_create.py b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_create.py new file mode 100644 index 00000000000..402f4a2f257 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_create.py @@ -0,0 +1,630 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing billing-subscription-aliases create", +) +class Create(AAZCommand): + """Create a billing subscription by its alias ID. The operation is supported for seat based billing subscriptions. + + :example: BillingSubscriptionAliasCreateOrUpdate + az billing billing-subscription-aliases create --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --alias-name c356b7c7-7545-4686-b843-c1a49cf853fc --billing-frequency P1M --display-name Subscription 3 --quantity 1 --sku-id 0001 --term-duration P1M + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptionaliases/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.alias_name = AAZStrArg( + options=["--alias-name"], + help="The ID that uniquely identifies a subscription alias.", + required=True, + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.auto_renew = AAZStrArg( + options=["--auto-renew"], + arg_group="Properties", + help="Indicates whether auto renewal is turned on or off for a product.", + enum={"Off": "Off", "On": "On"}, + ) + _args_schema.beneficiary = AAZObjectArg( + options=["--beneficiary"], + arg_group="Properties", + help="The beneficiary of the billing subscription.", + ) + _args_schema.beneficiary_tenant_id = AAZStrArg( + options=["--beneficiary-tenant-id"], + arg_group="Properties", + help="The provisioning tenant of the subscription.", + ) + _args_schema.billing_frequency = AAZStrArg( + options=["--billing-frequency"], + arg_group="Properties", + help="The billing frequency in ISO8601 format of product in the subscription. Example: P1M, P3M, P1Y", + ) + _args_schema.billing_profile_id = AAZStrArg( + options=["--billing-profile-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies a billing profile.", + ) + _args_schema.consumption_cost_center = AAZStrArg( + options=["--consumption-cost-center"], + arg_group="Properties", + help="The cost center applied to the subscription. This field is only available for consumption subscriptions of Microsoft Customer Agreement or Enterprise Agreement Type billing accounts.", + ) + _args_schema.customer_id = AAZStrArg( + options=["--customer-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies a customer.", + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the billing subscription.", + ) + _args_schema.invoice_section_id = AAZStrArg( + options=["--invoice-section-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies an invoice section.", + ) + _args_schema.product_type_id = AAZStrArg( + options=["--product-type-id"], + arg_group="Properties", + help="Id of the product for which the subscription is purchased.", + ) + _args_schema.provisioning_tenant_id = AAZStrArg( + options=["--provisioning-tenant-id"], + arg_group="Properties", + help="The tenant in which the subscription is provisioned.", + ) + _args_schema.quantity = AAZIntArg( + options=["--quantity"], + arg_group="Properties", + help="The quantity of licenses or fulfillment units for the subscription.", + ) + _args_schema.sku_id = AAZStrArg( + options=["--sku-id"], + arg_group="Properties", + help="The SKU ID of the product for which the subscription is purchased. This field is is only available for Microsoft Customer Agreement billing accounts.", + ) + _args_schema.term_duration = AAZStrArg( + options=["--term-duration"], + arg_group="Properties", + help="The duration in ISO8601 format for which you can use the subscription. Example: P1M, P3M, P1Y", + ) + + beneficiary = cls._args_schema.beneficiary + beneficiary.object_id = AAZStrArg( + options=["object-id"], + help="The ID that uniquely identifies a user in a tenant.", + ) + beneficiary.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The ID that uniquely identifies a tenant.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingSubscriptionsAliasesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsAliasesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases/{aliasName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "aliasName", self.ctx.args.alias_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("autoRenew", AAZStrType, ".auto_renew") + properties.set_prop("beneficiary", AAZObjectType, ".beneficiary") + properties.set_prop("beneficiaryTenantId", AAZStrType, ".beneficiary_tenant_id") + properties.set_prop("billingFrequency", AAZStrType, ".billing_frequency") + properties.set_prop("billingProfileId", AAZStrType, ".billing_profile_id") + properties.set_prop("consumptionCostCenter", AAZStrType, ".consumption_cost_center") + properties.set_prop("customerId", AAZStrType, ".customer_id") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("invoiceSectionId", AAZStrType, ".invoice_section_id") + properties.set_prop("productTypeId", AAZStrType, ".product_type_id") + properties.set_prop("provisioningTenantId", AAZStrType, ".provisioning_tenant_id") + properties.set_prop("quantity", AAZIntType, ".quantity") + properties.set_prop("skuId", AAZStrType, ".sku_id") + properties.set_prop("termDuration", AAZStrType, ".term_duration") + + beneficiary = _builder.get(".properties.beneficiary") + if beneficiary is not None: + beneficiary.set_prop("objectId", AAZStrType, ".object_id") + beneficiary.set_prop("tenantId", AAZStrType, ".tenant_id") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_subscription_id = AAZStrType( + serialized_name="billingSubscriptionId", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _CreateHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _CreateHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200_201.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200_201.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200_201.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200_201.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200_201.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200_201.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200_201.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200_201.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200_201.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Create"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_get.py b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_get.py new file mode 100644 index 00000000000..8ab7d0595e8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_get.py @@ -0,0 +1,475 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing billing-subscription-aliases get", +) +class Get(AAZCommand): + """Get a subscription by its alias ID. The operation is supported for seat based billing subscriptions. + + :example: BillingSubscriptionAliasGet + az billing billing-subscription-aliases get --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --alias-name c356b7c7-7545-4686-b843-c1a49cf853fc + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptionaliases/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.alias_name = AAZStrArg( + options=["--alias-name"], + help="The ID that uniquely identifies a subscription alias.", + required=True, + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsAliasesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsAliasesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases/{aliasName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "aliasName", self.ctx.args.alias_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_subscription_id = AAZStrType( + serialized_name="billingSubscriptionId", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _GetHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _GetHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_list_by_billing_account.py new file mode 100644 index 00000000000..b0b7d759ccc --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_list_by_billing_account.py @@ -0,0 +1,530 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing billing-subscription-aliases list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the subscription aliases for a billing account. The operation is supported for seat based billing subscriptions. + + :example: BillingSubscriptionAliasList + az billing billing-subscription-aliases list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptionaliases", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted billing subscriptions.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsAliasesListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingSubscriptionsAliasesListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_subscription_id = AAZStrType( + serialized_name="billingSubscriptionId", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.value.Element.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.value.Element.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.value.Element.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.value.Element.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.value.Element.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.value.Element.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.value.Element.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.value.Element.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_update.py b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_update.py new file mode 100644 index 00000000000..1ed715ca4b7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_update.py @@ -0,0 +1,784 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing billing-subscription-aliases update", +) +class Update(AAZCommand): + """Update a billing subscription by its alias ID. The operation is supported for seat based billing subscriptions. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptionaliases/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.alias_name = AAZStrArg( + options=["--alias-name"], + help="The ID that uniquely identifies a subscription alias.", + required=True, + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.auto_renew = AAZStrArg( + options=["--auto-renew"], + arg_group="Properties", + help="Indicates whether auto renewal is turned on or off for a product.", + nullable=True, + enum={"Off": "Off", "On": "On"}, + ) + _args_schema.beneficiary = AAZObjectArg( + options=["--beneficiary"], + arg_group="Properties", + help="The beneficiary of the billing subscription.", + nullable=True, + ) + _args_schema.beneficiary_tenant_id = AAZStrArg( + options=["--beneficiary-tenant-id"], + arg_group="Properties", + help="The provisioning tenant of the subscription.", + nullable=True, + ) + _args_schema.billing_frequency = AAZStrArg( + options=["--billing-frequency"], + arg_group="Properties", + help="The billing frequency in ISO8601 format of product in the subscription. Example: P1M, P3M, P1Y", + nullable=True, + ) + _args_schema.billing_profile_id = AAZStrArg( + options=["--billing-profile-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies a billing profile.", + nullable=True, + ) + _args_schema.consumption_cost_center = AAZStrArg( + options=["--consumption-cost-center"], + arg_group="Properties", + help="The cost center applied to the subscription. This field is only available for consumption subscriptions of Microsoft Customer Agreement or Enterprise Agreement Type billing accounts.", + nullable=True, + ) + _args_schema.customer_id = AAZStrArg( + options=["--customer-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies a customer.", + nullable=True, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the billing subscription.", + nullable=True, + ) + _args_schema.invoice_section_id = AAZStrArg( + options=["--invoice-section-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies an invoice section.", + nullable=True, + ) + _args_schema.product_type_id = AAZStrArg( + options=["--product-type-id"], + arg_group="Properties", + help="Id of the product for which the subscription is purchased.", + nullable=True, + ) + _args_schema.provisioning_tenant_id = AAZStrArg( + options=["--provisioning-tenant-id"], + arg_group="Properties", + help="The tenant in which the subscription is provisioned.", + nullable=True, + ) + _args_schema.quantity = AAZIntArg( + options=["--quantity"], + arg_group="Properties", + help="The quantity of licenses or fulfillment units for the subscription.", + nullable=True, + ) + _args_schema.sku_id = AAZStrArg( + options=["--sku-id"], + arg_group="Properties", + help="The SKU ID of the product for which the subscription is purchased. This field is is only available for Microsoft Customer Agreement billing accounts.", + nullable=True, + ) + _args_schema.term_duration = AAZStrArg( + options=["--term-duration"], + arg_group="Properties", + help="The duration in ISO8601 format for which you can use the subscription. Example: P1M, P3M, P1Y", + nullable=True, + ) + + beneficiary = cls._args_schema.beneficiary + beneficiary.object_id = AAZStrArg( + options=["object-id"], + help="The ID that uniquely identifies a user in a tenant.", + nullable=True, + ) + beneficiary.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The ID that uniquely identifies a tenant.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsAliasesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.BillingSubscriptionsAliasesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsAliasesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases/{aliasName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "aliasName", self.ctx.args.alias_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_billing_subscription_alias_read(cls._schema_on_200) + + return cls._schema_on_200 + + class BillingSubscriptionsAliasesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases/{aliasName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "aliasName", self.ctx.args.alias_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_billing_subscription_alias_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("autoRenew", AAZStrType, ".auto_renew") + properties.set_prop("beneficiary", AAZObjectType, ".beneficiary") + properties.set_prop("beneficiaryTenantId", AAZStrType, ".beneficiary_tenant_id") + properties.set_prop("billingFrequency", AAZStrType, ".billing_frequency") + properties.set_prop("billingProfileId", AAZStrType, ".billing_profile_id") + properties.set_prop("consumptionCostCenter", AAZStrType, ".consumption_cost_center") + properties.set_prop("customerId", AAZStrType, ".customer_id") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("invoiceSectionId", AAZStrType, ".invoice_section_id") + properties.set_prop("productTypeId", AAZStrType, ".product_type_id") + properties.set_prop("provisioningTenantId", AAZStrType, ".provisioning_tenant_id") + properties.set_prop("quantity", AAZIntType, ".quantity") + properties.set_prop("skuId", AAZStrType, ".sku_id") + properties.set_prop("termDuration", AAZStrType, ".term_duration") + + beneficiary = _builder.get(".properties.beneficiary") + if beneficiary is not None: + beneficiary.set_prop("objectId", AAZStrType, ".object_id") + beneficiary.set_prop("tenantId", AAZStrType, ".tenant_id") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + _schema_billing_subscription_alias_read = None + + @classmethod + def _build_schema_billing_subscription_alias_read(cls, _schema): + if cls._schema_billing_subscription_alias_read is not None: + _schema.id = cls._schema_billing_subscription_alias_read.id + _schema.name = cls._schema_billing_subscription_alias_read.name + _schema.properties = cls._schema_billing_subscription_alias_read.properties + _schema.system_data = cls._schema_billing_subscription_alias_read.system_data + _schema.tags = cls._schema_billing_subscription_alias_read.tags + _schema.type = cls._schema_billing_subscription_alias_read.type + return + + cls._schema_billing_subscription_alias_read = _schema_billing_subscription_alias_read = AAZObjectType() + + billing_subscription_alias_read = _schema_billing_subscription_alias_read + billing_subscription_alias_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_subscription_alias_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_subscription_alias_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + billing_subscription_alias_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_subscription_alias_read.tags = AAZDictType() + billing_subscription_alias_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_subscription_alias_read.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_subscription_id = AAZStrType( + serialized_name="billingSubscriptionId", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + cls._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + cls._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = _schema_billing_subscription_alias_read.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = _schema_billing_subscription_alias_read.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = _schema_billing_subscription_alias_read.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = _schema_billing_subscription_alias_read.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = _schema_billing_subscription_alias_read.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = _schema_billing_subscription_alias_read.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = _schema_billing_subscription_alias_read.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = _schema_billing_subscription_alias_read.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = _schema_billing_subscription_alias_read.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = _schema_billing_subscription_alias_read.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = _schema_billing_subscription_alias_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_subscription_alias_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_subscription_alias_read.id + _schema.name = cls._schema_billing_subscription_alias_read.name + _schema.properties = cls._schema_billing_subscription_alias_read.properties + _schema.system_data = cls._schema_billing_subscription_alias_read.system_data + _schema.tags = cls._schema_billing_subscription_alias_read.tags + _schema.type = cls._schema_billing_subscription_alias_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_wait.py b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_wait.py new file mode 100644 index 00000000000..08457f8e142 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/billing_subscription_aliases/_wait.py @@ -0,0 +1,471 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing billing-subscription-aliases wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptionaliases/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.alias_name = AAZStrArg( + options=["--alias-name"], + help="The ID that uniquely identifies a subscription alias.", + required=True, + ) + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsAliasesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class BillingSubscriptionsAliasesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptionAliases/{aliasName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "aliasName", self.ctx.args.alias_name, + required=True, + ), + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_subscription_id = AAZStrType( + serialized_name="billingSubscriptionId", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _WaitHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _WaitHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/customer/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/customer/__cmd_group.py new file mode 100644 index 00000000000..350d7494871 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/customer/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing customer", +) +class __CMDGroup(AAZCommandGroup): + """Get, List operations at multiple scopes to help identify customers + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/customer/__init__.py b/src/billing/azext_billing/aaz/latest/billing/customer/__init__.py new file mode 100644 index 00000000000..fb4e9ca5616 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/customer/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get import * +from ._get_by_billing_account import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * diff --git a/src/billing/azext_billing/aaz/latest/billing/customer/_get.py b/src/billing/azext_billing/aaz/latest/billing/customer/_get.py new file mode 100644 index 00000000000..96e121b2edf --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/customer/_get.py @@ -0,0 +1,274 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing customer get", +) +class Get(AAZCommand): + """Get a customer by its ID. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: CustomersGet + az billing customer get --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.CustomersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CustomersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.resellers = AAZListType() + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + + enabled_azure_plans = cls._schema_on_200.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + resellers = cls._schema_on_200.properties.resellers + resellers.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.resellers.Element + _element.description = AAZStrType( + flags={"read_only": True}, + ) + _element.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/customer/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/customer/_get_by_billing_account.py new file mode 100644 index 00000000000..ec78e241da1 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/customer/_get_by_billing_account.py @@ -0,0 +1,262 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing customer get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get a customer by its ID at billing account level. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: CustomersGetByBillingAccount + az billing customer get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.CustomersGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CustomersGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.resellers = AAZListType() + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + + enabled_azure_plans = cls._schema_on_200.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + resellers = cls._schema_on_200.properties.resellers + resellers.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.resellers.Element + _element.description = AAZStrType( + flags={"read_only": True}, + ) + _element.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/customer/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/customer/_list_by_billing_account.py new file mode 100644 index 00000000000..f6376d965c6 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/customer/_list_by_billing_account.py @@ -0,0 +1,313 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing customer list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the customers that are billed to a billing account. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: CustomersListByBillingAccount + az billing customer list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand enabledAzurePlans and resellers", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.CustomersListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class CustomersListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.resellers = AAZListType() + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + + enabled_azure_plans = cls._schema_on_200.value.Element.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + resellers = cls._schema_on_200.value.Element.properties.resellers + resellers.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.resellers.Element + _element.description = AAZStrType( + flags={"read_only": True}, + ) + _element.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.value.Element.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/customer/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/customer/_list_by_billing_profile.py new file mode 100644 index 00000000000..5b41a5351ab --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/customer/_list_by_billing_profile.py @@ -0,0 +1,325 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing customer list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List the customers that are billed to a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: CustomersListByBillingProfile + az billing customer list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand enabledAzurePlans and resellers", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.CustomersListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class CustomersListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.resellers = AAZListType() + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + + enabled_azure_plans = cls._schema_on_200.value.Element.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + resellers = cls._schema_on_200.value.Element.properties.resellers + resellers.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.resellers.Element + _element.description = AAZStrType( + flags={"read_only": True}, + ) + _element.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.value.Element.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/department/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/department/__cmd_group.py new file mode 100644 index 00000000000..5c749565803 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/department/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing department", +) +class __CMDGroup(AAZCommandGroup): + """Get and List operations at billing account scope to identify Departments and is only for EA customers + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/department/__init__.py b/src/billing/azext_billing/aaz/latest/billing/department/__init__.py new file mode 100644 index 00000000000..400055b1bbd --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/department/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get import * +from ._list_by_billing_account import * diff --git a/src/billing/azext_billing/aaz/latest/billing/department/_get.py b/src/billing/azext_billing/aaz/latest/billing/department/_get.py new file mode 100644 index 00000000000..b02145a6592 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/department/_get.py @@ -0,0 +1,219 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing department get", +) +class Get(AAZCommand): + """Get a department by ID. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: DepartmentGet + az billing department get --billing-account-name 456598 --department-name 164821 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DepartmentsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DepartmentsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/department/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/department/_list_by_billing_account.py new file mode 100644 index 00000000000..f16bfbc9e7b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/department/_list_by_billing_account.py @@ -0,0 +1,256 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing department list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the departments that a user has access to. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: DepartmentsListByBillingAccount + az billing department list-by-billing-account --billing-account-name 456598 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DepartmentsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class DepartmentsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/__cmd_group.py new file mode 100644 index 00000000000..8cb2477fc62 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing enrollment-account", +) +class __CMDGroup(AAZCommandGroup): + """Get and List operations for EA customers at Enrollment Account, Department, Account level + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/__init__.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/__init__.py new file mode 100644 index 00000000000..6c7bdb0a1ce --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get import * +from ._get_by_department import * +from ._list_by_billing_account import * +from ._list_by_department import * diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_get.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_get.py new file mode 100644 index 00000000000..481c3b396d7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_get.py @@ -0,0 +1,243 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing enrollment-account get", +) +class Get(AAZCommand): + """Get an enrollment account by ID. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: EnrollmentAccountGet + az billing enrollment-account get --billing-account-name 6564892 --enrollment-account-name 257698 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnrollmentAccountsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class EnrollmentAccountsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_owner = AAZStrType( + serialized_name="accountOwner", + flags={"read_only": True}, + ) + properties.auth_type = AAZStrType( + serialized_name="authType", + flags={"read_only": True}, + ) + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.department_display_name = AAZStrType( + serialized_name="departmentDisplayName", + flags={"read_only": True}, + ) + properties.department_id = AAZStrType( + serialized_name="departmentId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.is_dev_test_enabled = AAZBoolType( + serialized_name="isDevTestEnabled", + ) + properties.start_date = AAZStrType( + serialized_name="startDate", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_get_by_department.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_get_by_department.py new file mode 100644 index 00000000000..085837b693c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_get_by_department.py @@ -0,0 +1,255 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing enrollment-account get-by-department", +) +class GetByDepartment(AAZCommand): + """Get an enrollment account by department. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: EnrollmentAccountByDepartment + az billing enrollment-account get-by-department --billing-account-name 6564892 --department-name 164821 --enrollment-account-name 257698 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/enrollmentaccounts/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnrollmentAccountsGetByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class EnrollmentAccountsGetByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/enrollmentAccounts/{enrollmentAccountName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_owner = AAZStrType( + serialized_name="accountOwner", + flags={"read_only": True}, + ) + properties.auth_type = AAZStrType( + serialized_name="authType", + flags={"read_only": True}, + ) + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.department_display_name = AAZStrType( + serialized_name="departmentDisplayName", + flags={"read_only": True}, + ) + properties.department_id = AAZStrType( + serialized_name="departmentId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.is_dev_test_enabled = AAZBoolType( + serialized_name="isDevTestEnabled", + ) + properties.start_date = AAZStrType( + serialized_name="startDate", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByDepartmentHelper: + """Helper class for GetByDepartment""" + + +__all__ = ["GetByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_list_by_billing_account.py new file mode 100644 index 00000000000..be2fb358a07 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_list_by_billing_account.py @@ -0,0 +1,287 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing enrollment-account list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the enrollment accounts for a billing account. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: EnrollmentAccountsListByBillingAccount + az billing enrollment-account list-by-billing-account --billing-account-name 6564892 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnrollmentAccountsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class EnrollmentAccountsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.account_owner = AAZStrType( + serialized_name="accountOwner", + flags={"read_only": True}, + ) + properties.auth_type = AAZStrType( + serialized_name="authType", + flags={"read_only": True}, + ) + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.department_display_name = AAZStrType( + serialized_name="departmentDisplayName", + flags={"read_only": True}, + ) + properties.department_id = AAZStrType( + serialized_name="departmentId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.is_dev_test_enabled = AAZBoolType( + serialized_name="isDevTestEnabled", + ) + properties.start_date = AAZStrType( + serialized_name="startDate", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_list_by_department.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_list_by_department.py new file mode 100644 index 00000000000..a7bb2ddd29e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/_list_by_department.py @@ -0,0 +1,299 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing enrollment-account list-by-department", +) +class ListByDepartment(AAZCommand): + """List the enrollment accounts for a department. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: EnrollmentAccountsListByDepartment + az billing enrollment-account list-by-department --billing-account-name 6564892 --department-name 164821 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/enrollmentaccounts", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnrollmentAccountsListByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class EnrollmentAccountsListByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/enrollmentAccounts", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.account_owner = AAZStrType( + serialized_name="accountOwner", + flags={"read_only": True}, + ) + properties.auth_type = AAZStrType( + serialized_name="authType", + flags={"read_only": True}, + ) + properties.cost_center = AAZStrType( + serialized_name="costCenter", + ) + properties.department_display_name = AAZStrType( + serialized_name="departmentDisplayName", + flags={"read_only": True}, + ) + properties.department_id = AAZStrType( + serialized_name="departmentId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.is_dev_test_enabled = AAZBoolType( + serialized_name="isDevTestEnabled", + ) + properties.start_date = AAZStrType( + serialized_name="startDate", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByDepartmentHelper: + """Helper class for ListByDepartment""" + + +__all__ = ["ListByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/__cmd_group.py new file mode 100644 index 00000000000..9b885633d84 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing enrollment-account billing-permission", +) +class __CMDGroup(AAZCommandGroup): + """Manage enrollment account billing permission + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/__init__.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/__init__.py new file mode 100644 index 00000000000..d63ae5a6fc9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * diff --git a/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/_list.py b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/_list.py new file mode 100644 index 00000000000..e95b905ce93 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/enrollment_account/billing_permission/_list.py @@ -0,0 +1,189 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing enrollment-account billing-permission list", +) +class List(AAZCommand): + """List the billing permissions the caller has on an enrollment account. + """ + + _aaz_info = { + "version": "2019-10-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingpermissions", "2019-10-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The ID that uniquely identifies an enrollment account.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType( + flags={"read_only": True}, + ) + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/invoice/__cmd_group.py new file mode 100644 index 00000000000..ef007cf73d8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing invoice", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations (Download, Get, List, Amend) at different scopes around Invoices + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/__init__.py b/src/billing/azext_billing/aaz/latest/billing/invoice/__init__.py new file mode 100644 index 00000000000..e0a4fbca47c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/__init__.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._amend import * +from ._download_by_billing_account import * +from ._download_by_billing_subscription import * +from ._download_document_by_billing_account import * +from ._download_document_by_billing_subscription import * +from ._download_summary_by_ea_billing_account import * +from ._get import * +from ._get_by_billing_account import * +from ._get_by_billing_subscription import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_billing_subscription import * diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_amend.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_amend.py new file mode 100644 index 00000000000..bb25ca71002 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_amend.py @@ -0,0 +1,141 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice amend", +) +class Amend(AAZCommand): + """Regenerate an invoice by billing account name and invoice name. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: InvoicesAmend + az billing invoice amend --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --invoice-name G123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices/{}/amend", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoicesAmend(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class InvoicesAmend(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + None, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/amend", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + +class _AmendHelper: + """Helper class for Amend""" + + +__all__ = ["Amend"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_download_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_by_billing_account.py new file mode 100644 index 00000000000..75c9893ab85 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_by_billing_account.py @@ -0,0 +1,198 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice download-by-billing-account", +) +class DownloadByBillingAccount(AAZCommand): + """Gets a URL to download an invoice document. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: InvoicesDownloadByBillingAccount + az billing invoice download-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --invoice-name G123456789 --document-name 12345678 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices/{}/download", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + _args_schema.document_name = AAZStrArg( + options=["--document-name"], + help="The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit note, or a tax receipt.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoicesDownloadByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesDownloadByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "documentName", self.ctx.args.document_name, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.expiry_time = AAZStrType( + serialized_name="expiryTime", + flags={"read_only": True}, + ) + _schema_on_200.url = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _DownloadByBillingAccountHelper: + """Helper class for DownloadByBillingAccount""" + + +__all__ = ["DownloadByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_download_by_billing_subscription.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_by_billing_subscription.py new file mode 100644 index 00000000000..ff4a256b7ef --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_by_billing_subscription.py @@ -0,0 +1,190 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice download-by-billing-subscription", +) +class DownloadByBillingSubscription(AAZCommand): + """Gets a URL to download an invoice by billing subscription. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: InvoicesDownloadByBillingSubscription + az billing invoice download-by-billing-subscription --invoice-name E123456789 --document-name 12345678 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/default/billingsubscriptions/{}/invoices/{}/download", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + _args_schema.document_name = AAZStrArg( + options=["--document-name"], + help="The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit note, or a tax receipt.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoicesDownloadByBillingSubscription(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesDownloadByBillingSubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "documentName", self.ctx.args.document_name, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.expiry_time = AAZStrType( + serialized_name="expiryTime", + flags={"read_only": True}, + ) + _schema_on_200.url = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _DownloadByBillingSubscriptionHelper: + """Helper class for DownloadByBillingSubscription""" + + +__all__ = ["DownloadByBillingSubscription"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_download_document_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_document_by_billing_account.py new file mode 100644 index 00000000000..5aefab6bccf --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_document_by_billing_account.py @@ -0,0 +1,215 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice download-document-by-billing-account", +) +class DownloadDocumentByBillingAccount(AAZCommand): + """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. + + :example: InvoicesDownloadDocumentsByBillingAccount + az billing invoice download-document-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --parameters "[{document-name:12345678,invoice-name:G123456789},{document-name:12345678,invoice-name:G987654321}]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/downloaddocuments", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.parameters = AAZListArg( + options=["--parameters"], + required=True, + ) + + parameters = cls._args_schema.parameters + parameters.Element = AAZObjectArg() + + _element = cls._args_schema.parameters.Element + _element.document_name = AAZStrArg( + options=["document-name"], + help="The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit note, or a tax receipt. If omitted, the most recent invoice PDF for the invoice will be returned.", + ) + _element.invoice_name = AAZStrArg( + options=["invoice-name"], + help="The ID that uniquely identifies an invoice.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoicesDownloadDocumentsByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesDownloadDocumentsByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args.parameters, + typ=AAZListType, + typ_kwargs={"flags": {"required": True}} + ) + _builder.set_elements(AAZObjectType, ".") + + _elements = _builder.get("[]") + if _elements is not None: + _elements.set_prop("documentName", AAZStrType, ".document_name") + _elements.set_prop("invoiceName", AAZStrType, ".invoice_name") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.expiry_time = AAZStrType( + serialized_name="expiryTime", + flags={"read_only": True}, + ) + _schema_on_200.url = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _DownloadDocumentByBillingAccountHelper: + """Helper class for DownloadDocumentByBillingAccount""" + + +__all__ = ["DownloadDocumentByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_download_document_by_billing_subscription.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_document_by_billing_subscription.py new file mode 100644 index 00000000000..f9ec5f9a9af --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_document_by_billing_subscription.py @@ -0,0 +1,207 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice download-document-by-billing-subscription", +) +class DownloadDocumentByBillingSubscription(AAZCommand): + """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. + + :example: InvoicesDownloadDocumentsByBillingSubscription + az billing invoice download-document-by-billing-subscription --parameters "[{document-name:12345678,invoice-name:E123456789},{document-name:12345678,invoice-name:E987654321}]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/default/billingsubscriptions/{}/downloaddocuments", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.parameters = AAZListArg( + options=["--parameters"], + required=True, + ) + + parameters = cls._args_schema.parameters + parameters.Element = AAZObjectArg() + + _element = cls._args_schema.parameters.Element + _element.document_name = AAZStrArg( + options=["document-name"], + help="The ID that uniquely identifies an invoice document. This ID may be an identifier for an invoice PDF, a credit note, or a tax receipt. If omitted, the most recent invoice PDF for the invoice will be returned.", + ) + _element.invoice_name = AAZStrArg( + options=["invoice-name"], + help="The ID that uniquely identifies an invoice.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoicesDownloadDocumentsByBillingSubscription(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesDownloadDocumentsByBillingSubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args.parameters, + typ=AAZListType, + typ_kwargs={"flags": {"required": True}} + ) + _builder.set_elements(AAZObjectType, ".") + + _elements = _builder.get("[]") + if _elements is not None: + _elements.set_prop("documentName", AAZStrType, ".document_name") + _elements.set_prop("invoiceName", AAZStrType, ".invoice_name") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.expiry_time = AAZStrType( + serialized_name="expiryTime", + flags={"read_only": True}, + ) + _schema_on_200.url = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _DownloadDocumentByBillingSubscriptionHelper: + """Helper class for DownloadDocumentByBillingSubscription""" + + +__all__ = ["DownloadDocumentByBillingSubscription"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_download_summary_by_ea_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_summary_by_ea_billing_account.py new file mode 100644 index 00000000000..727a1c4e86b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_download_summary_by_ea_billing_account.py @@ -0,0 +1,191 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice download-summary-by-ea-billing-account", +) +class DownloadSummaryByEaBillingAccount(AAZCommand): + """Gets a URL to download the summary document for an invoice. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: InvoicesDownloadSummaryByBillingAccount + az billing invoice download-summary-by-ea-billing-account --billing-account-name 123456789 --invoice-name G123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices/{}/downloadsummary", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoicesDownloadSummaryByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesDownloadSummaryByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/downloadSummary", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.expiry_time = AAZStrType( + serialized_name="expiryTime", + flags={"read_only": True}, + ) + _schema_on_200.url = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _DownloadSummaryByEaBillingAccountHelper: + """Helper class for DownloadSummaryByEaBillingAccount""" + + +__all__ = ["DownloadSummaryByEaBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_get.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_get.py new file mode 100644 index 00000000000..b857f185340 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_get.py @@ -0,0 +1,528 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice get", +) +class Get(AAZCommand): + """Get an invoice by ID. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: InvoicesGet + az billing invoice get --invoice-name G123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/default/invoices/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoicesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.amount_due = AAZObjectType( + serialized_name="amountDue", + ) + properties.azure_prepayment_applied = AAZObjectType( + serialized_name="azurePrepaymentApplied", + ) + properties.billed_amount = AAZObjectType( + serialized_name="billedAmount", + ) + properties.billed_document_id = AAZStrType( + serialized_name="billedDocumentId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.credit_amount = AAZObjectType( + serialized_name="creditAmount", + ) + properties.credit_for_document_id = AAZStrType( + serialized_name="creditForDocumentId", + flags={"read_only": True}, + ) + properties.document_type = AAZStrType( + serialized_name="documentType", + flags={"read_only": True}, + ) + properties.documents = AAZListType( + flags={"read_only": True}, + ) + properties.due_date = AAZStrType( + serialized_name="dueDate", + flags={"read_only": True}, + ) + properties.failed_payments = AAZListType( + serialized_name="failedPayments", + flags={"read_only": True}, + ) + properties.free_azure_credit_applied = AAZObjectType( + serialized_name="freeAzureCreditApplied", + ) + properties.invoice_date = AAZStrType( + serialized_name="invoiceDate", + flags={"read_only": True}, + ) + properties.invoice_period_end_date = AAZStrType( + serialized_name="invoicePeriodEndDate", + flags={"read_only": True}, + ) + properties.invoice_period_start_date = AAZStrType( + serialized_name="invoicePeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_type = AAZStrType( + serialized_name="invoiceType", + flags={"read_only": True}, + ) + properties.is_monthly_invoice = AAZBoolType( + serialized_name="isMonthlyInvoice", + flags={"read_only": True}, + ) + properties.payments = AAZListType( + flags={"read_only": True}, + ) + properties.purchase_order_number = AAZStrType( + serialized_name="purchaseOrderNumber", + flags={"read_only": True}, + ) + properties.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + _GetHelper._build_schema_rebill_details_read(properties.rebill_details) + properties.refund_details = AAZObjectType( + serialized_name="refundDetails", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.tax_amount = AAZObjectType( + serialized_name="taxAmount", + ) + properties.total_amount = AAZObjectType( + serialized_name="totalAmount", + ) + + amount_due = cls._schema_on_200.properties.amount_due + amount_due.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_due.value = AAZFloatType( + flags={"read_only": True}, + ) + + azure_prepayment_applied = cls._schema_on_200.properties.azure_prepayment_applied + azure_prepayment_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_prepayment_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + billed_amount = cls._schema_on_200.properties.billed_amount + billed_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + billed_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + credit_amount = cls._schema_on_200.properties.credit_amount + credit_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + credit_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + documents = cls._schema_on_200.properties.documents + documents.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.documents.Element + _element.document_numbers = AAZListType( + serialized_name="documentNumbers", + flags={"read_only": True}, + ) + _element.external_url = AAZStrType( + serialized_name="externalUrl", + flags={"read_only": True}, + ) + _element.kind = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source = AAZStrType( + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + document_numbers = cls._schema_on_200.properties.documents.Element.document_numbers + document_numbers.Element = AAZStrType() + + failed_payments = cls._schema_on_200.properties.failed_payments + failed_payments.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.failed_payments.Element + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.failed_payment_reason = AAZStrType( + serialized_name="failedPaymentReason", + flags={"read_only": True}, + ) + + free_azure_credit_applied = cls._schema_on_200.properties.free_azure_credit_applied + free_azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + free_azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments = cls._schema_on_200.properties.payments + payments.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.payments.Element + _element.amount = AAZObjectType() + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.payment_method_family = AAZStrType( + serialized_name="paymentMethodFamily", + flags={"read_only": True}, + ) + _element.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + _element.payment_type = AAZStrType( + serialized_name="paymentType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.properties.payments.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_details = cls._schema_on_200.properties.refund_details + refund_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_details.approved_on = AAZStrType( + serialized_name="approvedOn", + flags={"read_only": True}, + ) + refund_details.completed_on = AAZStrType( + serialized_name="completedOn", + flags={"read_only": True}, + ) + refund_details.rebill_invoice_id = AAZStrType( + serialized_name="rebillInvoiceId", + flags={"read_only": True}, + ) + refund_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + flags={"read_only": True}, + ) + refund_details.refund_reason = AAZStrType( + serialized_name="refundReason", + flags={"read_only": True}, + ) + refund_details.refund_status = AAZStrType( + serialized_name="refundStatus", + flags={"read_only": True}, + ) + refund_details.requested_on = AAZStrType( + serialized_name="requestedOn", + flags={"read_only": True}, + ) + refund_details.transaction_count = AAZIntType( + serialized_name="transactionCount", + flags={"read_only": True}, + ) + + amount_refunded = cls._schema_on_200.properties.refund_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.properties.refund_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax_amount = cls._schema_on_200.properties.tax_amount + tax_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + tax_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_amount = cls._schema_on_200.properties.total_amount + total_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + total_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + _schema_rebill_details_read = None + + @classmethod + def _build_schema_rebill_details_read(cls, _schema): + if cls._schema_rebill_details_read is not None: + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + return + + cls._schema_rebill_details_read = _schema_rebill_details_read = AAZObjectType( + flags={"read_only": True} + ) + + rebill_details_read = _schema_rebill_details_read + rebill_details_read.credit_note_document_id = AAZStrType( + serialized_name="creditNoteDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.invoice_document_id = AAZStrType( + serialized_name="invoiceDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + cls._build_schema_rebill_details_read(rebill_details_read.rebill_details) + + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_get_by_billing_account.py new file mode 100644 index 00000000000..5784c9842fa --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_get_by_billing_account.py @@ -0,0 +1,540 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get an invoice by billing account name and ID. The operation is supported for all billing account types. + + :example: InvoicesGetByBillingAccount + az billing invoice get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --invoice-name G123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoicesGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.amount_due = AAZObjectType( + serialized_name="amountDue", + ) + properties.azure_prepayment_applied = AAZObjectType( + serialized_name="azurePrepaymentApplied", + ) + properties.billed_amount = AAZObjectType( + serialized_name="billedAmount", + ) + properties.billed_document_id = AAZStrType( + serialized_name="billedDocumentId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.credit_amount = AAZObjectType( + serialized_name="creditAmount", + ) + properties.credit_for_document_id = AAZStrType( + serialized_name="creditForDocumentId", + flags={"read_only": True}, + ) + properties.document_type = AAZStrType( + serialized_name="documentType", + flags={"read_only": True}, + ) + properties.documents = AAZListType( + flags={"read_only": True}, + ) + properties.due_date = AAZStrType( + serialized_name="dueDate", + flags={"read_only": True}, + ) + properties.failed_payments = AAZListType( + serialized_name="failedPayments", + flags={"read_only": True}, + ) + properties.free_azure_credit_applied = AAZObjectType( + serialized_name="freeAzureCreditApplied", + ) + properties.invoice_date = AAZStrType( + serialized_name="invoiceDate", + flags={"read_only": True}, + ) + properties.invoice_period_end_date = AAZStrType( + serialized_name="invoicePeriodEndDate", + flags={"read_only": True}, + ) + properties.invoice_period_start_date = AAZStrType( + serialized_name="invoicePeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_type = AAZStrType( + serialized_name="invoiceType", + flags={"read_only": True}, + ) + properties.is_monthly_invoice = AAZBoolType( + serialized_name="isMonthlyInvoice", + flags={"read_only": True}, + ) + properties.payments = AAZListType( + flags={"read_only": True}, + ) + properties.purchase_order_number = AAZStrType( + serialized_name="purchaseOrderNumber", + flags={"read_only": True}, + ) + properties.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + _GetByBillingAccountHelper._build_schema_rebill_details_read(properties.rebill_details) + properties.refund_details = AAZObjectType( + serialized_name="refundDetails", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.tax_amount = AAZObjectType( + serialized_name="taxAmount", + ) + properties.total_amount = AAZObjectType( + serialized_name="totalAmount", + ) + + amount_due = cls._schema_on_200.properties.amount_due + amount_due.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_due.value = AAZFloatType( + flags={"read_only": True}, + ) + + azure_prepayment_applied = cls._schema_on_200.properties.azure_prepayment_applied + azure_prepayment_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_prepayment_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + billed_amount = cls._schema_on_200.properties.billed_amount + billed_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + billed_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + credit_amount = cls._schema_on_200.properties.credit_amount + credit_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + credit_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + documents = cls._schema_on_200.properties.documents + documents.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.documents.Element + _element.document_numbers = AAZListType( + serialized_name="documentNumbers", + flags={"read_only": True}, + ) + _element.external_url = AAZStrType( + serialized_name="externalUrl", + flags={"read_only": True}, + ) + _element.kind = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source = AAZStrType( + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + document_numbers = cls._schema_on_200.properties.documents.Element.document_numbers + document_numbers.Element = AAZStrType() + + failed_payments = cls._schema_on_200.properties.failed_payments + failed_payments.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.failed_payments.Element + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.failed_payment_reason = AAZStrType( + serialized_name="failedPaymentReason", + flags={"read_only": True}, + ) + + free_azure_credit_applied = cls._schema_on_200.properties.free_azure_credit_applied + free_azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + free_azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments = cls._schema_on_200.properties.payments + payments.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.payments.Element + _element.amount = AAZObjectType() + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.payment_method_family = AAZStrType( + serialized_name="paymentMethodFamily", + flags={"read_only": True}, + ) + _element.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + _element.payment_type = AAZStrType( + serialized_name="paymentType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.properties.payments.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_details = cls._schema_on_200.properties.refund_details + refund_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_details.approved_on = AAZStrType( + serialized_name="approvedOn", + flags={"read_only": True}, + ) + refund_details.completed_on = AAZStrType( + serialized_name="completedOn", + flags={"read_only": True}, + ) + refund_details.rebill_invoice_id = AAZStrType( + serialized_name="rebillInvoiceId", + flags={"read_only": True}, + ) + refund_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + flags={"read_only": True}, + ) + refund_details.refund_reason = AAZStrType( + serialized_name="refundReason", + flags={"read_only": True}, + ) + refund_details.refund_status = AAZStrType( + serialized_name="refundStatus", + flags={"read_only": True}, + ) + refund_details.requested_on = AAZStrType( + serialized_name="requestedOn", + flags={"read_only": True}, + ) + refund_details.transaction_count = AAZIntType( + serialized_name="transactionCount", + flags={"read_only": True}, + ) + + amount_refunded = cls._schema_on_200.properties.refund_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.properties.refund_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax_amount = cls._schema_on_200.properties.tax_amount + tax_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + tax_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_amount = cls._schema_on_200.properties.total_amount + total_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + total_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + _schema_rebill_details_read = None + + @classmethod + def _build_schema_rebill_details_read(cls, _schema): + if cls._schema_rebill_details_read is not None: + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + return + + cls._schema_rebill_details_read = _schema_rebill_details_read = AAZObjectType( + flags={"read_only": True} + ) + + rebill_details_read = _schema_rebill_details_read + rebill_details_read.credit_note_document_id = AAZStrType( + serialized_name="creditNoteDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.invoice_document_id = AAZStrType( + serialized_name="invoiceDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + cls._build_schema_rebill_details_read(rebill_details_read.rebill_details) + + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_get_by_billing_subscription.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_get_by_billing_subscription.py new file mode 100644 index 00000000000..a87ee2d0a94 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_get_by_billing_subscription.py @@ -0,0 +1,532 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice get-by-billing-subscription", +) +class GetByBillingSubscription(AAZCommand): + """Get an invoice by subscription ID and invoice ID. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: InvoicesGetByBillingSubscription + az billing invoice get-by-billing-subscription --invoice-name E123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/default/billingsubscriptions/{}/invoices/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoicesGetByBillingSubscription(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoicesGetByBillingSubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.amount_due = AAZObjectType( + serialized_name="amountDue", + ) + properties.azure_prepayment_applied = AAZObjectType( + serialized_name="azurePrepaymentApplied", + ) + properties.billed_amount = AAZObjectType( + serialized_name="billedAmount", + ) + properties.billed_document_id = AAZStrType( + serialized_name="billedDocumentId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.credit_amount = AAZObjectType( + serialized_name="creditAmount", + ) + properties.credit_for_document_id = AAZStrType( + serialized_name="creditForDocumentId", + flags={"read_only": True}, + ) + properties.document_type = AAZStrType( + serialized_name="documentType", + flags={"read_only": True}, + ) + properties.documents = AAZListType( + flags={"read_only": True}, + ) + properties.due_date = AAZStrType( + serialized_name="dueDate", + flags={"read_only": True}, + ) + properties.failed_payments = AAZListType( + serialized_name="failedPayments", + flags={"read_only": True}, + ) + properties.free_azure_credit_applied = AAZObjectType( + serialized_name="freeAzureCreditApplied", + ) + properties.invoice_date = AAZStrType( + serialized_name="invoiceDate", + flags={"read_only": True}, + ) + properties.invoice_period_end_date = AAZStrType( + serialized_name="invoicePeriodEndDate", + flags={"read_only": True}, + ) + properties.invoice_period_start_date = AAZStrType( + serialized_name="invoicePeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_type = AAZStrType( + serialized_name="invoiceType", + flags={"read_only": True}, + ) + properties.is_monthly_invoice = AAZBoolType( + serialized_name="isMonthlyInvoice", + flags={"read_only": True}, + ) + properties.payments = AAZListType( + flags={"read_only": True}, + ) + properties.purchase_order_number = AAZStrType( + serialized_name="purchaseOrderNumber", + flags={"read_only": True}, + ) + properties.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + _GetByBillingSubscriptionHelper._build_schema_rebill_details_read(properties.rebill_details) + properties.refund_details = AAZObjectType( + serialized_name="refundDetails", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.tax_amount = AAZObjectType( + serialized_name="taxAmount", + ) + properties.total_amount = AAZObjectType( + serialized_name="totalAmount", + ) + + amount_due = cls._schema_on_200.properties.amount_due + amount_due.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_due.value = AAZFloatType( + flags={"read_only": True}, + ) + + azure_prepayment_applied = cls._schema_on_200.properties.azure_prepayment_applied + azure_prepayment_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_prepayment_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + billed_amount = cls._schema_on_200.properties.billed_amount + billed_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + billed_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + credit_amount = cls._schema_on_200.properties.credit_amount + credit_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + credit_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + documents = cls._schema_on_200.properties.documents + documents.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.documents.Element + _element.document_numbers = AAZListType( + serialized_name="documentNumbers", + flags={"read_only": True}, + ) + _element.external_url = AAZStrType( + serialized_name="externalUrl", + flags={"read_only": True}, + ) + _element.kind = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source = AAZStrType( + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + document_numbers = cls._schema_on_200.properties.documents.Element.document_numbers + document_numbers.Element = AAZStrType() + + failed_payments = cls._schema_on_200.properties.failed_payments + failed_payments.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.failed_payments.Element + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.failed_payment_reason = AAZStrType( + serialized_name="failedPaymentReason", + flags={"read_only": True}, + ) + + free_azure_credit_applied = cls._schema_on_200.properties.free_azure_credit_applied + free_azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + free_azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments = cls._schema_on_200.properties.payments + payments.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.payments.Element + _element.amount = AAZObjectType() + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.payment_method_family = AAZStrType( + serialized_name="paymentMethodFamily", + flags={"read_only": True}, + ) + _element.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + _element.payment_type = AAZStrType( + serialized_name="paymentType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.properties.payments.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_details = cls._schema_on_200.properties.refund_details + refund_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_details.approved_on = AAZStrType( + serialized_name="approvedOn", + flags={"read_only": True}, + ) + refund_details.completed_on = AAZStrType( + serialized_name="completedOn", + flags={"read_only": True}, + ) + refund_details.rebill_invoice_id = AAZStrType( + serialized_name="rebillInvoiceId", + flags={"read_only": True}, + ) + refund_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + flags={"read_only": True}, + ) + refund_details.refund_reason = AAZStrType( + serialized_name="refundReason", + flags={"read_only": True}, + ) + refund_details.refund_status = AAZStrType( + serialized_name="refundStatus", + flags={"read_only": True}, + ) + refund_details.requested_on = AAZStrType( + serialized_name="requestedOn", + flags={"read_only": True}, + ) + refund_details.transaction_count = AAZIntType( + serialized_name="transactionCount", + flags={"read_only": True}, + ) + + amount_refunded = cls._schema_on_200.properties.refund_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.properties.refund_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax_amount = cls._schema_on_200.properties.tax_amount + tax_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + tax_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_amount = cls._schema_on_200.properties.total_amount + total_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + total_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingSubscriptionHelper: + """Helper class for GetByBillingSubscription""" + + _schema_rebill_details_read = None + + @classmethod + def _build_schema_rebill_details_read(cls, _schema): + if cls._schema_rebill_details_read is not None: + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + return + + cls._schema_rebill_details_read = _schema_rebill_details_read = AAZObjectType( + flags={"read_only": True} + ) + + rebill_details_read = _schema_rebill_details_read + rebill_details_read.credit_note_document_id = AAZStrType( + serialized_name="creditNoteDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.invoice_document_id = AAZStrType( + serialized_name="invoiceDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + cls._build_schema_rebill_details_read(rebill_details_read.rebill_details) + + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + + +__all__ = ["GetByBillingSubscription"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_account.py new file mode 100644 index 00000000000..fc0005d47eb --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_account.py @@ -0,0 +1,598 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the invoices for a billing account for a given start date and end date. The operation is supported for all billing account types. + + :example: InvoicesListByBillingAccount + az billing invoice list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --period-start-date 2023-01-01 --period-end-date 2023-06-30 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.period_end_date = AAZDateArg( + options=["--period-end-date"], + help="The end date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format.", + ) + _args_schema.period_start_date = AAZDateArg( + options=["--period-start-date"], + help="The start date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoicesListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class InvoicesListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "periodEndDate", self.ctx.args.period_end_date, + ), + **self.serialize_query_param( + "periodStartDate", self.ctx.args.period_start_date, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.amount_due = AAZObjectType( + serialized_name="amountDue", + ) + properties.azure_prepayment_applied = AAZObjectType( + serialized_name="azurePrepaymentApplied", + ) + properties.billed_amount = AAZObjectType( + serialized_name="billedAmount", + ) + properties.billed_document_id = AAZStrType( + serialized_name="billedDocumentId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.credit_amount = AAZObjectType( + serialized_name="creditAmount", + ) + properties.credit_for_document_id = AAZStrType( + serialized_name="creditForDocumentId", + flags={"read_only": True}, + ) + properties.document_type = AAZStrType( + serialized_name="documentType", + flags={"read_only": True}, + ) + properties.documents = AAZListType( + flags={"read_only": True}, + ) + properties.due_date = AAZStrType( + serialized_name="dueDate", + flags={"read_only": True}, + ) + properties.failed_payments = AAZListType( + serialized_name="failedPayments", + flags={"read_only": True}, + ) + properties.free_azure_credit_applied = AAZObjectType( + serialized_name="freeAzureCreditApplied", + ) + properties.invoice_date = AAZStrType( + serialized_name="invoiceDate", + flags={"read_only": True}, + ) + properties.invoice_period_end_date = AAZStrType( + serialized_name="invoicePeriodEndDate", + flags={"read_only": True}, + ) + properties.invoice_period_start_date = AAZStrType( + serialized_name="invoicePeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_type = AAZStrType( + serialized_name="invoiceType", + flags={"read_only": True}, + ) + properties.is_monthly_invoice = AAZBoolType( + serialized_name="isMonthlyInvoice", + flags={"read_only": True}, + ) + properties.payments = AAZListType( + flags={"read_only": True}, + ) + properties.purchase_order_number = AAZStrType( + serialized_name="purchaseOrderNumber", + flags={"read_only": True}, + ) + properties.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_rebill_details_read(properties.rebill_details) + properties.refund_details = AAZObjectType( + serialized_name="refundDetails", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.tax_amount = AAZObjectType( + serialized_name="taxAmount", + ) + properties.total_amount = AAZObjectType( + serialized_name="totalAmount", + ) + + amount_due = cls._schema_on_200.value.Element.properties.amount_due + amount_due.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_due.value = AAZFloatType( + flags={"read_only": True}, + ) + + azure_prepayment_applied = cls._schema_on_200.value.Element.properties.azure_prepayment_applied + azure_prepayment_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_prepayment_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + billed_amount = cls._schema_on_200.value.Element.properties.billed_amount + billed_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + billed_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + credit_amount = cls._schema_on_200.value.Element.properties.credit_amount + credit_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + credit_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + documents = cls._schema_on_200.value.Element.properties.documents + documents.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.documents.Element + _element.document_numbers = AAZListType( + serialized_name="documentNumbers", + flags={"read_only": True}, + ) + _element.external_url = AAZStrType( + serialized_name="externalUrl", + flags={"read_only": True}, + ) + _element.kind = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source = AAZStrType( + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + document_numbers = cls._schema_on_200.value.Element.properties.documents.Element.document_numbers + document_numbers.Element = AAZStrType() + + failed_payments = cls._schema_on_200.value.Element.properties.failed_payments + failed_payments.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.failed_payments.Element + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.failed_payment_reason = AAZStrType( + serialized_name="failedPaymentReason", + flags={"read_only": True}, + ) + + free_azure_credit_applied = cls._schema_on_200.value.Element.properties.free_azure_credit_applied + free_azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + free_azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments = cls._schema_on_200.value.Element.properties.payments + payments.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.payments.Element + _element.amount = AAZObjectType() + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.payment_method_family = AAZStrType( + serialized_name="paymentMethodFamily", + flags={"read_only": True}, + ) + _element.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + _element.payment_type = AAZStrType( + serialized_name="paymentType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.value.Element.properties.payments.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_details = cls._schema_on_200.value.Element.properties.refund_details + refund_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_details.approved_on = AAZStrType( + serialized_name="approvedOn", + flags={"read_only": True}, + ) + refund_details.completed_on = AAZStrType( + serialized_name="completedOn", + flags={"read_only": True}, + ) + refund_details.rebill_invoice_id = AAZStrType( + serialized_name="rebillInvoiceId", + flags={"read_only": True}, + ) + refund_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + flags={"read_only": True}, + ) + refund_details.refund_reason = AAZStrType( + serialized_name="refundReason", + flags={"read_only": True}, + ) + refund_details.refund_status = AAZStrType( + serialized_name="refundStatus", + flags={"read_only": True}, + ) + refund_details.requested_on = AAZStrType( + serialized_name="requestedOn", + flags={"read_only": True}, + ) + refund_details.transaction_count = AAZIntType( + serialized_name="transactionCount", + flags={"read_only": True}, + ) + + amount_refunded = cls._schema_on_200.value.Element.properties.refund_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.value.Element.properties.refund_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.value.Element.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax_amount = cls._schema_on_200.value.Element.properties.tax_amount + tax_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + tax_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_amount = cls._schema_on_200.value.Element.properties.total_amount + total_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + total_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + _schema_rebill_details_read = None + + @classmethod + def _build_schema_rebill_details_read(cls, _schema): + if cls._schema_rebill_details_read is not None: + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + return + + cls._schema_rebill_details_read = _schema_rebill_details_read = AAZObjectType( + flags={"read_only": True} + ) + + rebill_details_read = _schema_rebill_details_read + rebill_details_read.credit_note_document_id = AAZStrType( + serialized_name="creditNoteDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.invoice_document_id = AAZStrType( + serialized_name="invoiceDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + cls._build_schema_rebill_details_read(rebill_details_read.rebill_details) + + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_profile.py new file mode 100644 index 00000000000..d3663c2886b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_profile.py @@ -0,0 +1,610 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List 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. + + :example: InvoicesListByBillingProfile + az billing invoice list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --period-start-date 2023-01-01 --period-end-date 2023-06-30 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoices", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.period_end_date = AAZDateArg( + options=["--period-end-date"], + help="The end date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format.", + ) + _args_schema.period_start_date = AAZDateArg( + options=["--period-start-date"], + help="The start date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoicesListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class InvoicesListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "periodEndDate", self.ctx.args.period_end_date, + ), + **self.serialize_query_param( + "periodStartDate", self.ctx.args.period_start_date, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.amount_due = AAZObjectType( + serialized_name="amountDue", + ) + properties.azure_prepayment_applied = AAZObjectType( + serialized_name="azurePrepaymentApplied", + ) + properties.billed_amount = AAZObjectType( + serialized_name="billedAmount", + ) + properties.billed_document_id = AAZStrType( + serialized_name="billedDocumentId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.credit_amount = AAZObjectType( + serialized_name="creditAmount", + ) + properties.credit_for_document_id = AAZStrType( + serialized_name="creditForDocumentId", + flags={"read_only": True}, + ) + properties.document_type = AAZStrType( + serialized_name="documentType", + flags={"read_only": True}, + ) + properties.documents = AAZListType( + flags={"read_only": True}, + ) + properties.due_date = AAZStrType( + serialized_name="dueDate", + flags={"read_only": True}, + ) + properties.failed_payments = AAZListType( + serialized_name="failedPayments", + flags={"read_only": True}, + ) + properties.free_azure_credit_applied = AAZObjectType( + serialized_name="freeAzureCreditApplied", + ) + properties.invoice_date = AAZStrType( + serialized_name="invoiceDate", + flags={"read_only": True}, + ) + properties.invoice_period_end_date = AAZStrType( + serialized_name="invoicePeriodEndDate", + flags={"read_only": True}, + ) + properties.invoice_period_start_date = AAZStrType( + serialized_name="invoicePeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_type = AAZStrType( + serialized_name="invoiceType", + flags={"read_only": True}, + ) + properties.is_monthly_invoice = AAZBoolType( + serialized_name="isMonthlyInvoice", + flags={"read_only": True}, + ) + properties.payments = AAZListType( + flags={"read_only": True}, + ) + properties.purchase_order_number = AAZStrType( + serialized_name="purchaseOrderNumber", + flags={"read_only": True}, + ) + properties.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + _ListByBillingProfileHelper._build_schema_rebill_details_read(properties.rebill_details) + properties.refund_details = AAZObjectType( + serialized_name="refundDetails", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.tax_amount = AAZObjectType( + serialized_name="taxAmount", + ) + properties.total_amount = AAZObjectType( + serialized_name="totalAmount", + ) + + amount_due = cls._schema_on_200.value.Element.properties.amount_due + amount_due.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_due.value = AAZFloatType( + flags={"read_only": True}, + ) + + azure_prepayment_applied = cls._schema_on_200.value.Element.properties.azure_prepayment_applied + azure_prepayment_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_prepayment_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + billed_amount = cls._schema_on_200.value.Element.properties.billed_amount + billed_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + billed_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + credit_amount = cls._schema_on_200.value.Element.properties.credit_amount + credit_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + credit_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + documents = cls._schema_on_200.value.Element.properties.documents + documents.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.documents.Element + _element.document_numbers = AAZListType( + serialized_name="documentNumbers", + flags={"read_only": True}, + ) + _element.external_url = AAZStrType( + serialized_name="externalUrl", + flags={"read_only": True}, + ) + _element.kind = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source = AAZStrType( + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + document_numbers = cls._schema_on_200.value.Element.properties.documents.Element.document_numbers + document_numbers.Element = AAZStrType() + + failed_payments = cls._schema_on_200.value.Element.properties.failed_payments + failed_payments.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.failed_payments.Element + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.failed_payment_reason = AAZStrType( + serialized_name="failedPaymentReason", + flags={"read_only": True}, + ) + + free_azure_credit_applied = cls._schema_on_200.value.Element.properties.free_azure_credit_applied + free_azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + free_azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments = cls._schema_on_200.value.Element.properties.payments + payments.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.payments.Element + _element.amount = AAZObjectType() + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.payment_method_family = AAZStrType( + serialized_name="paymentMethodFamily", + flags={"read_only": True}, + ) + _element.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + _element.payment_type = AAZStrType( + serialized_name="paymentType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.value.Element.properties.payments.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_details = cls._schema_on_200.value.Element.properties.refund_details + refund_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_details.approved_on = AAZStrType( + serialized_name="approvedOn", + flags={"read_only": True}, + ) + refund_details.completed_on = AAZStrType( + serialized_name="completedOn", + flags={"read_only": True}, + ) + refund_details.rebill_invoice_id = AAZStrType( + serialized_name="rebillInvoiceId", + flags={"read_only": True}, + ) + refund_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + flags={"read_only": True}, + ) + refund_details.refund_reason = AAZStrType( + serialized_name="refundReason", + flags={"read_only": True}, + ) + refund_details.refund_status = AAZStrType( + serialized_name="refundStatus", + flags={"read_only": True}, + ) + refund_details.requested_on = AAZStrType( + serialized_name="requestedOn", + flags={"read_only": True}, + ) + refund_details.transaction_count = AAZIntType( + serialized_name="transactionCount", + flags={"read_only": True}, + ) + + amount_refunded = cls._schema_on_200.value.Element.properties.refund_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.value.Element.properties.refund_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.value.Element.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax_amount = cls._schema_on_200.value.Element.properties.tax_amount + tax_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + tax_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_amount = cls._schema_on_200.value.Element.properties.total_amount + total_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + total_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + _schema_rebill_details_read = None + + @classmethod + def _build_schema_rebill_details_read(cls, _schema): + if cls._schema_rebill_details_read is not None: + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + return + + cls._schema_rebill_details_read = _schema_rebill_details_read = AAZObjectType( + flags={"read_only": True} + ) + + rebill_details_read = _schema_rebill_details_read + rebill_details_read.credit_note_document_id = AAZStrType( + serialized_name="creditNoteDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.invoice_document_id = AAZStrType( + serialized_name="invoiceDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + cls._build_schema_rebill_details_read(rebill_details_read.rebill_details) + + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_subscription.py b/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_subscription.py new file mode 100644 index 00000000000..e1d204c8a40 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/_list_by_billing_subscription.py @@ -0,0 +1,590 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice list-by-billing-subscription", +) +class ListByBillingSubscription(AAZCommand): + """List the invoices for a subscription. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: InvoicesListByBillingSubscription + az billing invoice list-by-billing-subscription --period-start-date 2023-01-01 --period-end-date 2023-06-30 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/default/billingsubscriptions/{}/invoices", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.period_end_date = AAZDateArg( + options=["--period-end-date"], + help="The end date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format.", + ) + _args_schema.period_start_date = AAZDateArg( + options=["--period-start-date"], + help="The start date of the billing period for which the invoice is generated. The date is in MM-DD-YYYY format.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoicesListByBillingSubscription(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class InvoicesListByBillingSubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "periodEndDate", self.ctx.args.period_end_date, + ), + **self.serialize_query_param( + "periodStartDate", self.ctx.args.period_start_date, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.amount_due = AAZObjectType( + serialized_name="amountDue", + ) + properties.azure_prepayment_applied = AAZObjectType( + serialized_name="azurePrepaymentApplied", + ) + properties.billed_amount = AAZObjectType( + serialized_name="billedAmount", + ) + properties.billed_document_id = AAZStrType( + serialized_name="billedDocumentId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.credit_amount = AAZObjectType( + serialized_name="creditAmount", + ) + properties.credit_for_document_id = AAZStrType( + serialized_name="creditForDocumentId", + flags={"read_only": True}, + ) + properties.document_type = AAZStrType( + serialized_name="documentType", + flags={"read_only": True}, + ) + properties.documents = AAZListType( + flags={"read_only": True}, + ) + properties.due_date = AAZStrType( + serialized_name="dueDate", + flags={"read_only": True}, + ) + properties.failed_payments = AAZListType( + serialized_name="failedPayments", + flags={"read_only": True}, + ) + properties.free_azure_credit_applied = AAZObjectType( + serialized_name="freeAzureCreditApplied", + ) + properties.invoice_date = AAZStrType( + serialized_name="invoiceDate", + flags={"read_only": True}, + ) + properties.invoice_period_end_date = AAZStrType( + serialized_name="invoicePeriodEndDate", + flags={"read_only": True}, + ) + properties.invoice_period_start_date = AAZStrType( + serialized_name="invoicePeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_type = AAZStrType( + serialized_name="invoiceType", + flags={"read_only": True}, + ) + properties.is_monthly_invoice = AAZBoolType( + serialized_name="isMonthlyInvoice", + flags={"read_only": True}, + ) + properties.payments = AAZListType( + flags={"read_only": True}, + ) + properties.purchase_order_number = AAZStrType( + serialized_name="purchaseOrderNumber", + flags={"read_only": True}, + ) + properties.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + _ListByBillingSubscriptionHelper._build_schema_rebill_details_read(properties.rebill_details) + properties.refund_details = AAZObjectType( + serialized_name="refundDetails", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.tax_amount = AAZObjectType( + serialized_name="taxAmount", + ) + properties.total_amount = AAZObjectType( + serialized_name="totalAmount", + ) + + amount_due = cls._schema_on_200.value.Element.properties.amount_due + amount_due.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_due.value = AAZFloatType( + flags={"read_only": True}, + ) + + azure_prepayment_applied = cls._schema_on_200.value.Element.properties.azure_prepayment_applied + azure_prepayment_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_prepayment_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + billed_amount = cls._schema_on_200.value.Element.properties.billed_amount + billed_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + billed_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + credit_amount = cls._schema_on_200.value.Element.properties.credit_amount + credit_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + credit_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + documents = cls._schema_on_200.value.Element.properties.documents + documents.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.documents.Element + _element.document_numbers = AAZListType( + serialized_name="documentNumbers", + flags={"read_only": True}, + ) + _element.external_url = AAZStrType( + serialized_name="externalUrl", + flags={"read_only": True}, + ) + _element.kind = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source = AAZStrType( + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + document_numbers = cls._schema_on_200.value.Element.properties.documents.Element.document_numbers + document_numbers.Element = AAZStrType() + + failed_payments = cls._schema_on_200.value.Element.properties.failed_payments + failed_payments.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.failed_payments.Element + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.failed_payment_reason = AAZStrType( + serialized_name="failedPaymentReason", + flags={"read_only": True}, + ) + + free_azure_credit_applied = cls._schema_on_200.value.Element.properties.free_azure_credit_applied + free_azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + free_azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + payments = cls._schema_on_200.value.Element.properties.payments + payments.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.payments.Element + _element.amount = AAZObjectType() + _element.date = AAZStrType( + flags={"read_only": True}, + ) + _element.payment_method_family = AAZStrType( + serialized_name="paymentMethodFamily", + flags={"read_only": True}, + ) + _element.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + flags={"read_only": True}, + ) + _element.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + _element.payment_type = AAZStrType( + serialized_name="paymentType", + flags={"read_only": True}, + ) + + amount = cls._schema_on_200.value.Element.properties.payments.Element.amount + amount.currency = AAZStrType( + flags={"read_only": True}, + ) + amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_details = cls._schema_on_200.value.Element.properties.refund_details + refund_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_details.approved_on = AAZStrType( + serialized_name="approvedOn", + flags={"read_only": True}, + ) + refund_details.completed_on = AAZStrType( + serialized_name="completedOn", + flags={"read_only": True}, + ) + refund_details.rebill_invoice_id = AAZStrType( + serialized_name="rebillInvoiceId", + flags={"read_only": True}, + ) + refund_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + flags={"read_only": True}, + ) + refund_details.refund_reason = AAZStrType( + serialized_name="refundReason", + flags={"read_only": True}, + ) + refund_details.refund_status = AAZStrType( + serialized_name="refundStatus", + flags={"read_only": True}, + ) + refund_details.requested_on = AAZStrType( + serialized_name="requestedOn", + flags={"read_only": True}, + ) + refund_details.transaction_count = AAZIntType( + serialized_name="transactionCount", + flags={"read_only": True}, + ) + + amount_refunded = cls._schema_on_200.value.Element.properties.refund_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.value.Element.properties.refund_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.value.Element.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax_amount = cls._schema_on_200.value.Element.properties.tax_amount + tax_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + tax_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + total_amount = cls._schema_on_200.value.Element.properties.total_amount + total_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + total_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingSubscriptionHelper: + """Helper class for ListByBillingSubscription""" + + _schema_rebill_details_read = None + + @classmethod + def _build_schema_rebill_details_read(cls, _schema): + if cls._schema_rebill_details_read is not None: + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + return + + cls._schema_rebill_details_read = _schema_rebill_details_read = AAZObjectType( + flags={"read_only": True} + ) + + rebill_details_read = _schema_rebill_details_read + rebill_details_read.credit_note_document_id = AAZStrType( + serialized_name="creditNoteDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.invoice_document_id = AAZStrType( + serialized_name="invoiceDocumentId", + flags={"read_only": True}, + ) + rebill_details_read.rebill_details = AAZObjectType( + serialized_name="rebillDetails", + flags={"read_only": True}, + ) + cls._build_schema_rebill_details_read(rebill_details_read.rebill_details) + + _schema.credit_note_document_id = cls._schema_rebill_details_read.credit_note_document_id + _schema.invoice_document_id = cls._schema_rebill_details_read.invoice_document_id + _schema.rebill_details = cls._schema_rebill_details_read.rebill_details + + +__all__ = ["ListByBillingSubscription"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/section/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/invoice/section/__cmd_group.py new file mode 100644 index 00000000000..d6303cf1db2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/section/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing invoice section", +) +class __CMDGroup(AAZCommandGroup): + """Manage invoice section + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/section/__init__.py b/src/billing/azext_billing/aaz/latest/billing/invoice/section/__init__.py new file mode 100644 index 00000000000..044abaa2849 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/section/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._initiate_transfer import * diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice/section/_initiate_transfer.py b/src/billing/azext_billing/aaz/latest/billing/invoice/section/_initiate_transfer.py new file mode 100644 index 00000000000..838b150d3aa --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice/section/_initiate_transfer.py @@ -0,0 +1,288 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice section initiate-transfer", +) +class InitiateTransfer(AAZCommand): + """Sends a request to a user in another billing account to transfer billing ownership of their subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + """ + + _aaz_info = { + "version": "2019-10-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/initiatetransfer", "2019-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.recipient_email_id = AAZStrArg( + options=["--recipient-email-id"], + arg_group="Properties", + help="The email ID of the recipient to whom the transfer request is sent.", + ) + _args_schema.reseller_id = AAZStrArg( + options=["--reseller-id"], + arg_group="Properties", + help="Optional MPN ID of the reseller for transfer requests that are sent from a Microsoft Partner Agreement billing account.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransfersInitiate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TransfersInitiate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/initiateTransfer", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("recipientEmailId", AAZStrType, ".recipient_email_id") + properties.set_prop("resellerId", AAZStrType, ".reseller_id") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.creation_time = AAZStrType( + serialized_name="creationTime", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_modified_time = AAZStrType( + serialized_name="lastModifiedTime", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.error_code = AAZStrType( + serialized_name="errorCode", + flags={"read_only": True}, + ) + error_details.error_message = AAZStrType( + serialized_name="errorMessage", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _InitiateTransferHelper: + """Helper class for InitiateTransfer""" + + +__all__ = ["InitiateTransfer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/__cmd_group.py new file mode 100644 index 00000000000..52755cca292 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing invoice-section", +) +class __CMDGroup(AAZCommandGroup): + """Create, Update, Get, Validate Delete eligibility and List operations on invoice section scope and billing profile scope + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/__init__.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/__init__.py new file mode 100644 index 00000000000..a71b5437bf2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/__init__.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._get import * +from ._list_by_billing_profile import * +from ._update import * +from ._validate_delete_eligibility import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/_create.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_create.py new file mode 100644 index 00000000000..0f7c09840e2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_create.py @@ -0,0 +1,323 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice-section create", +) +class Create(AAZCommand): + """Create an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: InvoiceSectionsCreateOrUpdate + az billing invoice-section create --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name invoice-section-1 --display-name Invoice Section 1 --tags "{pcCode:A123456,costCategory:Support}" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the invoice section.", + ) + _args_schema.reason_code = AAZStrArg( + options=["--reason-code"], + arg_group="Properties", + help="Reason for the specified invoice section status.", + enum={"Other": "Other", "PastDue": "PastDue", "SpendingLimitExpired": "SpendingLimitExpired", "SpendingLimitReached": "SpendingLimitReached", "UnusualActivity": "UnusualActivity"}, + ) + _args_schema.state = AAZStrArg( + options=["--state"], + arg_group="Properties", + help="Identifies the status of an invoice section.", + enum={"Active": "Active", "Deleted": "Deleted", "Disabled": "Disabled", "Other": "Other", "Restricted": "Restricted", "UnderReview": "UnderReview", "Warned": "Warned"}, + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Properties", + help="Dictionary of metadata associated with the resource. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + _args_schema.target_cloud = AAZStrArg( + options=["--target-cloud"], + arg_group="Properties", + help="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.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoiceSectionsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("reasonCode", AAZStrType, ".reason_code") + properties.set_prop("state", AAZStrType, ".state") + properties.set_prop("tags", AAZDictType, ".tags") + properties.set_prop("targetCloud", AAZStrType, ".target_cloud") + + tags = _builder.get(".properties.tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.state = AAZStrType() + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_cloud = AAZStrType( + serialized_name="targetCloud", + ) + + tags = cls._schema_on_200_201.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/_delete.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_delete.py new file mode 100644 index 00000000000..d312867f77b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_delete.py @@ -0,0 +1,178 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice-section delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: InvoiceSectionsDelete + az billing invoice-section delete --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InvoiceSectionsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class InvoiceSectionsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/_get.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_get.py new file mode 100644 index 00000000000..2cce0f51c6e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_get.py @@ -0,0 +1,241 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice-section get", +) +class Get(AAZCommand): + """Get an invoice section by its ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: InvoiceSectionsGet + az billing invoice-section get --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.state = AAZStrType() + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_cloud = AAZStrType( + serialized_name="targetCloud", + ) + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_list_by_billing_profile.py new file mode 100644 index 00000000000..967240bd45c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_list_by_billing_profile.py @@ -0,0 +1,293 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice-section list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List the invoice sections that a user has access to. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: InvoiceSectionsListByBillingProfile + az billing invoice-section list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --include-deleted True + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted invoice sections.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class InvoiceSectionsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.state = AAZStrType() + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_cloud = AAZStrType( + serialized_name="targetCloud", + ) + + tags = cls._schema_on_200.value.Element.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/_update.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_update.py new file mode 100644 index 00000000000..026bbc7d5f2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_update.py @@ -0,0 +1,469 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice-section update", +) +class Update(AAZCommand): + """Update an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the invoice section.", + nullable=True, + ) + _args_schema.reason_code = AAZStrArg( + options=["--reason-code"], + arg_group="Properties", + help="Reason for the specified invoice section status.", + nullable=True, + enum={"Other": "Other", "PastDue": "PastDue", "SpendingLimitExpired": "SpendingLimitExpired", "SpendingLimitReached": "SpendingLimitReached", "UnusualActivity": "UnusualActivity"}, + ) + _args_schema.state = AAZStrArg( + options=["--state"], + arg_group="Properties", + help="Identifies the status of an invoice section.", + nullable=True, + enum={"Active": "Active", "Deleted": "Deleted", "Disabled": "Disabled", "Other": "Other", "Restricted": "Restricted", "UnderReview": "UnderReview", "Warned": "Warned"}, + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Properties", + help="Dictionary of metadata associated with the resource. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + _args_schema.target_cloud = AAZStrArg( + options=["--target-cloud"], + arg_group="Properties", + help="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.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.InvoiceSectionsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_invoice_section_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InvoiceSectionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_invoice_section_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("reasonCode", AAZStrType, ".reason_code") + properties.set_prop("state", AAZStrType, ".state") + properties.set_prop("tags", AAZDictType, ".tags") + properties.set_prop("targetCloud", AAZStrType, ".target_cloud") + + tags = _builder.get(".properties.tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_invoice_section_read = None + + @classmethod + def _build_schema_invoice_section_read(cls, _schema): + if cls._schema_invoice_section_read is not None: + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.system_data = cls._schema_invoice_section_read.system_data + _schema.tags = cls._schema_invoice_section_read.tags + _schema.type = cls._schema_invoice_section_read.type + return + + cls._schema_invoice_section_read = _schema_invoice_section_read = AAZObjectType() + + invoice_section_read = _schema_invoice_section_read + invoice_section_read.id = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.name = AAZStrType( + flags={"read_only": True}, + ) + invoice_section_read.properties = AAZObjectType() + invoice_section_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + invoice_section_read.tags = AAZDictType() + invoice_section_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_invoice_section_read.properties + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.state = AAZStrType() + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_cloud = AAZStrType( + serialized_name="targetCloud", + ) + + tags = _schema_invoice_section_read.properties.tags + tags.Element = AAZStrType() + + system_data = _schema_invoice_section_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_invoice_section_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_invoice_section_read.id + _schema.name = cls._schema_invoice_section_read.name + _schema.properties = cls._schema_invoice_section_read.properties + _schema.system_data = cls._schema_invoice_section_read.system_data + _schema.tags = cls._schema_invoice_section_read.tags + _schema.type = cls._schema_invoice_section_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/_validate_delete_eligibility.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_validate_delete_eligibility.py new file mode 100644 index 00000000000..5e7c47353c9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_validate_delete_eligibility.py @@ -0,0 +1,192 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice-section validate-delete-eligibility", +) +class ValidateDeleteEligibility(AAZCommand): + """Validates if the invoice section can be deleted. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: InvoiceSectionsValidateDeleteEligibilitySuccess + az billing invoice-section validate-delete-eligibility --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/validatedeleteeligibility", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsValidateDeleteEligibility(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InvoiceSectionsValidateDeleteEligibility(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/validateDeleteEligibility", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.eligibility_details = AAZListType( + serialized_name="eligibilityDetails", + ) + _schema_on_200.eligibility_status = AAZStrType( + serialized_name="eligibilityStatus", + ) + + eligibility_details = cls._schema_on_200.eligibility_details + eligibility_details.Element = AAZObjectType() + + _element = cls._schema_on_200.eligibility_details.Element + _element.code = AAZStrType() + _element.message = AAZStrType() + + return cls._schema_on_200 + + +class _ValidateDeleteEligibilityHelper: + """Helper class for ValidateDeleteEligibility""" + + +__all__ = ["ValidateDeleteEligibility"] diff --git a/src/billing/azext_billing/aaz/latest/billing/invoice_section/_wait.py b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_wait.py new file mode 100644 index 00000000000..bbd1cf339b8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/invoice_section/_wait.py @@ -0,0 +1,237 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing invoice-section wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InvoiceSectionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class InvoiceSectionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.state = AAZStrType() + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_cloud = AAZStrType( + serialized_name="targetCloud", + ) + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/partner_transfer/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/__cmd_group.py new file mode 100644 index 00000000000..357325fbfbf --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing partner-transfer", +) +class __CMDGroup(AAZCommandGroup): + """Get, List, Initiate and Cancel operations at Billing Account scope and is only for customers on MCA and MPA + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/partner_transfer/__init__.py b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/__init__.py new file mode 100644 index 00000000000..4f2631ad537 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._cancel import * +from ._get import * +from ._initiate import * +from ._list import * +from ._update import * diff --git a/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_cancel.py b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_cancel.py new file mode 100644 index 00000000000..632ceca0534 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_cancel.py @@ -0,0 +1,305 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing partner-transfer cancel", +) +class Cancel(AAZCommand): + """Cancels a transfer request. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: PartnerTransferCancel + az billing transfer cancel --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 --transfer-name aabb123 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/transfers/{}/cancel", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PartnerTransfersCancel(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PartnerTransfersCancel(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}/cancel", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CancelHelper: + """Helper class for Cancel""" + + +__all__ = ["Cancel"] diff --git a/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_get.py b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_get.py new file mode 100644 index 00000000000..07e7a1fff6d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_get.py @@ -0,0 +1,305 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing partner-transfer get", +) +class Get(AAZCommand): + """Get a transfer request by ID. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: PartnerTransferGet + az billing partner-transfer get --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 --transfer-name aabb123 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/transfers/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PartnerTransfersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PartnerTransfersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_initiate.py b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_initiate.py new file mode 100644 index 00000000000..6b7ac7dcfda --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_initiate.py @@ -0,0 +1,338 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing partner-transfer initiate", +) +class Initiate(AAZCommand): + """Create a request to a user in a customer's billing account to transfer billing ownership of their subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: InitiatePartnerTransfer + az billing partner-transfer initiate --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 --transfer-name aabb123 --recipient-email-id user@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/transfers/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.recipient_email_id = AAZStrArg( + options=["--recipient-email-id"], + arg_group="Properties", + help="The email ID of the recipient to whom the transfer request is sent.", + ) + _args_schema.reseller_id = AAZStrArg( + options=["--reseller-id"], + arg_group="Properties", + help="Optional MPN ID of the reseller for transfer requests that are sent from a Microsoft Partner Agreement billing account.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PartnerTransfersInitiate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PartnerTransfersInitiate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("recipientEmailId", AAZStrType, ".recipient_email_id") + properties.set_prop("resellerId", AAZStrType, ".reseller_id") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = cls._schema_on_200_201.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200_201.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _InitiateHelper: + """Helper class for Initiate""" + + +__all__ = ["Initiate"] diff --git a/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_list.py b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_list.py new file mode 100644 index 00000000000..ae5a4330f9d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_list.py @@ -0,0 +1,307 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing partner-transfer list", +) +class List(AAZCommand): + """List the transfer requests sent to a customer. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: PartnerTransfersList + az billing partner-transfer list --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/transfers", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PartnerTransfersList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class PartnerTransfersList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = cls._schema_on_200.value.Element.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.value.Element.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_update.py b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_update.py new file mode 100644 index 00000000000..f5fd12ab551 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/partner_transfer/_update.py @@ -0,0 +1,483 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing partner-transfer update", +) +class Update(AAZCommand): + """Update a request to a user in a customer's billing account to transfer billing ownership of their subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/transfers/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.recipient_email_id = AAZStrArg( + options=["--recipient-email-id"], + arg_group="Properties", + help="The email ID of the recipient to whom the transfer request is sent.", + nullable=True, + ) + _args_schema.reseller_id = AAZStrArg( + options=["--reseller-id"], + arg_group="Properties", + help="Optional MPN ID of the reseller for transfer requests that are sent from a Microsoft Partner Agreement billing account.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PartnerTransfersGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.PartnerTransfersInitiate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PartnerTransfersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_partner_transfer_details_read(cls._schema_on_200) + + return cls._schema_on_200 + + class PartnerTransfersInitiate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_partner_transfer_details_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("recipientEmailId", AAZStrType, ".recipient_email_id") + properties.set_prop("resellerId", AAZStrType, ".reseller_id") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_partner_transfer_details_read = None + + @classmethod + def _build_schema_partner_transfer_details_read(cls, _schema): + if cls._schema_partner_transfer_details_read is not None: + _schema.id = cls._schema_partner_transfer_details_read.id + _schema.name = cls._schema_partner_transfer_details_read.name + _schema.properties = cls._schema_partner_transfer_details_read.properties + _schema.system_data = cls._schema_partner_transfer_details_read.system_data + _schema.tags = cls._schema_partner_transfer_details_read.tags + _schema.type = cls._schema_partner_transfer_details_read.type + return + + cls._schema_partner_transfer_details_read = _schema_partner_transfer_details_read = AAZObjectType() + + partner_transfer_details_read = _schema_partner_transfer_details_read + partner_transfer_details_read.id = AAZStrType( + flags={"read_only": True}, + ) + partner_transfer_details_read.name = AAZStrType( + flags={"read_only": True}, + ) + partner_transfer_details_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + partner_transfer_details_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + partner_transfer_details_read.tags = AAZDictType() + partner_transfer_details_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_partner_transfer_details_read.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = _schema_partner_transfer_details_read.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = _schema_partner_transfer_details_read.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = _schema_partner_transfer_details_read.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = _schema_partner_transfer_details_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_partner_transfer_details_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_partner_transfer_details_read.id + _schema.name = cls._schema_partner_transfer_details_read.name + _schema.properties = cls._schema_partner_transfer_details_read.properties + _schema.system_data = cls._schema_partner_transfer_details_read.system_data + _schema.tags = cls._schema_partner_transfer_details_read.tags + _schema.type = cls._schema_partner_transfer_details_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/__cmd_group.py new file mode 100644 index 00000000000..f11e85573c1 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing payment-method", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations ( Get, List, Delete) at different scopes around Payment Methods + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/__init__.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/__init__.py new file mode 100644 index 00000000000..8f8fba0155e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/__init__.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._delete_by_user import * +from ._get_by_billing_account import * +from ._get_by_billing_profile import * +from ._get_by_user import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_user import * diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/_delete_by_user.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/_delete_by_user.py new file mode 100644 index 00000000000..2d889645288 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/_delete_by_user.py @@ -0,0 +1,127 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing payment-method delete-by-user", + confirmation="Are you sure you want to perform this operation?", +) +class DeleteByUser(AAZCommand): + """Delete a payment method owned by the caller. + + :example: DeletePaymentMethodOwnedByUser + az billing payment-method delete-by-user --payment-method-name ABCDABCDABC0 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/paymentmethods/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.payment_method_name = AAZStrArg( + options=["--payment-method-name"], + help="The ID that uniquely identifies a payment method.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PaymentMethodsDeleteByUser(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class PaymentMethodsDeleteByUser(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/paymentMethods/{paymentMethodName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "paymentMethodName", self.ctx.args.payment_method_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteByUserHelper: + """Helper class for DeleteByUser""" + + +__all__ = ["DeleteByUser"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_billing_account.py new file mode 100644 index 00000000000..bb1f9be18f0 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_billing_account.py @@ -0,0 +1,240 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing payment-method get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get a payment method available for a billing account. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: PaymentMethodGetAtBillingProfile + az billing payment-method get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31 --payment-method-name 21dd9edc-af71-4d62-80ce-37151d475326 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/paymentmethods/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.payment_method_name = AAZStrArg( + options=["--payment-method-name"], + help="The ID that uniquely identifies a payment method.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PaymentMethodsGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PaymentMethodsGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/paymentMethods/{paymentMethodName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "paymentMethodName", self.ctx.args.payment_method_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.expiration = AAZStrType( + flags={"read_only": True}, + ) + properties.family = AAZStrType() + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + properties.logos = AAZListType() + properties.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + properties.status = AAZStrType() + + logos = cls._schema_on_200.properties.logos + logos.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.logos.Element + _element.mime_type = AAZStrType( + serialized_name="mimeType", + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_billing_profile.py new file mode 100644 index 00000000000..72bce314656 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_billing_profile.py @@ -0,0 +1,304 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing payment-method get-by-billing-profile", +) +class GetByBillingProfile(AAZCommand): + """Get a payment method linked with a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: PaymentMethodsGetByBillingProfile + az billing payment-method get-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31 --billing-profile-name ABC1-A1CD-AB1-BP1 --payment-method-name ABCDABCDABC0 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/paymentmethodlinks/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + _args_schema.payment_method_name = AAZStrArg( + options=["--payment-method-name"], + help="The ID that uniquely identifies a payment method.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PaymentMethodsGetByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PaymentMethodsGetByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethodLinks/{paymentMethodName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "paymentMethodName", self.ctx.args.payment_method_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.expiration = AAZStrType( + flags={"read_only": True}, + ) + properties.family = AAZStrType( + flags={"read_only": True}, + ) + properties.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + properties.logos = AAZListType( + flags={"read_only": True}, + ) + properties.payment_method = AAZObjectType( + serialized_name="paymentMethod", + ) + properties.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + ) + properties.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + logos = cls._schema_on_200.properties.logos + logos.Element = AAZObjectType() + _GetByBillingProfileHelper._build_schema_payment_method_logo_read(logos.Element) + + payment_method = cls._schema_on_200.properties.payment_method + payment_method.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + payment_method.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + payment_method.expiration = AAZStrType( + flags={"read_only": True}, + ) + payment_method.family = AAZStrType() + payment_method.id = AAZStrType( + flags={"read_only": True}, + ) + payment_method.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + payment_method.logos = AAZListType() + payment_method.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + payment_method.status = AAZStrType() + + logos = cls._schema_on_200.properties.payment_method.logos + logos.Element = AAZObjectType() + _GetByBillingProfileHelper._build_schema_payment_method_logo_read(logos.Element) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingProfileHelper: + """Helper class for GetByBillingProfile""" + + _schema_payment_method_logo_read = None + + @classmethod + def _build_schema_payment_method_logo_read(cls, _schema): + if cls._schema_payment_method_logo_read is not None: + _schema.mime_type = cls._schema_payment_method_logo_read.mime_type + _schema.url = cls._schema_payment_method_logo_read.url + return + + cls._schema_payment_method_logo_read = _schema_payment_method_logo_read = AAZObjectType() + + payment_method_logo_read = _schema_payment_method_logo_read + payment_method_logo_read.mime_type = AAZStrType( + serialized_name="mimeType", + flags={"read_only": True}, + ) + payment_method_logo_read.url = AAZStrType( + flags={"read_only": True}, + ) + + _schema.mime_type = cls._schema_payment_method_logo_read.mime_type + _schema.url = cls._schema_payment_method_logo_read.url + + +__all__ = ["GetByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_user.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_user.py new file mode 100644 index 00000000000..ede0228dc5e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/_get_by_user.py @@ -0,0 +1,231 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing payment-method get-by-user", +) +class GetByUser(AAZCommand): + """Get a payment method owned by the caller. + + :example: GetPaymentMethodOwnedByUser + az billing payment-method get-by-user --payment-method-name ABCDABCDABC0 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/paymentmethods/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.payment_method_name = AAZStrArg( + options=["--payment-method-name"], + help="The ID that uniquely identifies a payment method.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PaymentMethodsGetByUser(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PaymentMethodsGetByUser(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/paymentMethods/{paymentMethodName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "paymentMethodName", self.ctx.args.payment_method_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.expiration = AAZStrType( + flags={"read_only": True}, + ) + properties.family = AAZStrType() + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + properties.logos = AAZListType() + properties.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + properties.status = AAZStrType() + + logos = cls._schema_on_200.properties.logos + logos.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.logos.Element + _element.mime_type = AAZStrType( + serialized_name="mimeType", + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByUserHelper: + """Helper class for GetByUser""" + + +__all__ = ["GetByUser"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_billing_account.py new file mode 100644 index 00000000000..2bc27cba32b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_billing_account.py @@ -0,0 +1,245 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing payment-method list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the payment methods available for a billing account. Along with the payment methods owned by the caller, these payment methods can be attached to a billing profile to make payments. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: PaymentMethodsListByBillingAccount + az billing payment-method list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/paymentmethods", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PaymentMethodsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class PaymentMethodsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/paymentMethods", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.expiration = AAZStrType( + flags={"read_only": True}, + ) + properties.family = AAZStrType() + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + properties.logos = AAZListType() + properties.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + properties.status = AAZStrType() + + logos = cls._schema_on_200.value.Element.properties.logos + logos.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.logos.Element + _element.mime_type = AAZStrType( + serialized_name="mimeType", + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_billing_profile.py new file mode 100644 index 00000000000..28cee2e43f0 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_billing_profile.py @@ -0,0 +1,309 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing payment-method list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List payment methods attached to a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: PaymentMethodsListByBillingProfile + az billing payment-method list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000032:00000000-0000-0000-0000-000000000099_2019-05-31 --billing-profile-name ABC1-A1CD-AB1-BP1 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/paymentmethodlinks", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PaymentMethodsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class PaymentMethodsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethodLinks", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.expiration = AAZStrType( + flags={"read_only": True}, + ) + properties.family = AAZStrType( + flags={"read_only": True}, + ) + properties.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + properties.logos = AAZListType( + flags={"read_only": True}, + ) + properties.payment_method = AAZObjectType( + serialized_name="paymentMethod", + ) + properties.payment_method_id = AAZStrType( + serialized_name="paymentMethodId", + ) + properties.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + logos = cls._schema_on_200.value.Element.properties.logos + logos.Element = AAZObjectType() + _ListByBillingProfileHelper._build_schema_payment_method_logo_read(logos.Element) + + payment_method = cls._schema_on_200.value.Element.properties.payment_method + payment_method.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + payment_method.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + payment_method.expiration = AAZStrType( + flags={"read_only": True}, + ) + payment_method.family = AAZStrType() + payment_method.id = AAZStrType( + flags={"read_only": True}, + ) + payment_method.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + payment_method.logos = AAZListType() + payment_method.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + payment_method.status = AAZStrType() + + logos = cls._schema_on_200.value.Element.properties.payment_method.logos + logos.Element = AAZObjectType() + _ListByBillingProfileHelper._build_schema_payment_method_logo_read(logos.Element) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + _schema_payment_method_logo_read = None + + @classmethod + def _build_schema_payment_method_logo_read(cls, _schema): + if cls._schema_payment_method_logo_read is not None: + _schema.mime_type = cls._schema_payment_method_logo_read.mime_type + _schema.url = cls._schema_payment_method_logo_read.url + return + + cls._schema_payment_method_logo_read = _schema_payment_method_logo_read = AAZObjectType() + + payment_method_logo_read = _schema_payment_method_logo_read + payment_method_logo_read.mime_type = AAZStrType( + serialized_name="mimeType", + flags={"read_only": True}, + ) + payment_method_logo_read.url = AAZStrType( + flags={"read_only": True}, + ) + + _schema.mime_type = cls._schema_payment_method_logo_read.mime_type + _schema.url = cls._schema_payment_method_logo_read.url + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_user.py b/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_user.py new file mode 100644 index 00000000000..328dc2c9edb --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/payment_method/_list_by_user.py @@ -0,0 +1,217 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing payment-method list-by-user", +) +class ListByUser(AAZCommand): + """List the payment methods owned by the caller. + + :example: ListPaymentMethodOwnedByUser + az billing payment-method list-by-user + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/paymentmethods", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + def _execute_operations(self): + self.pre_operations() + self.PaymentMethodsListByUser(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class PaymentMethodsListByUser(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/paymentMethods", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.account_holder_name = AAZStrType( + serialized_name="accountHolderName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.expiration = AAZStrType( + flags={"read_only": True}, + ) + properties.family = AAZStrType() + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.last_four_digits = AAZStrType( + serialized_name="lastFourDigits", + flags={"read_only": True}, + ) + properties.logos = AAZListType() + properties.payment_method_type = AAZStrType( + serialized_name="paymentMethodType", + flags={"read_only": True}, + ) + properties.status = AAZStrType() + + logos = cls._schema_on_200.value.Element.properties.logos + logos.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.logos.Element + _element.mime_type = AAZStrType( + serialized_name="mimeType", + flags={"read_only": True}, + ) + _element.url = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByUserHelper: + """Helper class for ListByUser""" + + +__all__ = ["ListByUser"] diff --git a/src/billing/azext_billing/aaz/latest/billing/period/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/period/__cmd_group.py new file mode 100644 index 00000000000..2cdffae141d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/period/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing period", +) +class __CMDGroup(AAZCommandGroup): + """Manage billing periods for a subscription. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/period/__init__.py b/src/billing/azext_billing/aaz/latest/billing/period/__init__.py new file mode 100644 index 00000000000..2df85698253 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/period/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * +from ._show import * diff --git a/src/billing/azext_billing/aaz/latest/billing/period/_list.py b/src/billing/azext_billing/aaz/latest/billing/period/_list.py new file mode 100644 index 00000000000..7fc77a332b4 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/period/_list.py @@ -0,0 +1,214 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing period list", +) +class List(AAZCommand): + """List 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. + """ + + _aaz_info = { + "version": "2018-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.billing/billingperiods", "2018-03-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="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'.", + ) + _args_schema.skiptoken = AAZStrArg( + options=["--skiptoken"], + help="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.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="May be used to limit the number of results to the most recent N billing periods.", + fmt=AAZIntArgFormat( + maximum=100, + minimum=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPeriodsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPeriodsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "$skiptoken", self.ctx.args.skiptoken, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2018-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_period_end_date = AAZStrType( + serialized_name="billingPeriodEndDate", + flags={"read_only": True}, + ) + properties.billing_period_start_date = AAZStrType( + serialized_name="billingPeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_ids = AAZListType( + serialized_name="invoiceIds", + flags={"read_only": True}, + ) + + invoice_ids = cls._schema_on_200.value.Element.properties.invoice_ids + invoice_ids.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/period/_show.py b/src/billing/azext_billing/aaz/latest/billing/period/_show.py new file mode 100644 index 00000000000..12a63d11673 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/period/_show.py @@ -0,0 +1,185 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing period show", +) +class Show(AAZCommand): + """Show 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. + """ + + _aaz_info = { + "version": "2018-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.billing/billingperiods/{}", "2018-03-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the billing period. Run the az billing period list command to list the name of billing period", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPeriodsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPeriodsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingPeriodName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2018-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_period_end_date = AAZStrType( + serialized_name="billingPeriodEndDate", + flags={"read_only": True}, + ) + properties.billing_period_start_date = AAZStrType( + serialized_name="billingPeriodStartDate", + flags={"read_only": True}, + ) + properties.invoice_ids = AAZListType( + serialized_name="invoiceIds", + flags={"read_only": True}, + ) + + invoice_ids = cls._schema_on_200.properties.invoice_ids + invoice_ids.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/permission/__cmd_group.py new file mode 100644 index 00000000000..bd14478c013 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing permission", +) +class __CMDGroup(AAZCommandGroup): + """Check Access at multiple scopes like Billing Accounts, Billing Profile, Customer etc. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/__init__.py b/src/billing/azext_billing/aaz/latest/billing/permission/__init__.py new file mode 100644 index 00000000000..9d11358cb24 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/__init__.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._check_access_by_billing_account import * +from ._check_access_by_billing_profile import * +from ._check_access_by_customer import * +from ._check_access_by_department import * +from ._check_access_by_enrollment_account import * +from ._check_access_by_invoice_section import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_customer import * +from ._list_by_customer_at_billing_account import * +from ._list_by_department import * +from ._list_by_enrollment_account import * +from ._list_by_invoice_section import * diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_billing_account.py new file mode 100644 index 00000000000..b3152bf7d8a --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_billing_account.py @@ -0,0 +1,195 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission check-access-by-billing-account", +) +class CheckAccessByBillingAccount(AAZCommand): + """Provides a list of check access response objects for a billing account. + + :example: CheckAccessByBillingAccount + az billing permission check-access-by-billing-account --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --actions "[Microsoft.Billing/billingAccounts/read,Microsoft.Subscription/subscriptions/write]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/checkaccess", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.actions = AAZListArg( + options=["--actions"], + arg_group="Parameters", + help="List of actions passed in the request body against which the permissions will be checked.", + ) + + actions = cls._args_schema.actions + actions.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsCheckAccessByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPermissionsCheckAccessByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/checkAccess", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("actions", AAZListType, ".actions") + + actions = _builder.get(".actions") + if actions is not None: + actions.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.access_decision = AAZStrType( + serialized_name="accessDecision", + flags={"read_only": True}, + ) + _element.action = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CheckAccessByBillingAccountHelper: + """Helper class for CheckAccessByBillingAccount""" + + +__all__ = ["CheckAccessByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_billing_profile.py new file mode 100644 index 00000000000..5ddefb85dc1 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_billing_profile.py @@ -0,0 +1,207 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission check-access-by-billing-profile", +) +class CheckAccessByBillingProfile(AAZCommand): + """Provides a list of check access response objects for a billing profile. + + :example: CheckAccessByBillingProfile + az billing permission check-access-by-billing-profile --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --actions "[Microsoft.Billing/billingAccounts/read,Microsoft.Subscription/subscriptions/write]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/checkaccess", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.actions = AAZListArg( + options=["--actions"], + arg_group="Parameters", + help="List of actions passed in the request body against which the permissions will be checked.", + ) + + actions = cls._args_schema.actions + actions.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsCheckAccessByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPermissionsCheckAccessByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/checkAccess", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("actions", AAZListType, ".actions") + + actions = _builder.get(".actions") + if actions is not None: + actions.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.access_decision = AAZStrType( + serialized_name="accessDecision", + flags={"read_only": True}, + ) + _element.action = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CheckAccessByBillingProfileHelper: + """Helper class for CheckAccessByBillingProfile""" + + +__all__ = ["CheckAccessByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_customer.py new file mode 100644 index 00000000000..56f48c08a5f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_customer.py @@ -0,0 +1,219 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission check-access-by-customer", +) +class CheckAccessByCustomer(AAZCommand): + """Provides a list of check access response objects for a customer. + + :example: CheckAccessByCustomer + az billing permission check-access-by-customer --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 703ab484-dda2-4402-827b-a74513b61e2d --actions "[Microsoft.Billing/billingAccounts/read,Microsoft.Subscription/subscriptions/write]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/checkaccess", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.actions = AAZListArg( + options=["--actions"], + arg_group="Parameters", + help="List of actions passed in the request body against which the permissions will be checked.", + ) + + actions = cls._args_schema.actions + actions.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsCheckAccessByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPermissionsCheckAccessByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/checkAccess", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("actions", AAZListType, ".actions") + + actions = _builder.get(".actions") + if actions is not None: + actions.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.access_decision = AAZStrType( + serialized_name="accessDecision", + flags={"read_only": True}, + ) + _element.action = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CheckAccessByCustomerHelper: + """Helper class for CheckAccessByCustomer""" + + +__all__ = ["CheckAccessByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_department.py b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_department.py new file mode 100644 index 00000000000..d7054281961 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_department.py @@ -0,0 +1,207 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission check-access-by-department", +) +class CheckAccessByDepartment(AAZCommand): + """Provides a list of check access response objects for a department. + + :example: CheckAccessByDepartment + az billing permission check-access-by-department --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --department-name 12345 --actions "[Microsoft.Billing/billingAccounts/read,Microsoft.Subscription/subscriptions/write]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/checkaccess", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.actions = AAZListArg( + options=["--actions"], + arg_group="Parameters", + help="List of actions passed in the request body against which the permissions will be checked.", + ) + + actions = cls._args_schema.actions + actions.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsCheckAccessByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPermissionsCheckAccessByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/checkAccess", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("actions", AAZListType, ".actions") + + actions = _builder.get(".actions") + if actions is not None: + actions.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.access_decision = AAZStrType( + serialized_name="accessDecision", + flags={"read_only": True}, + ) + _element.action = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CheckAccessByDepartmentHelper: + """Helper class for CheckAccessByDepartment""" + + +__all__ = ["CheckAccessByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_enrollment_account.py new file mode 100644 index 00000000000..06c0ec85838 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_enrollment_account.py @@ -0,0 +1,207 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission check-access-by-enrollment-account", +) +class CheckAccessByEnrollmentAccount(AAZCommand): + """Provides a list of check access response objects for an enrollment account. + + :example: CheckAccessByEnrollmentAccount + az billing permission check-access-by-enrollment-account --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --enrollment-account-name 123456 --actions "[Microsoft.Billing/billingAccounts/read,Microsoft.Subscription/subscriptions/write]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/checkaccess", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.actions = AAZListArg( + options=["--actions"], + arg_group="Parameters", + help="List of actions passed in the request body against which the permissions will be checked.", + ) + + actions = cls._args_schema.actions + actions.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsCheckAccessByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPermissionsCheckAccessByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/checkAccess", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("actions", AAZListType, ".actions") + + actions = _builder.get(".actions") + if actions is not None: + actions.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.access_decision = AAZStrType( + serialized_name="accessDecision", + flags={"read_only": True}, + ) + _element.action = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CheckAccessByEnrollmentAccountHelper: + """Helper class for CheckAccessByEnrollmentAccount""" + + +__all__ = ["CheckAccessByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_invoice_section.py new file mode 100644 index 00000000000..5c0ed928b94 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_check_access_by_invoice_section.py @@ -0,0 +1,219 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission check-access-by-invoice-section", +) +class CheckAccessByInvoiceSection(AAZCommand): + """Provides a list of check access response objects for an invoice section. + + :example: CheckAccessByInvoiceSection + az billing permission check-access-by-invoice-section --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name Q7GV-UUVA-PJA-TGB --actions "[Microsoft.Billing/billingAccounts/read,Microsoft.Subscription/subscriptions/write]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/checkaccess", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.actions = AAZListArg( + options=["--actions"], + arg_group="Parameters", + help="List of actions passed in the request body against which the permissions will be checked.", + ) + + actions = cls._args_schema.actions + actions.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsCheckAccessByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingPermissionsCheckAccessByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/checkAccess", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("actions", AAZListType, ".actions") + + actions = _builder.get(".actions") + if actions is not None: + actions.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.access_decision = AAZStrType( + serialized_name="accessDecision", + flags={"read_only": True}, + ) + _element.action = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CheckAccessByInvoiceSectionHelper: + """Helper class for CheckAccessByInvoiceSection""" + + +__all__ = ["CheckAccessByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_billing_account.py new file mode 100644 index 00000000000..ad3fb351850 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_billing_account.py @@ -0,0 +1,184 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the billing permissions the caller has on a billing account. + + :example: BillingPermissionsListByBillingAccount + az billing permission list-by-billing-account --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingpermissions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_billing_profile.py new file mode 100644 index 00000000000..3368a8724e2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_billing_profile.py @@ -0,0 +1,196 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List the billing permissions the caller has on a billing profile. + + :example: BillingPermissionsListByBillingProfile + az billing permission list-by-billing-profile --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingpermissions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_customer.py new file mode 100644 index 00000000000..d4839527400 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_customer.py @@ -0,0 +1,208 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission list-by-customer", +) +class ListByCustomer(AAZCommand): + """List the billing permissions the caller has for a customer. + + :example: BillingPermissionsListByCustomer + az billing permission list-by-customer --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name BKM6-54VH-BG7-PGB --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingpermissions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerHelper: + """Helper class for ListByCustomer""" + + +__all__ = ["ListByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_customer_at_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_customer_at_billing_account.py new file mode 100644 index 00000000000..fbc8e475bf0 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_customer_at_billing_account.py @@ -0,0 +1,196 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission list-by-customer-at-billing-account", +) +class ListByCustomerAtBillingAccount(AAZCommand): + """List the billing permissions the caller has for a customer at billing account level. + + :example: BillingPermissionsListByCustomerAtBillingAccount + az billing permission list-by-customer --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers/{}/billingpermissions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByCustomerAtBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByCustomerAtBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerAtBillingAccountHelper: + """Helper class for ListByCustomerAtBillingAccount""" + + +__all__ = ["ListByCustomerAtBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_department.py b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_department.py new file mode 100644 index 00000000000..10903d76134 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_department.py @@ -0,0 +1,196 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission list-by-department", +) +class ListByDepartment(AAZCommand): + """List the billing permissions the caller has for a department. + + :example: BillingPermissionsListByDepartment + az billing permission list-by-department --billing-account-name 6100092 --department-name 123456 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingpermissions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByDepartmentHelper: + """Helper class for ListByDepartment""" + + +__all__ = ["ListByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_enrollment_account.py new file mode 100644 index 00000000000..6514bd937e7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_enrollment_account.py @@ -0,0 +1,196 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission list-by-enrollment-account", +) +class ListByEnrollmentAccount(AAZCommand): + """List the billing permissions the caller has on an enrollment account. + + :example: BillingPermissionsListByEnrollmentAccount + az billing permission list-by-enrollment-account --billing-account-name 6100092 --enrollment-account-name 123456 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingpermissions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The ID that uniquely identifies an enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByEnrollmentAccountHelper: + """Helper class for ListByEnrollmentAccount""" + + +__all__ = ["ListByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_invoice_section.py new file mode 100644 index 00000000000..9d1aa536504 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/permission/_list_by_invoice_section.py @@ -0,0 +1,208 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing permission list-by-invoice-section", +) +class ListByInvoiceSection(AAZCommand): + """List the billing permissions the caller has for an invoice section. + + :example: BillingPermissionsListByInvoiceSection + az billing permission list-by-invoice-section --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name XXXX-XXXX-XXX-XXX + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingpermissions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingPermissionsListByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingPermissionsListByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.not_actions + not_actions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceSectionHelper: + """Helper class for ListByInvoiceSection""" + + +__all__ = ["ListByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/policy/__cmd_group.py new file mode 100644 index 00000000000..00671936322 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing policy", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations ( Get, List, Create) at different scopes around policies and is only for customers on MCA and MPA + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/__init__.py b/src/billing/azext_billing/aaz/latest/billing/policy/__init__.py new file mode 100644 index 00000000000..081cd8a4354 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/__init__.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create_by_billing_profile import * +from ._create_by_customer import * +from ._create_by_customer_at_billing_account import * +from ._create_or_update_by_billing_account import * +from ._get_by_billing_account import * +from ._get_by_billing_profile import * +from ._get_by_customer import * +from ._get_by_customer_at_billing_account import * +from ._get_by_subscription import * +from ._update_by_billing_account import * +from ._update_by_billing_profile import * +from ._update_by_customer_at_billing_account import * diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_billing_profile.py new file mode 100644 index 00000000000..b339f7856a4 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_billing_profile.py @@ -0,0 +1,410 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy create-by-billing-profile", +) +class CreateByBillingProfile(AAZCommand): + """Create the policies for a billing profile. This operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: PoliciesPutByBillingProfile + az billing policy create-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-label-management Allowed --marketplace-purchases AllAllowed --reservation-purchases Allowed --savings-plan-purchases Allowed + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/policies/default", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.enterprise_agreement_policies = AAZObjectArg( + options=["--enterprise-agreement-policies"], + arg_group="Properties", + help="The policies for Enterprise Agreement enrollments.", + ) + _args_schema.invoice_section_label_management = AAZStrArg( + options=["--invoice-section-label-management"], + arg_group="Properties", + help="The policy that controls invoice section label management at invoice section scope. This is allowed by default.", + enum={"Allowed": "Allowed", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.marketplace_purchases = AAZStrArg( + options=["--marketplace-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure marketplace purchases are allowed.", + enum={"AllAllowed": "AllAllowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "OnlyFreeAllowed": "OnlyFreeAllowed", "Other": "Other"}, + ) + _args_schema.policies = AAZListArg( + options=["--policies"], + arg_group="Properties", + help="List of all policies defined at the billing scope.", + ) + _args_schema.reservation_purchases = AAZStrArg( + options=["--reservation-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure reservation purchases are allowed.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.savings_plan_purchases = AAZStrArg( + options=["--savings-plan-purchases"], + arg_group="Properties", + help="The policy that controls whether users with Azure savings plan purchase are allowed.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.view_charges = AAZStrArg( + options=["--view-charges"], + arg_group="Properties", + help="The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices.", + enum={"Allowed": "Allowed", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + enterprise_agreement_policies = cls._args_schema.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrArg( + options=["account-owner-view-charges"], + help="The policy that controls whether account owner can view charges.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + enterprise_agreement_policies.authentication_type = AAZStrArg( + options=["authentication-type"], + help="The state showing the enrollment auth level.", + enum={"MicrosoftAccountOnly": "MicrosoftAccountOnly", "MixedAccount": "MixedAccount", "OrganizationalAccountCrossTenant": "OrganizationalAccountCrossTenant", "OrganizationalAccountOnly": "OrganizationalAccountOnly", "Other": "Other"}, + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrArg( + options=["department-admin-view-charges"], + help="The policy that controls whether department admin can view charges.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + policies = cls._args_schema.policies + policies.Element = AAZObjectArg() + + _element = cls._args_schema.policies.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the policy.", + ) + _element.policy_type = AAZStrArg( + options=["policy-type"], + help="The type of the policy.", + enum={"Other": "Other", "SystemControlled": "SystemControlled", "UserControlled": "UserControlled"}, + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope at which the policy is defined.", + ) + _element.value = AAZStrArg( + options=["value"], + help="The value of the policy.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PoliciesCreateOrUpdateByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesCreateOrUpdateByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("enterpriseAgreementPolicies", AAZObjectType, ".enterprise_agreement_policies") + properties.set_prop("invoiceSectionLabelManagement", AAZStrType, ".invoice_section_label_management") + properties.set_prop("marketplacePurchases", AAZStrType, ".marketplace_purchases") + properties.set_prop("policies", AAZListType, ".policies") + properties.set_prop("reservationPurchases", AAZStrType, ".reservation_purchases") + properties.set_prop("savingsPlanPurchases", AAZStrType, ".savings_plan_purchases") + properties.set_prop("viewCharges", AAZStrType, ".view_charges") + + enterprise_agreement_policies = _builder.get(".properties.enterpriseAgreementPolicies") + if enterprise_agreement_policies is not None: + enterprise_agreement_policies.set_prop("accountOwnerViewCharges", AAZStrType, ".account_owner_view_charges") + enterprise_agreement_policies.set_prop("authenticationType", AAZStrType, ".authentication_type") + enterprise_agreement_policies.set_prop("departmentAdminViewCharges", AAZStrType, ".department_admin_view_charges") + + policies = _builder.get(".properties.policies") + if policies is not None: + policies.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.policies[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("policyType", AAZStrType, ".policy_type") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("value", AAZStrType, ".value") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.enterprise_agreement_policies = AAZObjectType( + serialized_name="enterpriseAgreementPolicies", + ) + properties.invoice_section_label_management = AAZStrType( + serialized_name="invoiceSectionLabelManagement", + ) + properties.marketplace_purchases = AAZStrType( + serialized_name="marketplacePurchases", + ) + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reservation_purchases = AAZStrType( + serialized_name="reservationPurchases", + ) + properties.savings_plan_purchases = AAZStrType( + serialized_name="savingsPlanPurchases", + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + ) + + enterprise_agreement_policies = cls._schema_on_200_201.properties.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrType( + serialized_name="accountOwnerViewCharges", + ) + enterprise_agreement_policies.authentication_type = AAZStrType( + serialized_name="authenticationType", + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrType( + serialized_name="departmentAdminViewCharges", + ) + + policies = cls._schema_on_200_201.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateByBillingProfileHelper: + """Helper class for CreateByBillingProfile""" + + +__all__ = ["CreateByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_customer.py new file mode 100644 index 00000000000..b470e23f2d8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_customer.py @@ -0,0 +1,340 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy create-by-customer", +) +class CreateByCustomer(AAZCommand): + """Create the policies for a customer. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: PoliciesPutByCustomer + az billing policy create-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 --view-charges Allowed + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/policies/default", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.policies = AAZListArg( + options=["--policies"], + arg_group="Properties", + help="List of all policies defined at the billing scope.", + ) + _args_schema.view_charges = AAZStrArg( + options=["--view-charges"], + arg_group="Properties", + help="The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices.", + enum={"Allowed": "Allowed", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + policies = cls._args_schema.policies + policies.Element = AAZObjectArg() + + _element = cls._args_schema.policies.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the policy.", + ) + _element.policy_type = AAZStrArg( + options=["policy-type"], + help="The type of the policy.", + enum={"Other": "Other", "SystemControlled": "SystemControlled", "UserControlled": "UserControlled"}, + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope at which the policy is defined.", + ) + _element.value = AAZStrArg( + options=["value"], + help="The value of the policy.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PoliciesCreateOrUpdateByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesCreateOrUpdateByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("policies", AAZListType, ".policies") + properties.set_prop("viewCharges", AAZStrType, ".view_charges", typ_kwargs={"flags": {"required": True}}) + + policies = _builder.get(".properties.policies") + if policies is not None: + policies.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.policies[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("policyType", AAZStrType, ".policy_type") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("value", AAZStrType, ".value") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + flags={"required": True}, + ) + + policies = cls._schema_on_200_201.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateByCustomerHelper: + """Helper class for CreateByCustomer""" + + +__all__ = ["CreateByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_customer_at_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_customer_at_billing_account.py new file mode 100644 index 00000000000..314f3e54834 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_create_by_customer_at_billing_account.py @@ -0,0 +1,328 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy create-by-customer-at-billing-account", +) +class CreateByCustomerAtBillingAccount(AAZCommand): + """Create the policies for a customer at billing account scope. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: PoliciesPutByCustomerAtBillingAccount + az billing policy create-by-customer-at-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --customer-name 11111111-1111-1111-1111-111111111111 --view-charges Allowed + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers/{}/policies/default", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.policies = AAZListArg( + options=["--policies"], + arg_group="Properties", + help="List of all policies defined at the billing scope.", + ) + _args_schema.view_charges = AAZStrArg( + options=["--view-charges"], + arg_group="Properties", + help="The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices.", + enum={"Allowed": "Allowed", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + policies = cls._args_schema.policies + policies.Element = AAZObjectArg() + + _element = cls._args_schema.policies.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the policy.", + ) + _element.policy_type = AAZStrArg( + options=["policy-type"], + help="The type of the policy.", + enum={"Other": "Other", "SystemControlled": "SystemControlled", "UserControlled": "UserControlled"}, + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope at which the policy is defined.", + ) + _element.value = AAZStrArg( + options=["value"], + help="The value of the policy.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PoliciesCreateOrUpdateByCustomerAtBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesCreateOrUpdateByCustomerAtBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("policies", AAZListType, ".policies") + properties.set_prop("viewCharges", AAZStrType, ".view_charges", typ_kwargs={"flags": {"required": True}}) + + policies = _builder.get(".properties.policies") + if policies is not None: + policies.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.policies[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("policyType", AAZStrType, ".policy_type") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("value", AAZStrType, ".value") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + flags={"required": True}, + ) + + policies = cls._schema_on_200_201.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateByCustomerAtBillingAccountHelper: + """Helper class for CreateByCustomerAtBillingAccount""" + + +__all__ = ["CreateByCustomerAtBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_create_or_update_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/policy/_create_or_update_by_billing_account.py new file mode 100644 index 00000000000..b3f8fd9ee82 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_create_or_update_by_billing_account.py @@ -0,0 +1,378 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy create-or-update-by-billing-account", +) +class CreateOrUpdateByBillingAccount(AAZCommand): + """Create the policies for a billing account of Enterprise Agreement type. + + :example: PoliciesPutByBillingAccount + az billing policy create-or-update-by-billing-account --billing-account-name 1234567 --enterprise-agreement-policies "{authentication-type:OrganizationalAccountOnly}" --marketplace-purchases AllAllowed --reservation-purchases Allowed --savings-plan-purchases NotAllowed + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/policies/default", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.enterprise_agreement_policies = AAZObjectArg( + options=["--enterprise-agreement-policies"], + arg_group="Properties", + help="The policies for Enterprise Agreement enrollments.", + ) + _args_schema.marketplace_purchases = AAZStrArg( + options=["--marketplace-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure marketplace purchases are allowed.", + enum={"AllAllowed": "AllAllowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "OnlyFreeAllowed": "OnlyFreeAllowed", "Other": "Other"}, + ) + _args_schema.policies = AAZListArg( + options=["--policies"], + arg_group="Properties", + help="List of all policies defined at the billing scope.", + ) + _args_schema.reservation_purchases = AAZStrArg( + options=["--reservation-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure reservation purchases are allowed.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.savings_plan_purchases = AAZStrArg( + options=["--savings-plan-purchases"], + arg_group="Properties", + help="The policy that controls whether users with Azure savings plan purchase are allowed.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + enterprise_agreement_policies = cls._args_schema.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrArg( + options=["account-owner-view-charges"], + help="The policy that controls whether account owner can view charges.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + enterprise_agreement_policies.authentication_type = AAZStrArg( + options=["authentication-type"], + help="The state showing the enrollment auth level.", + enum={"MicrosoftAccountOnly": "MicrosoftAccountOnly", "MixedAccount": "MixedAccount", "OrganizationalAccountCrossTenant": "OrganizationalAccountCrossTenant", "OrganizationalAccountOnly": "OrganizationalAccountOnly", "Other": "Other"}, + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrArg( + options=["department-admin-view-charges"], + help="The policy that controls whether department admin can view charges.", + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + policies = cls._args_schema.policies + policies.Element = AAZObjectArg() + + _element = cls._args_schema.policies.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the policy.", + ) + _element.policy_type = AAZStrArg( + options=["policy-type"], + help="The type of the policy.", + enum={"Other": "Other", "SystemControlled": "SystemControlled", "UserControlled": "UserControlled"}, + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope at which the policy is defined.", + ) + _element.value = AAZStrArg( + options=["value"], + help="The value of the policy.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PoliciesCreateOrUpdateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesCreateOrUpdateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("enterpriseAgreementPolicies", AAZObjectType, ".enterprise_agreement_policies") + properties.set_prop("marketplacePurchases", AAZStrType, ".marketplace_purchases") + properties.set_prop("policies", AAZListType, ".policies") + properties.set_prop("reservationPurchases", AAZStrType, ".reservation_purchases") + properties.set_prop("savingsPlanPurchases", AAZStrType, ".savings_plan_purchases") + + enterprise_agreement_policies = _builder.get(".properties.enterpriseAgreementPolicies") + if enterprise_agreement_policies is not None: + enterprise_agreement_policies.set_prop("accountOwnerViewCharges", AAZStrType, ".account_owner_view_charges") + enterprise_agreement_policies.set_prop("authenticationType", AAZStrType, ".authentication_type") + enterprise_agreement_policies.set_prop("departmentAdminViewCharges", AAZStrType, ".department_admin_view_charges") + + policies = _builder.get(".properties.policies") + if policies is not None: + policies.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.policies[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("policyType", AAZStrType, ".policy_type") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("value", AAZStrType, ".value") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.enterprise_agreement_policies = AAZObjectType( + serialized_name="enterpriseAgreementPolicies", + ) + properties.marketplace_purchases = AAZStrType( + serialized_name="marketplacePurchases", + ) + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reservation_purchases = AAZStrType( + serialized_name="reservationPurchases", + ) + properties.savings_plan_purchases = AAZStrType( + serialized_name="savingsPlanPurchases", + ) + + enterprise_agreement_policies = cls._schema_on_200_201.properties.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrType( + serialized_name="accountOwnerViewCharges", + ) + enterprise_agreement_policies.authentication_type = AAZStrType( + serialized_name="authenticationType", + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrType( + serialized_name="departmentAdminViewCharges", + ) + + policies = cls._schema_on_200_201.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateOrUpdateByBillingAccountHelper: + """Helper class for CreateOrUpdateByBillingAccount""" + + +__all__ = ["CreateOrUpdateByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_billing_account.py new file mode 100644 index 00000000000..31d183392f2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_billing_account.py @@ -0,0 +1,234 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get the policies for a billing account of Enterprise Agreement type. + + :example: PoliciesGetByBillingAccount + az billing policy get-by-billing-account --billing-account-name 1234567 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/policies/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.enterprise_agreement_policies = AAZObjectType( + serialized_name="enterpriseAgreementPolicies", + ) + properties.marketplace_purchases = AAZStrType( + serialized_name="marketplacePurchases", + ) + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reservation_purchases = AAZStrType( + serialized_name="reservationPurchases", + ) + properties.savings_plan_purchases = AAZStrType( + serialized_name="savingsPlanPurchases", + ) + + enterprise_agreement_policies = cls._schema_on_200.properties.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrType( + serialized_name="accountOwnerViewCharges", + ) + enterprise_agreement_policies.authentication_type = AAZStrType( + serialized_name="authenticationType", + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrType( + serialized_name="departmentAdminViewCharges", + ) + + policies = cls._schema_on_200.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_billing_profile.py new file mode 100644 index 00000000000..b66a720e8fb --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_billing_profile.py @@ -0,0 +1,252 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy get-by-billing-profile", +) +class GetByBillingProfile(AAZCommand): + """Get the policies for a billing profile. This operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: PoliciesGetByBillingProfile + az billing policy get-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/policies/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.enterprise_agreement_policies = AAZObjectType( + serialized_name="enterpriseAgreementPolicies", + ) + properties.invoice_section_label_management = AAZStrType( + serialized_name="invoiceSectionLabelManagement", + ) + properties.marketplace_purchases = AAZStrType( + serialized_name="marketplacePurchases", + ) + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reservation_purchases = AAZStrType( + serialized_name="reservationPurchases", + ) + properties.savings_plan_purchases = AAZStrType( + serialized_name="savingsPlanPurchases", + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + ) + + enterprise_agreement_policies = cls._schema_on_200.properties.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrType( + serialized_name="accountOwnerViewCharges", + ) + enterprise_agreement_policies.authentication_type = AAZStrType( + serialized_name="authenticationType", + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrType( + serialized_name="departmentAdminViewCharges", + ) + + policies = cls._schema_on_200.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingProfileHelper: + """Helper class for GetByBillingProfile""" + + +__all__ = ["GetByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_customer.py new file mode 100644 index 00000000000..8c29b770316 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_customer.py @@ -0,0 +1,252 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy get-by-customer", +) +class GetByCustomer(AAZCommand): + """Get the policies for a customer. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: PoliciesGetByCustomer + az billing policy get-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 --policy-name default + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/policies/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.policy_name = AAZStrArg( + options=["--policy-name"], + help="Service-defined resource names such as 'default' which are reserved resource names.", + required=True, + enum={"default": "default"}, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/policies/{policyName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + **self.serialize_url_param( + "policyName", self.ctx.args.policy_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + flags={"required": True}, + ) + + policies = cls._schema_on_200.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByCustomerHelper: + """Helper class for GetByCustomer""" + + +__all__ = ["GetByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_customer_at_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_customer_at_billing_account.py new file mode 100644 index 00000000000..f858d3ae380 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_customer_at_billing_account.py @@ -0,0 +1,227 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy get-by-customer-at-billing-account", +) +class GetByCustomerAtBillingAccount(AAZCommand): + """Get the policies for a customer at billing account scope. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: PoliciesGetByCustomerAtBillingAccount + az billing policy get-by-customer-at-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers/{}/policies/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetByCustomerAtBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetByCustomerAtBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + flags={"required": True}, + ) + + policies = cls._schema_on_200.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByCustomerAtBillingAccountHelper: + """Helper class for GetByCustomerAtBillingAccount""" + + +__all__ = ["GetByCustomerAtBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_subscription.py b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_subscription.py new file mode 100644 index 00000000000..0988207889c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_get_by_subscription.py @@ -0,0 +1,201 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy get-by-subscription", +) +class GetBySubscription(AAZCommand): + """Get the policies that are managed by the Billing Admin for the defined subscriptions. This is supported for Microsoft Online Services Program, Microsoft Customer Agreement and Microsoft Partner Agreement. + + :example: PoliciesGetBySubscription + az billing policy get-by-subscription + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.billing/policies/default", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetBySubscription(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + policies = cls._schema_on_200.properties.policies + policies.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetBySubscriptionHelper: + """Helper class for GetBySubscription""" + + +__all__ = ["GetBySubscription"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_billing_account.py new file mode 100644 index 00000000000..07a2dc9a92f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_billing_account.py @@ -0,0 +1,515 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy update-by-billing-account", +) +class UpdateByBillingAccount(AAZCommand): + """Update the policies for a billing account of Enterprise Agreement type. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/policies/default", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.enterprise_agreement_policies = AAZObjectArg( + options=["--enterprise-agreement-policies"], + arg_group="Properties", + help="The policies for Enterprise Agreement enrollments.", + nullable=True, + ) + _args_schema.marketplace_purchases = AAZStrArg( + options=["--marketplace-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure marketplace purchases are allowed.", + nullable=True, + enum={"AllAllowed": "AllAllowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "OnlyFreeAllowed": "OnlyFreeAllowed", "Other": "Other"}, + ) + _args_schema.policies = AAZListArg( + options=["--policies"], + arg_group="Properties", + help="List of all policies defined at the billing scope.", + nullable=True, + ) + _args_schema.reservation_purchases = AAZStrArg( + options=["--reservation-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure reservation purchases are allowed.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.savings_plan_purchases = AAZStrArg( + options=["--savings-plan-purchases"], + arg_group="Properties", + help="The policy that controls whether users with Azure savings plan purchase are allowed.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + enterprise_agreement_policies = cls._args_schema.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrArg( + options=["account-owner-view-charges"], + help="The policy that controls whether account owner can view charges.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + enterprise_agreement_policies.authentication_type = AAZStrArg( + options=["authentication-type"], + help="The state showing the enrollment auth level.", + nullable=True, + enum={"MicrosoftAccountOnly": "MicrosoftAccountOnly", "MixedAccount": "MixedAccount", "OrganizationalAccountCrossTenant": "OrganizationalAccountCrossTenant", "OrganizationalAccountOnly": "OrganizationalAccountOnly", "Other": "Other"}, + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrArg( + options=["department-admin-view-charges"], + help="The policy that controls whether department admin can view charges.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + policies = cls._args_schema.policies + policies.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.policies.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the policy.", + nullable=True, + ) + _element.policy_type = AAZStrArg( + options=["policy-type"], + help="The type of the policy.", + nullable=True, + enum={"Other": "Other", "SystemControlled": "SystemControlled", "UserControlled": "UserControlled"}, + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope at which the policy is defined.", + nullable=True, + ) + _element.value = AAZStrArg( + options=["value"], + help="The value of the policy.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetByBillingAccount(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.PoliciesCreateOrUpdateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateByBillingAccountHelper._build_schema_billing_account_policy_read(cls._schema_on_200) + + return cls._schema_on_200 + + class PoliciesCreateOrUpdateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateByBillingAccountHelper._build_schema_billing_account_policy_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("enterpriseAgreementPolicies", AAZObjectType, ".enterprise_agreement_policies") + properties.set_prop("marketplacePurchases", AAZStrType, ".marketplace_purchases") + properties.set_prop("policies", AAZListType, ".policies") + properties.set_prop("reservationPurchases", AAZStrType, ".reservation_purchases") + properties.set_prop("savingsPlanPurchases", AAZStrType, ".savings_plan_purchases") + + enterprise_agreement_policies = _builder.get(".properties.enterpriseAgreementPolicies") + if enterprise_agreement_policies is not None: + enterprise_agreement_policies.set_prop("accountOwnerViewCharges", AAZStrType, ".account_owner_view_charges") + enterprise_agreement_policies.set_prop("authenticationType", AAZStrType, ".authentication_type") + enterprise_agreement_policies.set_prop("departmentAdminViewCharges", AAZStrType, ".department_admin_view_charges") + + policies = _builder.get(".properties.policies") + if policies is not None: + policies.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.policies[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("policyType", AAZStrType, ".policy_type") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("value", AAZStrType, ".value") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + +class _UpdateByBillingAccountHelper: + """Helper class for UpdateByBillingAccount""" + + _schema_billing_account_policy_read = None + + @classmethod + def _build_schema_billing_account_policy_read(cls, _schema): + if cls._schema_billing_account_policy_read is not None: + _schema.id = cls._schema_billing_account_policy_read.id + _schema.name = cls._schema_billing_account_policy_read.name + _schema.properties = cls._schema_billing_account_policy_read.properties + _schema.system_data = cls._schema_billing_account_policy_read.system_data + _schema.tags = cls._schema_billing_account_policy_read.tags + _schema.type = cls._schema_billing_account_policy_read.type + return + + cls._schema_billing_account_policy_read = _schema_billing_account_policy_read = AAZObjectType() + + billing_account_policy_read = _schema_billing_account_policy_read + billing_account_policy_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_account_policy_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_account_policy_read.properties = AAZObjectType() + billing_account_policy_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_account_policy_read.tags = AAZDictType() + billing_account_policy_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_account_policy_read.properties + properties.enterprise_agreement_policies = AAZObjectType( + serialized_name="enterpriseAgreementPolicies", + ) + properties.marketplace_purchases = AAZStrType( + serialized_name="marketplacePurchases", + ) + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reservation_purchases = AAZStrType( + serialized_name="reservationPurchases", + ) + properties.savings_plan_purchases = AAZStrType( + serialized_name="savingsPlanPurchases", + ) + + enterprise_agreement_policies = _schema_billing_account_policy_read.properties.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrType( + serialized_name="accountOwnerViewCharges", + ) + enterprise_agreement_policies.authentication_type = AAZStrType( + serialized_name="authenticationType", + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrType( + serialized_name="departmentAdminViewCharges", + ) + + policies = _schema_billing_account_policy_read.properties.policies + policies.Element = AAZObjectType() + + _element = _schema_billing_account_policy_read.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = _schema_billing_account_policy_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_account_policy_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_account_policy_read.id + _schema.name = cls._schema_billing_account_policy_read.name + _schema.properties = cls._schema_billing_account_policy_read.properties + _schema.system_data = cls._schema_billing_account_policy_read.system_data + _schema.tags = cls._schema_billing_account_policy_read.tags + _schema.type = cls._schema_billing_account_policy_read.type + + +__all__ = ["UpdateByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_billing_profile.py new file mode 100644 index 00000000000..e75686d7d19 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_billing_profile.py @@ -0,0 +1,553 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy update-by-billing-profile", +) +class UpdateByBillingProfile(AAZCommand): + """Update the policies for a billing profile. This operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/policies/default", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.enterprise_agreement_policies = AAZObjectArg( + options=["--enterprise-agreement-policies"], + arg_group="Properties", + help="The policies for Enterprise Agreement enrollments.", + nullable=True, + ) + _args_schema.invoice_section_label_management = AAZStrArg( + options=["--invoice-section-label-management"], + arg_group="Properties", + help="The policy that controls invoice section label management at invoice section scope. This is allowed by default.", + nullable=True, + enum={"Allowed": "Allowed", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.marketplace_purchases = AAZStrArg( + options=["--marketplace-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure marketplace purchases are allowed.", + nullable=True, + enum={"AllAllowed": "AllAllowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "OnlyFreeAllowed": "OnlyFreeAllowed", "Other": "Other"}, + ) + _args_schema.policies = AAZListArg( + options=["--policies"], + arg_group="Properties", + help="List of all policies defined at the billing scope.", + nullable=True, + ) + _args_schema.reservation_purchases = AAZStrArg( + options=["--reservation-purchases"], + arg_group="Properties", + help="The policy that controls whether Azure reservation purchases are allowed.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.savings_plan_purchases = AAZStrArg( + options=["--savings-plan-purchases"], + arg_group="Properties", + help="The policy that controls whether users with Azure savings plan purchase are allowed.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + _args_schema.view_charges = AAZStrArg( + options=["--view-charges"], + arg_group="Properties", + help="The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices.", + nullable=True, + enum={"Allowed": "Allowed", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + enterprise_agreement_policies = cls._args_schema.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrArg( + options=["account-owner-view-charges"], + help="The policy that controls whether account owner can view charges.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + enterprise_agreement_policies.authentication_type = AAZStrArg( + options=["authentication-type"], + help="The state showing the enrollment auth level.", + nullable=True, + enum={"MicrosoftAccountOnly": "MicrosoftAccountOnly", "MixedAccount": "MixedAccount", "OrganizationalAccountCrossTenant": "OrganizationalAccountCrossTenant", "OrganizationalAccountOnly": "OrganizationalAccountOnly", "Other": "Other"}, + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrArg( + options=["department-admin-view-charges"], + help="The policy that controls whether department admin can view charges.", + nullable=True, + enum={"Allowed": "Allowed", "Disabled": "Disabled", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + policies = cls._args_schema.policies + policies.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.policies.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the policy.", + nullable=True, + ) + _element.policy_type = AAZStrArg( + options=["policy-type"], + help="The type of the policy.", + nullable=True, + enum={"Other": "Other", "SystemControlled": "SystemControlled", "UserControlled": "UserControlled"}, + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope at which the policy is defined.", + nullable=True, + ) + _element.value = AAZStrArg( + options=["value"], + help="The value of the policy.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetByBillingProfile(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.PoliciesCreateOrUpdateByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateByBillingProfileHelper._build_schema_billing_profile_policy_read(cls._schema_on_200) + + return cls._schema_on_200 + + class PoliciesCreateOrUpdateByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateByBillingProfileHelper._build_schema_billing_profile_policy_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("enterpriseAgreementPolicies", AAZObjectType, ".enterprise_agreement_policies") + properties.set_prop("invoiceSectionLabelManagement", AAZStrType, ".invoice_section_label_management") + properties.set_prop("marketplacePurchases", AAZStrType, ".marketplace_purchases") + properties.set_prop("policies", AAZListType, ".policies") + properties.set_prop("reservationPurchases", AAZStrType, ".reservation_purchases") + properties.set_prop("savingsPlanPurchases", AAZStrType, ".savings_plan_purchases") + properties.set_prop("viewCharges", AAZStrType, ".view_charges") + + enterprise_agreement_policies = _builder.get(".properties.enterpriseAgreementPolicies") + if enterprise_agreement_policies is not None: + enterprise_agreement_policies.set_prop("accountOwnerViewCharges", AAZStrType, ".account_owner_view_charges") + enterprise_agreement_policies.set_prop("authenticationType", AAZStrType, ".authentication_type") + enterprise_agreement_policies.set_prop("departmentAdminViewCharges", AAZStrType, ".department_admin_view_charges") + + policies = _builder.get(".properties.policies") + if policies is not None: + policies.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.policies[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("policyType", AAZStrType, ".policy_type") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("value", AAZStrType, ".value") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + +class _UpdateByBillingProfileHelper: + """Helper class for UpdateByBillingProfile""" + + _schema_billing_profile_policy_read = None + + @classmethod + def _build_schema_billing_profile_policy_read(cls, _schema): + if cls._schema_billing_profile_policy_read is not None: + _schema.id = cls._schema_billing_profile_policy_read.id + _schema.name = cls._schema_billing_profile_policy_read.name + _schema.properties = cls._schema_billing_profile_policy_read.properties + _schema.system_data = cls._schema_billing_profile_policy_read.system_data + _schema.tags = cls._schema_billing_profile_policy_read.tags + _schema.type = cls._schema_billing_profile_policy_read.type + return + + cls._schema_billing_profile_policy_read = _schema_billing_profile_policy_read = AAZObjectType() + + billing_profile_policy_read = _schema_billing_profile_policy_read + billing_profile_policy_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_profile_policy_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_profile_policy_read.properties = AAZObjectType() + billing_profile_policy_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_profile_policy_read.tags = AAZDictType() + billing_profile_policy_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_profile_policy_read.properties + properties.enterprise_agreement_policies = AAZObjectType( + serialized_name="enterpriseAgreementPolicies", + ) + properties.invoice_section_label_management = AAZStrType( + serialized_name="invoiceSectionLabelManagement", + ) + properties.marketplace_purchases = AAZStrType( + serialized_name="marketplacePurchases", + ) + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.reservation_purchases = AAZStrType( + serialized_name="reservationPurchases", + ) + properties.savings_plan_purchases = AAZStrType( + serialized_name="savingsPlanPurchases", + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + ) + + enterprise_agreement_policies = _schema_billing_profile_policy_read.properties.enterprise_agreement_policies + enterprise_agreement_policies.account_owner_view_charges = AAZStrType( + serialized_name="accountOwnerViewCharges", + ) + enterprise_agreement_policies.authentication_type = AAZStrType( + serialized_name="authenticationType", + ) + enterprise_agreement_policies.department_admin_view_charges = AAZStrType( + serialized_name="departmentAdminViewCharges", + ) + + policies = _schema_billing_profile_policy_read.properties.policies + policies.Element = AAZObjectType() + + _element = _schema_billing_profile_policy_read.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = _schema_billing_profile_policy_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_profile_policy_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_profile_policy_read.id + _schema.name = cls._schema_billing_profile_policy_read.name + _schema.properties = cls._schema_billing_profile_policy_read.properties + _schema.system_data = cls._schema_billing_profile_policy_read.system_data + _schema.tags = cls._schema_billing_profile_policy_read.tags + _schema.type = cls._schema_billing_profile_policy_read.type + + +__all__ = ["UpdateByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_customer_at_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_customer_at_billing_account.py new file mode 100644 index 00000000000..d816f361698 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/policy/_update_by_customer_at_billing_account.py @@ -0,0 +1,462 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing policy update-by-customer-at-billing-account", +) +class UpdateByCustomerAtBillingAccount(AAZCommand): + """Update the policies for a customer at billing account scope. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers/{}/policies/default", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.policies = AAZListArg( + options=["--policies"], + arg_group="Properties", + help="List of all policies defined at the billing scope.", + nullable=True, + ) + _args_schema.view_charges = AAZStrArg( + options=["--view-charges"], + arg_group="Properties", + help="The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices.", + enum={"Allowed": "Allowed", "NotAllowed": "NotAllowed", "Other": "Other"}, + ) + + policies = cls._args_schema.policies + policies.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.policies.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the policy.", + nullable=True, + ) + _element.policy_type = AAZStrArg( + options=["policy-type"], + help="The type of the policy.", + nullable=True, + enum={"Other": "Other", "SystemControlled": "SystemControlled", "UserControlled": "UserControlled"}, + ) + _element.scope = AAZStrArg( + options=["scope"], + help="The scope at which the policy is defined.", + nullable=True, + ) + _element.value = AAZStrArg( + options=["value"], + help="The value of the policy.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PoliciesGetByCustomerAtBillingAccount(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.PoliciesCreateOrUpdateByCustomerAtBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PoliciesGetByCustomerAtBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateByCustomerAtBillingAccountHelper._build_schema_customer_policy_read(cls._schema_on_200) + + return cls._schema_on_200 + + class PoliciesCreateOrUpdateByCustomerAtBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateByCustomerAtBillingAccountHelper._build_schema_customer_policy_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("policies", AAZListType, ".policies") + properties.set_prop("viewCharges", AAZStrType, ".view_charges", typ_kwargs={"flags": {"required": True}}) + + policies = _builder.get(".properties.policies") + if policies is not None: + policies.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.policies[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("policyType", AAZStrType, ".policy_type") + _elements.set_prop("scope", AAZStrType, ".scope") + _elements.set_prop("value", AAZStrType, ".value") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + +class _UpdateByCustomerAtBillingAccountHelper: + """Helper class for UpdateByCustomerAtBillingAccount""" + + _schema_customer_policy_read = None + + @classmethod + def _build_schema_customer_policy_read(cls, _schema): + if cls._schema_customer_policy_read is not None: + _schema.id = cls._schema_customer_policy_read.id + _schema.name = cls._schema_customer_policy_read.name + _schema.properties = cls._schema_customer_policy_read.properties + _schema.system_data = cls._schema_customer_policy_read.system_data + _schema.tags = cls._schema_customer_policy_read.tags + _schema.type = cls._schema_customer_policy_read.type + return + + cls._schema_customer_policy_read = _schema_customer_policy_read = AAZObjectType() + + customer_policy_read = _schema_customer_policy_read + customer_policy_read.id = AAZStrType( + flags={"read_only": True}, + ) + customer_policy_read.name = AAZStrType( + flags={"read_only": True}, + ) + customer_policy_read.properties = AAZObjectType() + customer_policy_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + customer_policy_read.tags = AAZDictType() + customer_policy_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_customer_policy_read.properties + properties.policies = AAZListType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.view_charges = AAZStrType( + serialized_name="viewCharges", + flags={"required": True}, + ) + + policies = _schema_customer_policy_read.properties.policies + policies.Element = AAZObjectType() + + _element = _schema_customer_policy_read.properties.policies.Element + _element.name = AAZStrType() + _element.policy_type = AAZStrType( + serialized_name="policyType", + ) + _element.scope = AAZStrType() + _element.value = AAZStrType() + + system_data = _schema_customer_policy_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_customer_policy_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_customer_policy_read.id + _schema.name = cls._schema_customer_policy_read.name + _schema.properties = cls._schema_customer_policy_read.properties + _schema.system_data = cls._schema_customer_policy_read.system_data + _schema.tags = cls._schema_customer_policy_read.tags + _schema.type = cls._schema_customer_policy_read.type + + +__all__ = ["UpdateByCustomerAtBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/product/__cmd_group.py new file mode 100644 index 00000000000..bfee3d7d174 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing product", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations ( Get, List, Move, Update) at different scopes around products and is only for customers on MCA and MPA + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/__init__.py b/src/billing/azext_billing/aaz/latest/billing/product/__init__.py new file mode 100644 index 00000000000..3b8ce71ad35 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/__init__.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_customer import * +from ._list_by_invoice_section import * +from ._move import * +from ._update import * +from ._validate_move_eligibility import * diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_get.py b/src/billing/azext_billing/aaz/latest/billing/product/_get.py new file mode 100644 index 00000000000..4f71ee71123 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_get.py @@ -0,0 +1,305 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product get", +) +class Get(AAZCommand): + """Get a product by ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: ProductsGet + az billing product get --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --product-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/products/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.product_name = AAZStrArg( + options=["--product-name"], + help="The ID that uniquely identifies a product.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ProductsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ProductsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "productName", self.ctx.args.product_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.availability_id = AAZStrType( + serialized_name="availabilityId", + flags={"read_only": True}, + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_charge = AAZObjectType( + serialized_name="lastCharge", + ) + properties.last_charge_date = AAZStrType( + serialized_name="lastChargeDate", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType() + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + last_charge = cls._schema_on_200.properties.last_charge + last_charge.currency = AAZStrType( + flags={"read_only": True}, + ) + last_charge.value = AAZFloatType( + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_billing_account.py new file mode 100644 index 00000000000..b89d50fdedb --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_billing_account.py @@ -0,0 +1,349 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List 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. + + :example: ProductsListByBillingAccount + az billing product list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/products", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ProductsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ProductsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.availability_id = AAZStrType( + serialized_name="availabilityId", + flags={"read_only": True}, + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_charge = AAZObjectType( + serialized_name="lastCharge", + ) + properties.last_charge_date = AAZStrType( + serialized_name="lastChargeDate", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType() + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + last_charge = cls._schema_on_200.value.Element.properties.last_charge + last_charge.currency = AAZStrType( + flags={"read_only": True}, + ) + last_charge.value = AAZFloatType( + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_billing_profile.py new file mode 100644 index 00000000000..8dbc2fc3304 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_billing_profile.py @@ -0,0 +1,361 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List 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. + + :example: ProductsListByBillingProfile + az billing product list-by-billing-profile --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --billing-profile-name ea36e548-1505-41db-bebc-46fff3d37998 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/products", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ProductsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ProductsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/products", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.availability_id = AAZStrType( + serialized_name="availabilityId", + flags={"read_only": True}, + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_charge = AAZObjectType( + serialized_name="lastCharge", + ) + properties.last_charge_date = AAZStrType( + serialized_name="lastChargeDate", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType() + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + last_charge = cls._schema_on_200.value.Element.properties.last_charge + last_charge.currency = AAZStrType( + flags={"read_only": True}, + ) + last_charge.value = AAZFloatType( + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_list_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_customer.py new file mode 100644 index 00000000000..2114efad06e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_customer.py @@ -0,0 +1,361 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product list-by-customer", +) +class ListByCustomer(AAZCommand): + """List 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. + + :example: ProductsListByCustomer + az billing product list-by-customer --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --customer-name Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers/{}/products", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ProductsListByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ProductsListByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/products", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.availability_id = AAZStrType( + serialized_name="availabilityId", + flags={"read_only": True}, + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_charge = AAZObjectType( + serialized_name="lastCharge", + ) + properties.last_charge_date = AAZStrType( + serialized_name="lastChargeDate", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType() + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + last_charge = cls._schema_on_200.value.Element.properties.last_charge + last_charge.currency = AAZStrType( + flags={"read_only": True}, + ) + last_charge.value = AAZFloatType( + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerHelper: + """Helper class for ListByCustomer""" + + +__all__ = ["ListByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_list_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_invoice_section.py new file mode 100644 index 00000000000..8fca8f0acdf --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_list_by_invoice_section.py @@ -0,0 +1,373 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product list-by-invoice-section", +) +class ListByInvoiceSection(AAZCommand): + """List 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. + + :example: ProductsListByInvoiceSection + az billing product list-by-invoice-section --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --billing-profile-name ea36e548-1505-41db-bebc-46fff3d37998 --invoice-section-name Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/products", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ProductsListByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ProductsListByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/products", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.availability_id = AAZStrType( + serialized_name="availabilityId", + flags={"read_only": True}, + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_charge = AAZObjectType( + serialized_name="lastCharge", + ) + properties.last_charge_date = AAZStrType( + serialized_name="lastChargeDate", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType() + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + last_charge = cls._schema_on_200.value.Element.properties.last_charge + last_charge.currency = AAZStrType( + flags={"read_only": True}, + ) + last_charge.value = AAZFloatType( + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceSectionHelper: + """Helper class for ListByInvoiceSection""" + + +__all__ = ["ListByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_move.py b/src/billing/azext_billing/aaz/latest/billing/product/_move.py new file mode 100644 index 00000000000..ec4440b59fd --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_move.py @@ -0,0 +1,349 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product move", +) +class Move(AAZCommand): + """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. + + :example: ProductMove + az billing product move --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --product-name 6b96d3f2-9008-4a9d-912f-f87744185aa3 --destination-invoice-section-id /providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/products/{}/move", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.product_name = AAZStrArg( + options=["--product-name"], + help="The ID that uniquely identifies a product.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.destination_invoice_section_id = AAZStrArg( + options=["--destination-invoice-section-id"], + arg_group="Parameters", + help="The destination invoice section id.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ProductsMove(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ProductsMove(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "productName", self.ctx.args.product_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("destinationInvoiceSectionId", AAZStrType, ".destination_invoice_section_id", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.availability_id = AAZStrType( + serialized_name="availabilityId", + flags={"read_only": True}, + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_charge = AAZObjectType( + serialized_name="lastCharge", + ) + properties.last_charge_date = AAZStrType( + serialized_name="lastChargeDate", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType() + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + last_charge = cls._schema_on_200.properties.last_charge + last_charge.currency = AAZStrType( + flags={"read_only": True}, + ) + last_charge.value = AAZFloatType( + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _MoveHelper: + """Helper class for Move""" + + +__all__ = ["Move"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_update.py b/src/billing/azext_billing/aaz/latest/billing/product/_update.py new file mode 100644 index 00000000000..6035394d1ac --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_update.py @@ -0,0 +1,347 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product update", +) +class Update(AAZCommand): + """Update 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. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/products/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.product_name = AAZStrArg( + options=["--product-name"], + help="The ID that uniquely identifies a product.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.auto_renew = AAZStrArg( + options=["--auto-renew"], + arg_group="Properties", + help="Indicates whether auto renewal is turned on or off for a product.", + enum={"Off": "Off", "On": "On"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ProductsUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ProductsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "productName", self.ctx.args.product_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("autoRenew", AAZStrType, ".auto_renew") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.availability_id = AAZStrType( + serialized_name="availabilityId", + flags={"read_only": True}, + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.end_date = AAZStrType( + serialized_name="endDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.last_charge = AAZObjectType( + serialized_name="lastCharge", + ) + properties.last_charge_date = AAZStrType( + serialized_name="lastChargeDate", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType( + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType() + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + last_charge = cls._schema_on_200.properties.last_charge + last_charge.currency = AAZStrType( + flags={"read_only": True}, + ) + last_charge.value = AAZFloatType( + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/product/_validate_move_eligibility.py b/src/billing/azext_billing/aaz/latest/billing/product/_validate_move_eligibility.py new file mode 100644 index 00000000000..908f27f0b93 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/product/_validate_move_eligibility.py @@ -0,0 +1,211 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing product validate-move-eligibility", +) +class ValidateMoveEligibility(AAZCommand): + """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. + + :example: ProductValidateMoveSuccess + az billing product validate-move-eligibility --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --product-name 6b96d3f2-9008-4a9d-912f-f87744185aa3 --destination-invoice-section-id /providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/products/{}/validatemoveeligibility", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.product_name = AAZStrArg( + options=["--product-name"], + help="The ID that uniquely identifies a product.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.destination_invoice_section_id = AAZStrArg( + options=["--destination-invoice-section-id"], + arg_group="Parameters", + help="The destination invoice section id.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ProductsValidateMoveEligibility(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ProductsValidateMoveEligibility(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "productName", self.ctx.args.product_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("destinationInvoiceSectionId", AAZStrType, ".destination_invoice_section_id", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _schema_on_200.is_move_eligible = AAZBoolType( + serialized_name="isMoveEligible", + ) + + error_details = cls._schema_on_200.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.details = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ValidateMoveEligibilityHelper: + """Helper class for ValidateMoveEligibility""" + + +__all__ = ["ValidateMoveEligibility"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/profile/__cmd_group.py new file mode 100644 index 00000000000..51d898499e7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing profile", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations at the billing profile scope like create, delete, list etc. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/__init__.py b/src/billing/azext_billing/aaz/latest/billing/profile/__init__.py new file mode 100644 index 00000000000..0c2ee2ab156 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/__init__.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._get import * +from ._list_by_billing_account import * +from ._update import * +from ._validate_delete_eligibility import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/_create.py b/src/billing/azext_billing/aaz/latest/billing/profile/_create.py new file mode 100644 index 00000000000..0687a5bed2a --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/_create.py @@ -0,0 +1,936 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile create", +) +class Create(AAZCommand): + """Create a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. If you are a MCA Individual (Pay-as-you-go) customer, then please use the Azure portal experience to create the billing profile. + + :example: BillingProfilesCreateOrUpdate + az billing profile create --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --bill-to "{address-line1:'Test Address1',address-line2:'Test Address2',address-line3:'Test Address3',city:City,company-name:Contoso,country:US,email:abc@contoso.com,first-name:Test,last-name:User,phone-number:000-000-0000,postal-code:00000,region:WA,is-valid-address:True}" --display-name Billing Profile 1 --enabled-azure-plans "[{sku-id:0001},{sku-id:0002}]" --invoice-email-opt-in True --po-number ABC12345 --ship-to "{address-line1:'Test Address1',address-line2:'Test Address2',address-line3:'Test Address3',city:City,company-name:Contoso,country:US,email:abc@contoso.com,first-name:Test,last-name:User,phone-number:000-000-0000,postal-code:00000,region:WA,is-valid-address:True}" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.bill_to = AAZObjectArg( + options=["--bill-to"], + arg_group="Properties", + help="Billing address.", + ) + _args_schema.current_payment_term = AAZObjectArg( + options=["--current-payment-term"], + arg_group="Properties", + help="The current payment term of the billing profile.", + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the billing profile.", + ) + _args_schema.enabled_azure_plans = AAZListArg( + options=["--enabled-azure-plans"], + arg_group="Properties", + help="Information about the enabled azure plans.", + ) + _args_schema.indirect_relationship_info = AAZObjectArg( + options=["--indirect-relationship-info"], + arg_group="Properties", + help="Identifies the billing profile that is linked to another billing profile in indirect purchase motion.", + ) + _args_schema.invoice_email_opt_in = AAZBoolArg( + options=["--invoice-email-opt-in"], + arg_group="Properties", + help="Flag controlling whether the invoices for the billing profile are sent through email.", + ) + _args_schema.invoice_recipients = AAZListArg( + options=["--invoice-recipients"], + arg_group="Properties", + help="The list of email addresses to receive invoices by email for the billing profile.", + ) + _args_schema.po_number = AAZStrArg( + options=["--po-number"], + arg_group="Properties", + help="The default purchase order number that will appear on the invoices generated for the billing profile.", + ) + _args_schema.ship_to = AAZObjectArg( + options=["--ship-to"], + arg_group="Properties", + help="The default address where the products are shipped, or the services are being used. If a ship to is not specified for a product or a subscription, then this address will be used.", + ) + _args_schema.sold_to = AAZObjectArg( + options=["--sold-to"], + arg_group="Properties", + help="The address of the individual or organization that is responsible for the billing account.", + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Properties", + help="Dictionary of metadata associated with the resource. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + bill_to = cls._args_schema.bill_to + bill_to.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + bill_to.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + ) + bill_to.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + ) + bill_to.city = AAZStrArg( + options=["city"], + help="Address city.", + ) + bill_to.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + ) + bill_to.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + bill_to.district = AAZStrArg( + options=["district"], + help="Address district.", + ) + bill_to.email = AAZStrArg( + options=["email"], + help="Email address.", + ) + bill_to.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + ) + bill_to.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + ) + bill_to.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + ) + bill_to.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + ) + bill_to.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + ) + bill_to.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + ) + bill_to.region = AAZStrArg( + options=["region"], + help="Address region.", + ) + + current_payment_term = cls._args_schema.current_payment_term + current_payment_term.end_date = AAZDateTimeArg( + options=["end-date"], + help="The date on when the defined 'Payment Term' will end and is always in UTC.", + ) + current_payment_term.start_date = AAZDateTimeArg( + options=["start-date"], + help="The date on when the defined 'Payment Term' will be effective from and is always in UTC.", + ) + current_payment_term.term = AAZStrArg( + options=["term"], + help="Represents duration in netXX format. Always in days.", + ) + + enabled_azure_plans = cls._args_schema.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectArg() + + _element = cls._args_schema.enabled_azure_plans.Element + _element.product_id = AAZStrArg( + options=["product-id"], + help="The ID that uniquely identifies a product.", + ) + _element.sku_description = AAZStrArg( + options=["sku-description"], + help="The sku description.", + ) + _element.sku_id = AAZStrArg( + options=["sku-id"], + help="The ID that uniquely identifies a sku.", + ) + + indirect_relationship_info = cls._args_schema.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrArg( + options=["billing-account-name"], + help="The billing account name of the partner or the customer for an indirect motion.", + ) + indirect_relationship_info.billing_profile_name = AAZStrArg( + options=["billing-profile-name"], + help="The billing profile name of the partner or the customer for an indirect motion.", + ) + indirect_relationship_info.display_name = AAZStrArg( + options=["display-name"], + help="The display name of the partner or customer for an indirect motion.", + ) + + invoice_recipients = cls._args_schema.invoice_recipients + invoice_recipients.Element = AAZStrArg() + + ship_to = cls._args_schema.ship_to + ship_to.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + ship_to.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + ) + ship_to.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + ) + ship_to.city = AAZStrArg( + options=["city"], + help="Address city.", + ) + ship_to.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + ) + ship_to.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + ship_to.district = AAZStrArg( + options=["district"], + help="Address district.", + ) + ship_to.email = AAZStrArg( + options=["email"], + help="Email address.", + ) + ship_to.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + ) + ship_to.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + ) + ship_to.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + ) + ship_to.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + ) + ship_to.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + ) + ship_to.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + ) + ship_to.region = AAZStrArg( + options=["region"], + help="Address region.", + ) + + sold_to = cls._args_schema.sold_to + sold_to.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + sold_to.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + ) + sold_to.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + ) + sold_to.city = AAZStrArg( + options=["city"], + help="Address city.", + ) + sold_to.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + ) + sold_to.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + sold_to.district = AAZStrArg( + options=["district"], + help="Address district.", + ) + sold_to.email = AAZStrArg( + options=["email"], + help="Email address.", + ) + sold_to.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + ) + sold_to.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + ) + sold_to.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + ) + sold_to.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + ) + sold_to.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + ) + sold_to.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + ) + sold_to.region = AAZStrArg( + options=["region"], + help="Address region.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingProfilesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingProfilesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billTo", AAZObjectType, ".bill_to") + properties.set_prop("currentPaymentTerm", AAZObjectType, ".current_payment_term") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("enabledAzurePlans", AAZListType, ".enabled_azure_plans") + properties.set_prop("indirectRelationshipInfo", AAZObjectType, ".indirect_relationship_info") + properties.set_prop("invoiceEmailOptIn", AAZBoolType, ".invoice_email_opt_in") + properties.set_prop("invoiceRecipients", AAZListType, ".invoice_recipients") + properties.set_prop("poNumber", AAZStrType, ".po_number") + properties.set_prop("shipTo", AAZObjectType, ".ship_to") + properties.set_prop("soldTo", AAZObjectType, ".sold_to") + properties.set_prop("tags", AAZDictType, ".tags") + + bill_to = _builder.get(".properties.billTo") + if bill_to is not None: + bill_to.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + bill_to.set_prop("addressLine2", AAZStrType, ".address_line2") + bill_to.set_prop("addressLine3", AAZStrType, ".address_line3") + bill_to.set_prop("city", AAZStrType, ".city") + bill_to.set_prop("companyName", AAZStrType, ".company_name") + bill_to.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + bill_to.set_prop("district", AAZStrType, ".district") + bill_to.set_prop("email", AAZStrType, ".email") + bill_to.set_prop("firstName", AAZStrType, ".first_name") + bill_to.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + bill_to.set_prop("lastName", AAZStrType, ".last_name") + bill_to.set_prop("middleName", AAZStrType, ".middle_name") + bill_to.set_prop("phoneNumber", AAZStrType, ".phone_number") + bill_to.set_prop("postalCode", AAZStrType, ".postal_code") + bill_to.set_prop("region", AAZStrType, ".region") + + current_payment_term = _builder.get(".properties.currentPaymentTerm") + if current_payment_term is not None: + current_payment_term.set_prop("endDate", AAZStrType, ".end_date") + current_payment_term.set_prop("startDate", AAZStrType, ".start_date") + current_payment_term.set_prop("term", AAZStrType, ".term") + + enabled_azure_plans = _builder.get(".properties.enabledAzurePlans") + if enabled_azure_plans is not None: + enabled_azure_plans.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.enabledAzurePlans[]") + if _elements is not None: + _elements.set_prop("productId", AAZStrType, ".product_id") + _elements.set_prop("skuDescription", AAZStrType, ".sku_description") + _elements.set_prop("skuId", AAZStrType, ".sku_id") + + indirect_relationship_info = _builder.get(".properties.indirectRelationshipInfo") + if indirect_relationship_info is not None: + indirect_relationship_info.set_prop("billingAccountName", AAZStrType, ".billing_account_name") + indirect_relationship_info.set_prop("billingProfileName", AAZStrType, ".billing_profile_name") + indirect_relationship_info.set_prop("displayName", AAZStrType, ".display_name") + + invoice_recipients = _builder.get(".properties.invoiceRecipients") + if invoice_recipients is not None: + invoice_recipients.set_elements(AAZStrType, ".") + + ship_to = _builder.get(".properties.shipTo") + if ship_to is not None: + ship_to.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + ship_to.set_prop("addressLine2", AAZStrType, ".address_line2") + ship_to.set_prop("addressLine3", AAZStrType, ".address_line3") + ship_to.set_prop("city", AAZStrType, ".city") + ship_to.set_prop("companyName", AAZStrType, ".company_name") + ship_to.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + ship_to.set_prop("district", AAZStrType, ".district") + ship_to.set_prop("email", AAZStrType, ".email") + ship_to.set_prop("firstName", AAZStrType, ".first_name") + ship_to.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + ship_to.set_prop("lastName", AAZStrType, ".last_name") + ship_to.set_prop("middleName", AAZStrType, ".middle_name") + ship_to.set_prop("phoneNumber", AAZStrType, ".phone_number") + ship_to.set_prop("postalCode", AAZStrType, ".postal_code") + ship_to.set_prop("region", AAZStrType, ".region") + + sold_to = _builder.get(".properties.soldTo") + if sold_to is not None: + sold_to.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + sold_to.set_prop("addressLine2", AAZStrType, ".address_line2") + sold_to.set_prop("addressLine3", AAZStrType, ".address_line3") + sold_to.set_prop("city", AAZStrType, ".city") + sold_to.set_prop("companyName", AAZStrType, ".company_name") + sold_to.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + sold_to.set_prop("district", AAZStrType, ".district") + sold_to.set_prop("email", AAZStrType, ".email") + sold_to.set_prop("firstName", AAZStrType, ".first_name") + sold_to.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + sold_to.set_prop("lastName", AAZStrType, ".last_name") + sold_to.set_prop("middleName", AAZStrType, ".middle_name") + sold_to.set_prop("phoneNumber", AAZStrType, ".phone_number") + sold_to.set_prop("postalCode", AAZStrType, ".postal_code") + sold_to.set_prop("region", AAZStrType, ".region") + + tags = _builder.get(".properties.tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.bill_to = AAZObjectType( + serialized_name="billTo", + ) + properties.billing_relationship_type = AAZStrType( + serialized_name="billingRelationshipType", + flags={"read_only": True}, + ) + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.current_payment_term = AAZObjectType( + serialized_name="currentPaymentTerm", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + flags={"read_only": True}, + ) + properties.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + ) + properties.invoice_recipients = AAZListType( + serialized_name="invoiceRecipients", + ) + properties.other_payment_terms = AAZListType( + serialized_name="otherPaymentTerms", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.ship_to = AAZObjectType( + serialized_name="shipTo", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.spending_limit = AAZStrType( + serialized_name="spendingLimit", + flags={"read_only": True}, + ) + properties.spending_limit_details = AAZListType( + serialized_name="spendingLimitDetails", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_reason_code = AAZStrType( + serialized_name="statusReasonCode", + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_clouds = AAZListType( + serialized_name="targetClouds", + flags={"read_only": True}, + ) + + bill_to = cls._schema_on_200_201.properties.bill_to + bill_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + bill_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + bill_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + bill_to.city = AAZStrType() + bill_to.company_name = AAZStrType( + serialized_name="companyName", + ) + bill_to.country = AAZStrType( + flags={"required": True}, + ) + bill_to.district = AAZStrType() + bill_to.email = AAZStrType() + bill_to.first_name = AAZStrType( + serialized_name="firstName", + ) + bill_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + bill_to.last_name = AAZStrType( + serialized_name="lastName", + ) + bill_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + bill_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + bill_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + bill_to.region = AAZStrType() + + current_payment_term = cls._schema_on_200_201.properties.current_payment_term + current_payment_term.end_date = AAZStrType( + serialized_name="endDate", + ) + current_payment_term.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + current_payment_term.start_date = AAZStrType( + serialized_name="startDate", + ) + current_payment_term.term = AAZStrType() + + enabled_azure_plans = cls._schema_on_200_201.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + indirect_relationship_info = cls._schema_on_200_201.properties.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + invoice_recipients = cls._schema_on_200_201.properties.invoice_recipients + invoice_recipients.Element = AAZStrType() + + other_payment_terms = cls._schema_on_200_201.properties.other_payment_terms + other_payment_terms.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.other_payment_terms.Element + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.term = AAZStrType() + + ship_to = cls._schema_on_200_201.properties.ship_to + ship_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + ship_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + ship_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + ship_to.city = AAZStrType() + ship_to.company_name = AAZStrType( + serialized_name="companyName", + ) + ship_to.country = AAZStrType( + flags={"required": True}, + ) + ship_to.district = AAZStrType() + ship_to.email = AAZStrType() + ship_to.first_name = AAZStrType( + serialized_name="firstName", + ) + ship_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + ship_to.last_name = AAZStrType( + serialized_name="lastName", + ) + ship_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + ship_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + ship_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + ship_to.region = AAZStrType() + + sold_to = cls._schema_on_200_201.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + spending_limit_details = cls._schema_on_200_201.properties.spending_limit_details + spending_limit_details.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.spending_limit_details.Element + _element.amount = AAZFloatType() + _element.currency = AAZStrType() + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.status = AAZStrType() + _element.type = AAZStrType() + + tags = cls._schema_on_200_201.properties.tags + tags.Element = AAZStrType() + + target_clouds = cls._schema_on_200_201.properties.target_clouds + target_clouds.Element = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/_delete.py b/src/billing/azext_billing/aaz/latest/billing/profile/_delete.py new file mode 100644 index 00000000000..9228422bbd8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/_delete.py @@ -0,0 +1,166 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. + + :example: BillingProfilesDelete + az billing profile delete --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingProfilesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingProfilesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/_get.py b/src/billing/azext_billing/aaz/latest/billing/profile/_get.py new file mode 100644 index 00000000000..0fdff4165b5 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/_get.py @@ -0,0 +1,482 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile get", +) +class Get(AAZCommand): + """Get a billing profile by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. + + :example: BillingProfilesGet + az billing profile get --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingProfilesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingProfilesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.bill_to = AAZObjectType( + serialized_name="billTo", + ) + properties.billing_relationship_type = AAZStrType( + serialized_name="billingRelationshipType", + flags={"read_only": True}, + ) + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.current_payment_term = AAZObjectType( + serialized_name="currentPaymentTerm", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + flags={"read_only": True}, + ) + properties.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + ) + properties.invoice_recipients = AAZListType( + serialized_name="invoiceRecipients", + ) + properties.other_payment_terms = AAZListType( + serialized_name="otherPaymentTerms", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.ship_to = AAZObjectType( + serialized_name="shipTo", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.spending_limit = AAZStrType( + serialized_name="spendingLimit", + flags={"read_only": True}, + ) + properties.spending_limit_details = AAZListType( + serialized_name="spendingLimitDetails", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_reason_code = AAZStrType( + serialized_name="statusReasonCode", + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_clouds = AAZListType( + serialized_name="targetClouds", + flags={"read_only": True}, + ) + + bill_to = cls._schema_on_200.properties.bill_to + bill_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + bill_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + bill_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + bill_to.city = AAZStrType() + bill_to.company_name = AAZStrType( + serialized_name="companyName", + ) + bill_to.country = AAZStrType( + flags={"required": True}, + ) + bill_to.district = AAZStrType() + bill_to.email = AAZStrType() + bill_to.first_name = AAZStrType( + serialized_name="firstName", + ) + bill_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + bill_to.last_name = AAZStrType( + serialized_name="lastName", + ) + bill_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + bill_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + bill_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + bill_to.region = AAZStrType() + + current_payment_term = cls._schema_on_200.properties.current_payment_term + current_payment_term.end_date = AAZStrType( + serialized_name="endDate", + ) + current_payment_term.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + current_payment_term.start_date = AAZStrType( + serialized_name="startDate", + ) + current_payment_term.term = AAZStrType() + + enabled_azure_plans = cls._schema_on_200.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + indirect_relationship_info = cls._schema_on_200.properties.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + invoice_recipients = cls._schema_on_200.properties.invoice_recipients + invoice_recipients.Element = AAZStrType() + + other_payment_terms = cls._schema_on_200.properties.other_payment_terms + other_payment_terms.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.other_payment_terms.Element + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.term = AAZStrType() + + ship_to = cls._schema_on_200.properties.ship_to + ship_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + ship_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + ship_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + ship_to.city = AAZStrType() + ship_to.company_name = AAZStrType( + serialized_name="companyName", + ) + ship_to.country = AAZStrType( + flags={"required": True}, + ) + ship_to.district = AAZStrType() + ship_to.email = AAZStrType() + ship_to.first_name = AAZStrType( + serialized_name="firstName", + ) + ship_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + ship_to.last_name = AAZStrType( + serialized_name="lastName", + ) + ship_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + ship_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + ship_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + ship_to.region = AAZStrType() + + sold_to = cls._schema_on_200.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + spending_limit_details = cls._schema_on_200.properties.spending_limit_details + spending_limit_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.spending_limit_details.Element + _element.amount = AAZFloatType() + _element.currency = AAZStrType() + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.status = AAZStrType() + _element.type = AAZStrType() + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + target_clouds = cls._schema_on_200.properties.target_clouds + target_clouds.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/profile/_list_by_billing_account.py new file mode 100644 index 00000000000..0ea2e282333 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/_list_by_billing_account.py @@ -0,0 +1,534 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the billing profiles that a user has access to. The operation is supported for billing accounts with agreement of type Microsoft Customer Agreement and Microsoft Partner Agreement. + + :example: BillingProfilesListByBillingAccount + az billing profile list --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted billing profiles.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingProfilesListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingProfilesListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.bill_to = AAZObjectType( + serialized_name="billTo", + ) + properties.billing_relationship_type = AAZStrType( + serialized_name="billingRelationshipType", + flags={"read_only": True}, + ) + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.current_payment_term = AAZObjectType( + serialized_name="currentPaymentTerm", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + flags={"read_only": True}, + ) + properties.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + ) + properties.invoice_recipients = AAZListType( + serialized_name="invoiceRecipients", + ) + properties.other_payment_terms = AAZListType( + serialized_name="otherPaymentTerms", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.ship_to = AAZObjectType( + serialized_name="shipTo", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.spending_limit = AAZStrType( + serialized_name="spendingLimit", + flags={"read_only": True}, + ) + properties.spending_limit_details = AAZListType( + serialized_name="spendingLimitDetails", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_reason_code = AAZStrType( + serialized_name="statusReasonCode", + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_clouds = AAZListType( + serialized_name="targetClouds", + flags={"read_only": True}, + ) + + bill_to = cls._schema_on_200.value.Element.properties.bill_to + bill_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + bill_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + bill_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + bill_to.city = AAZStrType() + bill_to.company_name = AAZStrType( + serialized_name="companyName", + ) + bill_to.country = AAZStrType( + flags={"required": True}, + ) + bill_to.district = AAZStrType() + bill_to.email = AAZStrType() + bill_to.first_name = AAZStrType( + serialized_name="firstName", + ) + bill_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + bill_to.last_name = AAZStrType( + serialized_name="lastName", + ) + bill_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + bill_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + bill_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + bill_to.region = AAZStrType() + + current_payment_term = cls._schema_on_200.value.Element.properties.current_payment_term + current_payment_term.end_date = AAZStrType( + serialized_name="endDate", + ) + current_payment_term.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + current_payment_term.start_date = AAZStrType( + serialized_name="startDate", + ) + current_payment_term.term = AAZStrType() + + enabled_azure_plans = cls._schema_on_200.value.Element.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + indirect_relationship_info = cls._schema_on_200.value.Element.properties.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + invoice_recipients = cls._schema_on_200.value.Element.properties.invoice_recipients + invoice_recipients.Element = AAZStrType() + + other_payment_terms = cls._schema_on_200.value.Element.properties.other_payment_terms + other_payment_terms.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.other_payment_terms.Element + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.term = AAZStrType() + + ship_to = cls._schema_on_200.value.Element.properties.ship_to + ship_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + ship_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + ship_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + ship_to.city = AAZStrType() + ship_to.company_name = AAZStrType( + serialized_name="companyName", + ) + ship_to.country = AAZStrType( + flags={"required": True}, + ) + ship_to.district = AAZStrType() + ship_to.email = AAZStrType() + ship_to.first_name = AAZStrType( + serialized_name="firstName", + ) + ship_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + ship_to.last_name = AAZStrType( + serialized_name="lastName", + ) + ship_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + ship_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + ship_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + ship_to.region = AAZStrType() + + sold_to = cls._schema_on_200.value.Element.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + spending_limit_details = cls._schema_on_200.value.Element.properties.spending_limit_details + spending_limit_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.spending_limit_details.Element + _element.amount = AAZFloatType() + _element.currency = AAZStrType() + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.status = AAZStrType() + _element.type = AAZStrType() + + tags = cls._schema_on_200.value.Element.properties.tags + tags.Element = AAZStrType() + + target_clouds = cls._schema_on_200.value.Element.properties.target_clouds + target_clouds.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/_update.py b/src/billing/azext_billing/aaz/latest/billing/profile/_update.py new file mode 100644 index 00000000000..ca717d3bb6b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/_update.py @@ -0,0 +1,1130 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile update", +) +class Update(AAZCommand): + """Update a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. If you are a MCA Individual (Pay-as-you-go) customer, then please use the Azure portal experience to create the billing profile. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.bill_to = AAZObjectArg( + options=["--bill-to"], + arg_group="Properties", + help="Billing address.", + nullable=True, + ) + _args_schema.current_payment_term = AAZObjectArg( + options=["--current-payment-term"], + arg_group="Properties", + help="The current payment term of the billing profile.", + nullable=True, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the billing profile.", + nullable=True, + ) + _args_schema.enabled_azure_plans = AAZListArg( + options=["--enabled-azure-plans"], + arg_group="Properties", + help="Information about the enabled azure plans.", + nullable=True, + ) + _args_schema.indirect_relationship_info = AAZObjectArg( + options=["--indirect-relationship-info"], + arg_group="Properties", + help="Identifies the billing profile that is linked to another billing profile in indirect purchase motion.", + nullable=True, + ) + _args_schema.invoice_email_opt_in = AAZBoolArg( + options=["--invoice-email-opt-in"], + arg_group="Properties", + help="Flag controlling whether the invoices for the billing profile are sent through email.", + nullable=True, + ) + _args_schema.invoice_recipients = AAZListArg( + options=["--invoice-recipients"], + arg_group="Properties", + help="The list of email addresses to receive invoices by email for the billing profile.", + nullable=True, + ) + _args_schema.po_number = AAZStrArg( + options=["--po-number"], + arg_group="Properties", + help="The default purchase order number that will appear on the invoices generated for the billing profile.", + nullable=True, + ) + _args_schema.ship_to = AAZObjectArg( + options=["--ship-to"], + arg_group="Properties", + help="The default address where the products are shipped, or the services are being used. If a ship to is not specified for a product or a subscription, then this address will be used.", + nullable=True, + ) + _args_schema.sold_to = AAZObjectArg( + options=["--sold-to"], + arg_group="Properties", + help="The address of the individual or organization that is responsible for the billing account.", + nullable=True, + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Properties", + help="Dictionary of metadata associated with the resource. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + bill_to = cls._args_schema.bill_to + bill_to.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + bill_to.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + nullable=True, + ) + bill_to.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + nullable=True, + ) + bill_to.city = AAZStrArg( + options=["city"], + help="Address city.", + nullable=True, + ) + bill_to.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + nullable=True, + ) + bill_to.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + bill_to.district = AAZStrArg( + options=["district"], + help="Address district.", + nullable=True, + ) + bill_to.email = AAZStrArg( + options=["email"], + help="Email address.", + nullable=True, + ) + bill_to.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + nullable=True, + ) + bill_to.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + nullable=True, + ) + bill_to.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + nullable=True, + ) + bill_to.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + nullable=True, + ) + bill_to.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + nullable=True, + ) + bill_to.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + nullable=True, + ) + bill_to.region = AAZStrArg( + options=["region"], + help="Address region.", + nullable=True, + ) + + current_payment_term = cls._args_schema.current_payment_term + current_payment_term.end_date = AAZDateTimeArg( + options=["end-date"], + help="The date on when the defined 'Payment Term' will end and is always in UTC.", + nullable=True, + ) + current_payment_term.start_date = AAZDateTimeArg( + options=["start-date"], + help="The date on when the defined 'Payment Term' will be effective from and is always in UTC.", + nullable=True, + ) + current_payment_term.term = AAZStrArg( + options=["term"], + help="Represents duration in netXX format. Always in days.", + nullable=True, + ) + + enabled_azure_plans = cls._args_schema.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.enabled_azure_plans.Element + _element.product_id = AAZStrArg( + options=["product-id"], + help="The ID that uniquely identifies a product.", + nullable=True, + ) + _element.sku_description = AAZStrArg( + options=["sku-description"], + help="The sku description.", + nullable=True, + ) + _element.sku_id = AAZStrArg( + options=["sku-id"], + help="The ID that uniquely identifies a sku.", + nullable=True, + ) + + indirect_relationship_info = cls._args_schema.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrArg( + options=["billing-account-name"], + help="The billing account name of the partner or the customer for an indirect motion.", + nullable=True, + ) + indirect_relationship_info.billing_profile_name = AAZStrArg( + options=["billing-profile-name"], + help="The billing profile name of the partner or the customer for an indirect motion.", + nullable=True, + ) + indirect_relationship_info.display_name = AAZStrArg( + options=["display-name"], + help="The display name of the partner or customer for an indirect motion.", + nullable=True, + ) + + invoice_recipients = cls._args_schema.invoice_recipients + invoice_recipients.Element = AAZStrArg( + nullable=True, + ) + + ship_to = cls._args_schema.ship_to + ship_to.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + ship_to.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + nullable=True, + ) + ship_to.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + nullable=True, + ) + ship_to.city = AAZStrArg( + options=["city"], + help="Address city.", + nullable=True, + ) + ship_to.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + nullable=True, + ) + ship_to.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + ship_to.district = AAZStrArg( + options=["district"], + help="Address district.", + nullable=True, + ) + ship_to.email = AAZStrArg( + options=["email"], + help="Email address.", + nullable=True, + ) + ship_to.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + nullable=True, + ) + ship_to.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + nullable=True, + ) + ship_to.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + nullable=True, + ) + ship_to.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + nullable=True, + ) + ship_to.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + nullable=True, + ) + ship_to.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + nullable=True, + ) + ship_to.region = AAZStrArg( + options=["region"], + help="Address region.", + nullable=True, + ) + + sold_to = cls._args_schema.sold_to + sold_to.address_line1 = AAZStrArg( + options=["address-line1"], + help="Address line 1.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + sold_to.address_line2 = AAZStrArg( + options=["address-line2"], + help="Address line 2.", + nullable=True, + ) + sold_to.address_line3 = AAZStrArg( + options=["address-line3"], + help="Address line 3.", + nullable=True, + ) + sold_to.city = AAZStrArg( + options=["city"], + help="Address city.", + nullable=True, + ) + sold_to.company_name = AAZStrArg( + options=["company-name"], + help="Company name. Optional for MCA Individual (Pay-as-you-go).", + nullable=True, + ) + sold_to.country = AAZStrArg( + options=["country"], + help="Country code uses ISO 3166-1 Alpha-2 format.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + sold_to.district = AAZStrArg( + options=["district"], + help="Address district.", + nullable=True, + ) + sold_to.email = AAZStrArg( + options=["email"], + help="Email address.", + nullable=True, + ) + sold_to.first_name = AAZStrArg( + options=["first-name"], + help="First name. Optional for MCA Enterprise.", + nullable=True, + ) + sold_to.is_valid_address = AAZBoolArg( + options=["is-valid-address"], + help="Indicates if the address is incomplete.", + nullable=True, + ) + sold_to.last_name = AAZStrArg( + options=["last-name"], + help="Last name. Optional for MCA Enterprise.", + nullable=True, + ) + sold_to.middle_name = AAZStrArg( + options=["middle-name"], + help="Middle name.", + nullable=True, + ) + sold_to.phone_number = AAZStrArg( + options=["phone-number"], + help="Phone number.", + nullable=True, + ) + sold_to.postal_code = AAZStrArg( + options=["postal-code"], + help="Postal code.", + nullable=True, + ) + sold_to.region = AAZStrArg( + options=["region"], + help="Address region.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingProfilesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.BillingProfilesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingProfilesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_billing_profile_read(cls._schema_on_200) + + return cls._schema_on_200 + + class BillingProfilesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_billing_profile_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("billTo", AAZObjectType, ".bill_to") + properties.set_prop("currentPaymentTerm", AAZObjectType, ".current_payment_term") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("enabledAzurePlans", AAZListType, ".enabled_azure_plans") + properties.set_prop("indirectRelationshipInfo", AAZObjectType, ".indirect_relationship_info") + properties.set_prop("invoiceEmailOptIn", AAZBoolType, ".invoice_email_opt_in") + properties.set_prop("invoiceRecipients", AAZListType, ".invoice_recipients") + properties.set_prop("poNumber", AAZStrType, ".po_number") + properties.set_prop("shipTo", AAZObjectType, ".ship_to") + properties.set_prop("soldTo", AAZObjectType, ".sold_to") + properties.set_prop("tags", AAZDictType, ".tags") + + bill_to = _builder.get(".properties.billTo") + if bill_to is not None: + bill_to.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + bill_to.set_prop("addressLine2", AAZStrType, ".address_line2") + bill_to.set_prop("addressLine3", AAZStrType, ".address_line3") + bill_to.set_prop("city", AAZStrType, ".city") + bill_to.set_prop("companyName", AAZStrType, ".company_name") + bill_to.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + bill_to.set_prop("district", AAZStrType, ".district") + bill_to.set_prop("email", AAZStrType, ".email") + bill_to.set_prop("firstName", AAZStrType, ".first_name") + bill_to.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + bill_to.set_prop("lastName", AAZStrType, ".last_name") + bill_to.set_prop("middleName", AAZStrType, ".middle_name") + bill_to.set_prop("phoneNumber", AAZStrType, ".phone_number") + bill_to.set_prop("postalCode", AAZStrType, ".postal_code") + bill_to.set_prop("region", AAZStrType, ".region") + + current_payment_term = _builder.get(".properties.currentPaymentTerm") + if current_payment_term is not None: + current_payment_term.set_prop("endDate", AAZStrType, ".end_date") + current_payment_term.set_prop("startDate", AAZStrType, ".start_date") + current_payment_term.set_prop("term", AAZStrType, ".term") + + enabled_azure_plans = _builder.get(".properties.enabledAzurePlans") + if enabled_azure_plans is not None: + enabled_azure_plans.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.enabledAzurePlans[]") + if _elements is not None: + _elements.set_prop("productId", AAZStrType, ".product_id") + _elements.set_prop("skuDescription", AAZStrType, ".sku_description") + _elements.set_prop("skuId", AAZStrType, ".sku_id") + + indirect_relationship_info = _builder.get(".properties.indirectRelationshipInfo") + if indirect_relationship_info is not None: + indirect_relationship_info.set_prop("billingAccountName", AAZStrType, ".billing_account_name") + indirect_relationship_info.set_prop("billingProfileName", AAZStrType, ".billing_profile_name") + indirect_relationship_info.set_prop("displayName", AAZStrType, ".display_name") + + invoice_recipients = _builder.get(".properties.invoiceRecipients") + if invoice_recipients is not None: + invoice_recipients.set_elements(AAZStrType, ".") + + ship_to = _builder.get(".properties.shipTo") + if ship_to is not None: + ship_to.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + ship_to.set_prop("addressLine2", AAZStrType, ".address_line2") + ship_to.set_prop("addressLine3", AAZStrType, ".address_line3") + ship_to.set_prop("city", AAZStrType, ".city") + ship_to.set_prop("companyName", AAZStrType, ".company_name") + ship_to.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + ship_to.set_prop("district", AAZStrType, ".district") + ship_to.set_prop("email", AAZStrType, ".email") + ship_to.set_prop("firstName", AAZStrType, ".first_name") + ship_to.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + ship_to.set_prop("lastName", AAZStrType, ".last_name") + ship_to.set_prop("middleName", AAZStrType, ".middle_name") + ship_to.set_prop("phoneNumber", AAZStrType, ".phone_number") + ship_to.set_prop("postalCode", AAZStrType, ".postal_code") + ship_to.set_prop("region", AAZStrType, ".region") + + sold_to = _builder.get(".properties.soldTo") + if sold_to is not None: + sold_to.set_prop("addressLine1", AAZStrType, ".address_line1", typ_kwargs={"flags": {"required": True}}) + sold_to.set_prop("addressLine2", AAZStrType, ".address_line2") + sold_to.set_prop("addressLine3", AAZStrType, ".address_line3") + sold_to.set_prop("city", AAZStrType, ".city") + sold_to.set_prop("companyName", AAZStrType, ".company_name") + sold_to.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}}) + sold_to.set_prop("district", AAZStrType, ".district") + sold_to.set_prop("email", AAZStrType, ".email") + sold_to.set_prop("firstName", AAZStrType, ".first_name") + sold_to.set_prop("isValidAddress", AAZBoolType, ".is_valid_address") + sold_to.set_prop("lastName", AAZStrType, ".last_name") + sold_to.set_prop("middleName", AAZStrType, ".middle_name") + sold_to.set_prop("phoneNumber", AAZStrType, ".phone_number") + sold_to.set_prop("postalCode", AAZStrType, ".postal_code") + sold_to.set_prop("region", AAZStrType, ".region") + + tags = _builder.get(".properties.tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_billing_profile_read = None + + @classmethod + def _build_schema_billing_profile_read(cls, _schema): + if cls._schema_billing_profile_read is not None: + _schema.id = cls._schema_billing_profile_read.id + _schema.name = cls._schema_billing_profile_read.name + _schema.properties = cls._schema_billing_profile_read.properties + _schema.system_data = cls._schema_billing_profile_read.system_data + _schema.tags = cls._schema_billing_profile_read.tags + _schema.type = cls._schema_billing_profile_read.type + return + + cls._schema_billing_profile_read = _schema_billing_profile_read = AAZObjectType() + + billing_profile_read = _schema_billing_profile_read + billing_profile_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_profile_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_profile_read.properties = AAZObjectType() + billing_profile_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_profile_read.tags = AAZDictType() + billing_profile_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_profile_read.properties + properties.bill_to = AAZObjectType( + serialized_name="billTo", + ) + properties.billing_relationship_type = AAZStrType( + serialized_name="billingRelationshipType", + flags={"read_only": True}, + ) + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.current_payment_term = AAZObjectType( + serialized_name="currentPaymentTerm", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + flags={"read_only": True}, + ) + properties.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + ) + properties.invoice_recipients = AAZListType( + serialized_name="invoiceRecipients", + ) + properties.other_payment_terms = AAZListType( + serialized_name="otherPaymentTerms", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.ship_to = AAZObjectType( + serialized_name="shipTo", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.spending_limit = AAZStrType( + serialized_name="spendingLimit", + flags={"read_only": True}, + ) + properties.spending_limit_details = AAZListType( + serialized_name="spendingLimitDetails", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_reason_code = AAZStrType( + serialized_name="statusReasonCode", + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_clouds = AAZListType( + serialized_name="targetClouds", + flags={"read_only": True}, + ) + + bill_to = _schema_billing_profile_read.properties.bill_to + bill_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + bill_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + bill_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + bill_to.city = AAZStrType() + bill_to.company_name = AAZStrType( + serialized_name="companyName", + ) + bill_to.country = AAZStrType( + flags={"required": True}, + ) + bill_to.district = AAZStrType() + bill_to.email = AAZStrType() + bill_to.first_name = AAZStrType( + serialized_name="firstName", + ) + bill_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + bill_to.last_name = AAZStrType( + serialized_name="lastName", + ) + bill_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + bill_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + bill_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + bill_to.region = AAZStrType() + + current_payment_term = _schema_billing_profile_read.properties.current_payment_term + current_payment_term.end_date = AAZStrType( + serialized_name="endDate", + ) + current_payment_term.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + current_payment_term.start_date = AAZStrType( + serialized_name="startDate", + ) + current_payment_term.term = AAZStrType() + + enabled_azure_plans = _schema_billing_profile_read.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = _schema_billing_profile_read.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + indirect_relationship_info = _schema_billing_profile_read.properties.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + invoice_recipients = _schema_billing_profile_read.properties.invoice_recipients + invoice_recipients.Element = AAZStrType() + + other_payment_terms = _schema_billing_profile_read.properties.other_payment_terms + other_payment_terms.Element = AAZObjectType() + + _element = _schema_billing_profile_read.properties.other_payment_terms.Element + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.term = AAZStrType() + + ship_to = _schema_billing_profile_read.properties.ship_to + ship_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + ship_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + ship_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + ship_to.city = AAZStrType() + ship_to.company_name = AAZStrType( + serialized_name="companyName", + ) + ship_to.country = AAZStrType( + flags={"required": True}, + ) + ship_to.district = AAZStrType() + ship_to.email = AAZStrType() + ship_to.first_name = AAZStrType( + serialized_name="firstName", + ) + ship_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + ship_to.last_name = AAZStrType( + serialized_name="lastName", + ) + ship_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + ship_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + ship_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + ship_to.region = AAZStrType() + + sold_to = _schema_billing_profile_read.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + spending_limit_details = _schema_billing_profile_read.properties.spending_limit_details + spending_limit_details.Element = AAZObjectType() + + _element = _schema_billing_profile_read.properties.spending_limit_details.Element + _element.amount = AAZFloatType() + _element.currency = AAZStrType() + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.status = AAZStrType() + _element.type = AAZStrType() + + tags = _schema_billing_profile_read.properties.tags + tags.Element = AAZStrType() + + target_clouds = _schema_billing_profile_read.properties.target_clouds + target_clouds.Element = AAZStrType() + + system_data = _schema_billing_profile_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_profile_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_profile_read.id + _schema.name = cls._schema_billing_profile_read.name + _schema.properties = cls._schema_billing_profile_read.properties + _schema.system_data = cls._schema_billing_profile_read.system_data + _schema.tags = cls._schema_billing_profile_read.tags + _schema.type = cls._schema_billing_profile_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/_validate_delete_eligibility.py b/src/billing/azext_billing/aaz/latest/billing/profile/_validate_delete_eligibility.py new file mode 100644 index 00000000000..2f3e8f946d5 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/_validate_delete_eligibility.py @@ -0,0 +1,180 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile validate-delete-eligibility", +) +class ValidateDeleteEligibility(AAZCommand): + """Validates if the billing profile can be deleted. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. + + :example: BillingProfilesValidateDeleteEligibilitySuccess + az billing profile validate-delete-eligibility --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/validatedeleteeligibility", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingProfilesValidateDeleteEligibility(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingProfilesValidateDeleteEligibility(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/validateDeleteEligibility", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.eligibility_details = AAZListType( + serialized_name="eligibilityDetails", + ) + _schema_on_200.eligibility_status = AAZStrType( + serialized_name="eligibilityStatus", + ) + + eligibility_details = cls._schema_on_200.eligibility_details + eligibility_details.Element = AAZObjectType() + + _element = cls._schema_on_200.eligibility_details.Element + _element.code = AAZStrType() + _element.message = AAZStrType() + + return cls._schema_on_200 + + +class _ValidateDeleteEligibilityHelper: + """Helper class for ValidateDeleteEligibility""" + + +__all__ = ["ValidateDeleteEligibility"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/_wait.py b/src/billing/azext_billing/aaz/latest/billing/profile/_wait.py new file mode 100644 index 00000000000..5a4fb5d202e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/_wait.py @@ -0,0 +1,478 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingProfilesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class BillingProfilesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.bill_to = AAZObjectType( + serialized_name="billTo", + ) + properties.billing_relationship_type = AAZStrType( + serialized_name="billingRelationshipType", + flags={"read_only": True}, + ) + properties.currency = AAZStrType( + flags={"read_only": True}, + ) + properties.current_payment_term = AAZObjectType( + serialized_name="currentPaymentTerm", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enabled_azure_plans = AAZListType( + serialized_name="enabledAzurePlans", + ) + properties.has_read_access = AAZBoolType( + serialized_name="hasReadAccess", + flags={"read_only": True}, + ) + properties.indirect_relationship_info = AAZObjectType( + serialized_name="indirectRelationshipInfo", + ) + properties.invoice_day = AAZIntType( + serialized_name="invoiceDay", + flags={"read_only": True}, + ) + properties.invoice_email_opt_in = AAZBoolType( + serialized_name="invoiceEmailOptIn", + ) + properties.invoice_recipients = AAZListType( + serialized_name="invoiceRecipients", + ) + properties.other_payment_terms = AAZListType( + serialized_name="otherPaymentTerms", + flags={"read_only": True}, + ) + properties.po_number = AAZStrType( + serialized_name="poNumber", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.ship_to = AAZObjectType( + serialized_name="shipTo", + ) + properties.sold_to = AAZObjectType( + serialized_name="soldTo", + ) + properties.spending_limit = AAZStrType( + serialized_name="spendingLimit", + flags={"read_only": True}, + ) + properties.spending_limit_details = AAZListType( + serialized_name="spendingLimitDetails", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_reason_code = AAZStrType( + serialized_name="statusReasonCode", + flags={"read_only": True}, + ) + properties.system_id = AAZStrType( + serialized_name="systemId", + flags={"read_only": True}, + ) + properties.tags = AAZDictType() + properties.target_clouds = AAZListType( + serialized_name="targetClouds", + flags={"read_only": True}, + ) + + bill_to = cls._schema_on_200.properties.bill_to + bill_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + bill_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + bill_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + bill_to.city = AAZStrType() + bill_to.company_name = AAZStrType( + serialized_name="companyName", + ) + bill_to.country = AAZStrType( + flags={"required": True}, + ) + bill_to.district = AAZStrType() + bill_to.email = AAZStrType() + bill_to.first_name = AAZStrType( + serialized_name="firstName", + ) + bill_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + bill_to.last_name = AAZStrType( + serialized_name="lastName", + ) + bill_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + bill_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + bill_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + bill_to.region = AAZStrType() + + current_payment_term = cls._schema_on_200.properties.current_payment_term + current_payment_term.end_date = AAZStrType( + serialized_name="endDate", + ) + current_payment_term.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + current_payment_term.start_date = AAZStrType( + serialized_name="startDate", + ) + current_payment_term.term = AAZStrType() + + enabled_azure_plans = cls._schema_on_200.properties.enabled_azure_plans + enabled_azure_plans.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.enabled_azure_plans.Element + _element.product_id = AAZStrType( + serialized_name="productId", + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + ) + _element.sku_id = AAZStrType( + serialized_name="skuId", + ) + + indirect_relationship_info = cls._schema_on_200.properties.indirect_relationship_info + indirect_relationship_info.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + ) + indirect_relationship_info.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + ) + indirect_relationship_info.display_name = AAZStrType( + serialized_name="displayName", + ) + + invoice_recipients = cls._schema_on_200.properties.invoice_recipients + invoice_recipients.Element = AAZStrType() + + other_payment_terms = cls._schema_on_200.properties.other_payment_terms + other_payment_terms.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.other_payment_terms.Element + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.is_default = AAZBoolType( + serialized_name="isDefault", + flags={"read_only": True}, + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.term = AAZStrType() + + ship_to = cls._schema_on_200.properties.ship_to + ship_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + ship_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + ship_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + ship_to.city = AAZStrType() + ship_to.company_name = AAZStrType( + serialized_name="companyName", + ) + ship_to.country = AAZStrType( + flags={"required": True}, + ) + ship_to.district = AAZStrType() + ship_to.email = AAZStrType() + ship_to.first_name = AAZStrType( + serialized_name="firstName", + ) + ship_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + ship_to.last_name = AAZStrType( + serialized_name="lastName", + ) + ship_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + ship_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + ship_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + ship_to.region = AAZStrType() + + sold_to = cls._schema_on_200.properties.sold_to + sold_to.address_line1 = AAZStrType( + serialized_name="addressLine1", + flags={"required": True}, + ) + sold_to.address_line2 = AAZStrType( + serialized_name="addressLine2", + ) + sold_to.address_line3 = AAZStrType( + serialized_name="addressLine3", + ) + sold_to.city = AAZStrType() + sold_to.company_name = AAZStrType( + serialized_name="companyName", + ) + sold_to.country = AAZStrType( + flags={"required": True}, + ) + sold_to.district = AAZStrType() + sold_to.email = AAZStrType() + sold_to.first_name = AAZStrType( + serialized_name="firstName", + ) + sold_to.is_valid_address = AAZBoolType( + serialized_name="isValidAddress", + ) + sold_to.last_name = AAZStrType( + serialized_name="lastName", + ) + sold_to.middle_name = AAZStrType( + serialized_name="middleName", + ) + sold_to.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + sold_to.postal_code = AAZStrType( + serialized_name="postalCode", + ) + sold_to.region = AAZStrType() + + spending_limit_details = cls._schema_on_200.properties.spending_limit_details + spending_limit_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.spending_limit_details.Element + _element.amount = AAZFloatType() + _element.currency = AAZStrType() + _element.end_date = AAZStrType( + serialized_name="endDate", + ) + _element.start_date = AAZStrType( + serialized_name="startDate", + ) + _element.status = AAZStrType() + _element.type = AAZStrType() + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + target_clouds = cls._schema_on_200.properties.target_clouds + target_clouds.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/reservation/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/profile/reservation/__cmd_group.py new file mode 100644 index 00000000000..aabe92ee807 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/reservation/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing profile reservation", +) +class __CMDGroup(AAZCommandGroup): + """Manage profile reservation + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/reservation/__init__.py b/src/billing/azext_billing/aaz/latest/billing/profile/reservation/__init__.py new file mode 100644 index 00000000000..d63ae5a6fc9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/reservation/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * diff --git a/src/billing/azext_billing/aaz/latest/billing/profile/reservation/_list.py b/src/billing/azext_billing/aaz/latest/billing/profile/reservation/_list.py new file mode 100644 index 00000000000..e001d7728b5 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/profile/reservation/_list.py @@ -0,0 +1,343 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing profile reservation list", +) +class List(AAZCommand): + """List the reservations for a billing profile and the roll up counts of reservations group by provisioning state. + """ + + _aaz_info = { + "version": "2020-05-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/reservations", "2020-05-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support 'ne', 'gt', 'le', 'ge', or 'not'.", + ) + _args_schema.orderby = AAZStrArg( + options=["--orderby"], + help="May be used to sort order by reservation properties.", + ) + _args_schema.refresh_summary = AAZStrArg( + options=["--refresh-summary"], + help="To indicate whether to refresh the roll up counts of the reservations group by provisioning state", + ) + _args_schema.selected_state = AAZStrArg( + options=["--selected-state"], + help="The selected provisioning state", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ReservationsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/reservations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "$orderby", self.ctx.args.orderby, + ), + **self.serialize_query_param( + "refreshSummary", self.ctx.args.refresh_summary, + ), + **self.serialize_query_param( + "selectedState", self.ctx.args.selected_state, + ), + **self.serialize_query_param( + "api-version", "2020-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.summary = AAZObjectType() + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + summary = cls._schema_on_200.summary + summary.cancelled_count = AAZFloatType( + serialized_name="cancelledCount", + flags={"read_only": True}, + ) + summary.expired_count = AAZFloatType( + serialized_name="expiredCount", + flags={"read_only": True}, + ) + summary.expiring_count = AAZFloatType( + serialized_name="expiringCount", + flags={"read_only": True}, + ) + summary.failed_count = AAZFloatType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + summary.pending_count = AAZFloatType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + summary.succeeded_count = AAZFloatType( + serialized_name="succeededCount", + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + utilization = cls._schema_on_200.value.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/__cmd_group.py new file mode 100644 index 00000000000..8c97eed2e35 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing recipient-transfer", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations ( Get, List, Delete) at different scopes around transfer requests + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/__init__.py b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/__init__.py new file mode 100644 index 00000000000..0545aa93951 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._accept import * +from ._decline import * +from ._get import * +from ._list import * +from ._validate import * diff --git a/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_accept.py b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_accept.py new file mode 100644 index 00000000000..62d0640be0b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_accept.py @@ -0,0 +1,337 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing recipient-transfer accept", +) +class Accept(AAZCommand): + """Accepts a transfer request. + + :example: AcceptTransfer + az billing recipient-transfer accept --transfer-name aabb123 --product-details "[{product-type:AzureSubscription,product-id:subscriptionId},{product-type:AzureReservation,product-id:reservedInstanceId}]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers/{}/accept", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.product_details = AAZListArg( + options=["--product-details"], + arg_group="Properties", + help="Request parameters to accept transfer.", + ) + + product_details = cls._args_schema.product_details + product_details.Element = AAZObjectArg() + + _element = cls._args_schema.product_details.Element + _element.product_id = AAZStrArg( + options=["product-id"], + help="The ID of the product that is transferred.", + ) + _element.product_type = AAZStrArg( + options=["product-type"], + help="Type of the product that is transferred.", + enum={"AzureReservation": "AzureReservation", "AzureSubscription": "AzureSubscription", "Department": "Department", "SAAS": "SAAS", "SavingsPlan": "SavingsPlan"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersAccept(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class RecipientTransfersAccept(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers/{transferName}/accept", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("productDetails", AAZListType, ".product_details") + + product_details = _builder.get(".properties.productDetails") + if product_details is not None: + product_details.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.productDetails[]") + if _elements is not None: + _elements.set_prop("productId", AAZStrType, ".product_id") + _elements.set_prop("productType", AAZStrType, ".product_type") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.allowed_product_type = AAZListType( + serialized_name="allowedProductType", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.customer_tenant_id = AAZStrType( + serialized_name="customerTenantId", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.supported_accounts = AAZListType( + serialized_name="supportedAccounts", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + allowed_product_type = cls._schema_on_200.properties.allowed_product_type + allowed_product_type.Element = AAZStrType() + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + supported_accounts = cls._schema_on_200.properties.supported_accounts + supported_accounts.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _AcceptHelper: + """Helper class for Accept""" + + +__all__ = ["Accept"] diff --git a/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_decline.py b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_decline.py new file mode 100644 index 00000000000..98ca4a67688 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_decline.py @@ -0,0 +1,287 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing recipient-transfer decline", +) +class Decline(AAZCommand): + """Declines a transfer request. + + :example: DeclineTransfer + az billing recipient-transfer decline --transfer-name aabb123 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers/{}/decline", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersDecline(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class RecipientTransfersDecline(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers/{transferName}/decline", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.allowed_product_type = AAZListType( + serialized_name="allowedProductType", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.customer_tenant_id = AAZStrType( + serialized_name="customerTenantId", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.supported_accounts = AAZListType( + serialized_name="supportedAccounts", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + allowed_product_type = cls._schema_on_200.properties.allowed_product_type + allowed_product_type.Element = AAZStrType() + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + supported_accounts = cls._schema_on_200.properties.supported_accounts + supported_accounts.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _DeclineHelper: + """Helper class for Decline""" + + +__all__ = ["Decline"] diff --git a/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_get.py b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_get.py new file mode 100644 index 00000000000..4c53c5763f0 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_get.py @@ -0,0 +1,287 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing recipient-transfer get", +) +class Get(AAZCommand): + """Get a transfer request by ID. The caller must be the recipient of the transfer request. + + :example: RecipientTransferGet + az billing recipient-transfer get --transfer-name aabb123 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class RecipientTransfersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.allowed_product_type = AAZListType( + serialized_name="allowedProductType", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.customer_tenant_id = AAZStrType( + serialized_name="customerTenantId", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.supported_accounts = AAZListType( + serialized_name="supportedAccounts", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + allowed_product_type = cls._schema_on_200.properties.allowed_product_type + allowed_product_type.Element = AAZStrType() + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + supported_accounts = cls._schema_on_200.properties.supported_accounts + supported_accounts.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_list.py b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_list.py new file mode 100644 index 00000000000..b0126401b46 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_list.py @@ -0,0 +1,270 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing recipient-transfer list", +) +class List(AAZCommand): + """List the transfer requests received by the caller. + + :example: RecipientTransfersList + az billing recipient-transfer list + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class RecipientTransfersList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.allowed_product_type = AAZListType( + serialized_name="allowedProductType", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.customer_tenant_id = AAZStrType( + serialized_name="customerTenantId", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.supported_accounts = AAZListType( + serialized_name="supportedAccounts", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + allowed_product_type = cls._schema_on_200.value.Element.properties.allowed_product_type + allowed_product_type.Element = AAZStrType() + + detailed_transfer_status = cls._schema_on_200.value.Element.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.value.Element.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + supported_accounts = cls._schema_on_200.value.Element.properties.supported_accounts + supported_accounts.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_validate.py b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_validate.py new file mode 100644 index 00000000000..002fbb81531 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/recipient_transfer/_validate.py @@ -0,0 +1,240 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing recipient-transfer validate", +) +class Validate(AAZCommand): + """Validates if a subscription or a reservation can be transferred. Use this operation to validate your subscriptions or reservation before using the accept transfer operation. + + :example: ValidateTransfer + az billing recipient-transfer validate --transfer-name aabb123 --product-details "[{product-type:AzureSubscription,product-id:subscriptionId},{product-type:AzureReservation,product-id:reservedInstanceId}]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers/{}/validate", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.product_details = AAZListArg( + options=["--product-details"], + arg_group="Properties", + help="Request parameters to accept transfer.", + ) + + product_details = cls._args_schema.product_details + product_details.Element = AAZObjectArg() + + _element = cls._args_schema.product_details.Element + _element.product_id = AAZStrArg( + options=["product-id"], + help="The ID of the product that is transferred.", + ) + _element.product_type = AAZStrArg( + options=["product-type"], + help="Type of the product that is transferred.", + enum={"AzureReservation": "AzureReservation", "AzureSubscription": "AzureSubscription", "Department": "Department", "SAAS": "SAAS", "SavingsPlan": "SavingsPlan"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersValidate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class RecipientTransfersValidate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers/{transferName}/validate", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("productDetails", AAZListType, ".product_details") + + product_details = _builder.get(".properties.productDetails") + if product_details is not None: + product_details.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.productDetails[]") + if _elements is not None: + _elements.set_prop("productId", AAZStrType, ".product_id") + _elements.set_prop("productType", AAZStrType, ".product_type") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + properties.results = AAZListType() + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + results = cls._schema_on_200.value.Element.properties.results + results.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.results.Element + _element.code = AAZStrType( + flags={"read_only": True}, + ) + _element.level = AAZStrType( + flags={"read_only": True}, + ) + _element.message = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ValidateHelper: + """Helper class for Validate""" + + +__all__ = ["Validate"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/request/__cmd_group.py new file mode 100644 index 00000000000..4bea9957d2d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing request", +) +class __CMDGroup(AAZCommandGroup): + """Billing Requests at multiple scopes like Billing Accounts, Billing Profile, Customer etc. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/__init__.py b/src/billing/azext_billing/aaz/latest/billing/request/__init__.py new file mode 100644 index 00000000000..53c996f13e6 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/__init__.py @@ -0,0 +1,20 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._get import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_customer import * +from ._list_by_invoice_section import * +from ._list_by_user import * +from ._update import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_create.py b/src/billing/azext_billing/aaz/latest/billing/request/_create.py new file mode 100644 index 00000000000..27dde7d0606 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_create.py @@ -0,0 +1,558 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request create", +) +class Create(AAZCommand): + """Create a billing request. + + :example: BillingRequestsCreateOrUpdate + az billing request create --billing-request-name 00000000-0000-0000-0000-000000000000 --additional-information "{RoleId:40000000-aaaa-bbbb-cccc-200000000006}" --decision-reason New team member --request-scope /providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx --status Pending --type RoleAssignment + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingrequests/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_request_name = AAZStrArg( + options=["--billing-request-name"], + help="The ID that uniquely identifies a billing request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.additional_information = AAZDictArg( + options=["--additional-information"], + arg_group="Properties", + help="Additional information for the billing request.", + ) + _args_schema.created_by = AAZObjectArg( + options=["--created-by"], + arg_group="Properties", + help="The principal of the entity who created the request.", + ) + _args_schema.decision_reason = AAZStrArg( + options=["--decision-reason"], + arg_group="Properties", + help="The reason to approve or decline the request.", + ) + _args_schema.justification = AAZStrArg( + options=["--justification"], + arg_group="Properties", + help="Justification for submitting request.", + ) + _args_schema.last_updated_by = AAZObjectArg( + options=["--last-updated-by"], + arg_group="Properties", + help="The principal of the entity who last updated the request.", + ) + _args_schema.recipients = AAZListArg( + options=["--recipients"], + arg_group="Properties", + help="The recipients of the billing request.", + ) + _args_schema.request_scope = AAZStrArg( + options=["--request-scope"], + arg_group="Properties", + help="The billing scope for which the request was submitted (ex. '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}').", + ) + _args_schema.reviewed_by = AAZObjectArg( + options=["--reviewed-by"], + arg_group="Properties", + help="The principal of the request reviewer. Will only be set if request is approved.", + ) + _args_schema.status = AAZStrArg( + options=["--status"], + arg_group="Properties", + help="Status of billing request.", + enum={"Approved": "Approved", "Cancelled": "Cancelled", "Completed": "Completed", "Declined": "Declined", "Expired": "Expired", "Other": "Other", "Pending": "Pending"}, + ) + _args_schema.type = AAZStrArg( + options=["--type"], + arg_group="Properties", + help="Type of billing request.", + enum={"InvoiceAccess": "InvoiceAccess", "Other": "Other", "ProvisioningAccess": "ProvisioningAccess", "RoleAssignment": "RoleAssignment", "UpdateBillingPolicy": "UpdateBillingPolicy"}, + ) + + additional_information = cls._args_schema.additional_information + additional_information.Element = AAZStrArg() + + created_by = cls._args_schema.created_by + created_by.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + ) + created_by.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + ) + created_by.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + ) + + last_updated_by = cls._args_schema.last_updated_by + last_updated_by.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + ) + last_updated_by.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + ) + last_updated_by.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + ) + + recipients = cls._args_schema.recipients + recipients.Element = AAZObjectArg() + + _element = cls._args_schema.recipients.Element + _element.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + ) + _element.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + ) + _element.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + ) + + reviewed_by = cls._args_schema.reviewed_by + reviewed_by.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + ) + reviewed_by.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + ) + reviewed_by.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRequestsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRequestsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingRequests/{billingRequestName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingRequestName", self.ctx.args.billing_request_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("additionalInformation", AAZDictType, ".additional_information") + properties.set_prop("createdBy", AAZObjectType, ".created_by") + properties.set_prop("decisionReason", AAZStrType, ".decision_reason") + properties.set_prop("justification", AAZStrType, ".justification") + properties.set_prop("lastUpdatedBy", AAZObjectType, ".last_updated_by") + properties.set_prop("recipients", AAZListType, ".recipients") + properties.set_prop("requestScope", AAZStrType, ".request_scope") + properties.set_prop("reviewedBy", AAZObjectType, ".reviewed_by") + properties.set_prop("status", AAZStrType, ".status") + properties.set_prop("type", AAZStrType, ".type") + + additional_information = _builder.get(".properties.additionalInformation") + if additional_information is not None: + additional_information.set_elements(AAZStrType, ".") + + created_by = _builder.get(".properties.createdBy") + if created_by is not None: + created_by.set_prop("objectId", AAZStrType, ".object_id") + created_by.set_prop("tenantId", AAZStrType, ".tenant_id") + created_by.set_prop("upn", AAZStrType, ".upn") + + last_updated_by = _builder.get(".properties.lastUpdatedBy") + if last_updated_by is not None: + last_updated_by.set_prop("objectId", AAZStrType, ".object_id") + last_updated_by.set_prop("tenantId", AAZStrType, ".tenant_id") + last_updated_by.set_prop("upn", AAZStrType, ".upn") + + recipients = _builder.get(".properties.recipients") + if recipients is not None: + recipients.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.recipients[]") + if _elements is not None: + _elements.set_prop("objectId", AAZStrType, ".object_id") + _elements.set_prop("tenantId", AAZStrType, ".tenant_id") + _elements.set_prop("upn", AAZStrType, ".upn") + + reviewed_by = _builder.get(".properties.reviewedBy") + if reviewed_by is not None: + reviewed_by.set_prop("objectId", AAZStrType, ".object_id") + reviewed_by.set_prop("tenantId", AAZStrType, ".tenant_id") + reviewed_by.set_prop("upn", AAZStrType, ".upn") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200_201.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200_201.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200_201.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200_201.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200_201.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_get.py b/src/billing/azext_billing/aaz/latest/billing/request/_get.py new file mode 100644 index 00000000000..ea2ebe883ed --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_get.py @@ -0,0 +1,347 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request get", +) +class Get(AAZCommand): + """Get a billing request by its ID. + + :example: BillingRequestsGet + az billing request get --billing-request-name 00000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingrequests/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_request_name = AAZStrArg( + options=["--billing-request-name"], + help="The ID that uniquely identifies a billing request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRequestsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingRequests/{billingRequestName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingRequestName", self.ctx.args.billing_request_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_billing_account.py new file mode 100644 index 00000000000..f40194d5471 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_billing_account.py @@ -0,0 +1,403 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List list of billing requests submitted for the billing account. + + :example: BillingRequestsListByBillingAccount + az billing request list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingrequests", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRequestsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRequests", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200.value.Element.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200.value.Element.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200.value.Element.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200.value.Element.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200.value.Element.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_billing_profile.py new file mode 100644 index 00000000000..f259b2244e3 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_billing_profile.py @@ -0,0 +1,415 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List list of billing requests submitted for the billing profile. + + :example: BillingRequestsListByBillingProfile + az billing request list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingrequests", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRequestsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRequests", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200.value.Element.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200.value.Element.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200.value.Element.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200.value.Element.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200.value.Element.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_list_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_customer.py new file mode 100644 index 00000000000..5e048937620 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_customer.py @@ -0,0 +1,427 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request list-by-customer", +) +class ListByCustomer(AAZCommand): + """List list of billing requests submitted for the customer. + + :example: BillingRequestsListByCustomer + az billing request list-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingrequests", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsListByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRequestsListByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRequests", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200.value.Element.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200.value.Element.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200.value.Element.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200.value.Element.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200.value.Element.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerHelper: + """Helper class for ListByCustomer""" + + +__all__ = ["ListByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_list_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_invoice_section.py new file mode 100644 index 00000000000..474143e55ab --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_invoice_section.py @@ -0,0 +1,427 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request list-by-invoice-section", +) +class ListByInvoiceSection(AAZCommand): + """List list of billing requests submitted for the invoice section. + + :example: BillingRequestsListByInvoiceSection + az billing request list-by-invoice-section --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingrequests", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsListByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRequestsListByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRequests", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200.value.Element.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200.value.Element.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200.value.Element.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200.value.Element.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200.value.Element.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceSectionHelper: + """Helper class for ListByInvoiceSection""" + + +__all__ = ["ListByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_list_by_user.py b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_user.py new file mode 100644 index 00000000000..41cea8ab5ab --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_list_by_user.py @@ -0,0 +1,385 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request list-by-user", +) +class ListByUser(AAZCommand): + """List list of billing requests submitted by a user. + + :example: BillingRequestsListByUser + az billing request list-by-user + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingrequests", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsListByUser(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRequestsListByUser(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingRequests", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200.value.Element.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200.value.Element.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200.value.Element.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200.value.Element.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200.value.Element.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByUserHelper: + """Helper class for ListByUser""" + + +__all__ = ["ListByUser"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_update.py b/src/billing/azext_billing/aaz/latest/billing/request/_update.py new file mode 100644 index 00000000000..b75f7de322d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_update.py @@ -0,0 +1,718 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request update", +) +class Update(AAZCommand): + """Update a billing request. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingrequests/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_request_name = AAZStrArg( + options=["--billing-request-name"], + help="The ID that uniquely identifies a billing request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.additional_information = AAZDictArg( + options=["--additional-information"], + arg_group="Properties", + help="Additional information for the billing request.", + nullable=True, + ) + _args_schema.created_by = AAZObjectArg( + options=["--created-by"], + arg_group="Properties", + help="The principal of the entity who created the request.", + nullable=True, + ) + _args_schema.decision_reason = AAZStrArg( + options=["--decision-reason"], + arg_group="Properties", + help="The reason to approve or decline the request.", + nullable=True, + ) + _args_schema.justification = AAZStrArg( + options=["--justification"], + arg_group="Properties", + help="Justification for submitting request.", + nullable=True, + ) + _args_schema.last_updated_by = AAZObjectArg( + options=["--last-updated-by"], + arg_group="Properties", + help="The principal of the entity who last updated the request.", + nullable=True, + ) + _args_schema.recipients = AAZListArg( + options=["--recipients"], + arg_group="Properties", + help="The recipients of the billing request.", + nullable=True, + ) + _args_schema.request_scope = AAZStrArg( + options=["--request-scope"], + arg_group="Properties", + help="The billing scope for which the request was submitted (ex. '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}').", + nullable=True, + ) + _args_schema.reviewed_by = AAZObjectArg( + options=["--reviewed-by"], + arg_group="Properties", + help="The principal of the request reviewer. Will only be set if request is approved.", + nullable=True, + ) + _args_schema.status = AAZStrArg( + options=["--status"], + arg_group="Properties", + help="Status of billing request.", + nullable=True, + enum={"Approved": "Approved", "Cancelled": "Cancelled", "Completed": "Completed", "Declined": "Declined", "Expired": "Expired", "Other": "Other", "Pending": "Pending"}, + ) + _args_schema.type = AAZStrArg( + options=["--type"], + arg_group="Properties", + help="Type of billing request.", + nullable=True, + enum={"InvoiceAccess": "InvoiceAccess", "Other": "Other", "ProvisioningAccess": "ProvisioningAccess", "RoleAssignment": "RoleAssignment", "UpdateBillingPolicy": "UpdateBillingPolicy"}, + ) + + additional_information = cls._args_schema.additional_information + additional_information.Element = AAZStrArg( + nullable=True, + ) + + created_by = cls._args_schema.created_by + created_by.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + nullable=True, + ) + created_by.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + nullable=True, + ) + created_by.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + nullable=True, + ) + + last_updated_by = cls._args_schema.last_updated_by + last_updated_by.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + nullable=True, + ) + last_updated_by.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + nullable=True, + ) + last_updated_by.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + nullable=True, + ) + + recipients = cls._args_schema.recipients + recipients.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.recipients.Element + _element.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + nullable=True, + ) + _element.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + nullable=True, + ) + _element.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + nullable=True, + ) + + reviewed_by = cls._args_schema.reviewed_by + reviewed_by.object_id = AAZStrArg( + options=["object-id"], + help="The object id of the principal who has interacted with a billing entity.", + nullable=True, + ) + reviewed_by.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The tenant id of the principal who has interacted with a billing entity.", + nullable=True, + ) + reviewed_by.upn = AAZStrArg( + options=["upn"], + help="The user principal name of the principal who has interacted with a billing entity.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.BillingRequestsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRequestsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingRequests/{billingRequestName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingRequestName", self.ctx.args.billing_request_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_billing_request_read(cls._schema_on_200) + + return cls._schema_on_200 + + class BillingRequestsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingRequests/{billingRequestName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingRequestName", self.ctx.args.billing_request_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_billing_request_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("additionalInformation", AAZDictType, ".additional_information") + properties.set_prop("createdBy", AAZObjectType, ".created_by") + properties.set_prop("decisionReason", AAZStrType, ".decision_reason") + properties.set_prop("justification", AAZStrType, ".justification") + properties.set_prop("lastUpdatedBy", AAZObjectType, ".last_updated_by") + properties.set_prop("recipients", AAZListType, ".recipients") + properties.set_prop("requestScope", AAZStrType, ".request_scope") + properties.set_prop("reviewedBy", AAZObjectType, ".reviewed_by") + properties.set_prop("status", AAZStrType, ".status") + properties.set_prop("type", AAZStrType, ".type") + + additional_information = _builder.get(".properties.additionalInformation") + if additional_information is not None: + additional_information.set_elements(AAZStrType, ".") + + created_by = _builder.get(".properties.createdBy") + if created_by is not None: + created_by.set_prop("objectId", AAZStrType, ".object_id") + created_by.set_prop("tenantId", AAZStrType, ".tenant_id") + created_by.set_prop("upn", AAZStrType, ".upn") + + last_updated_by = _builder.get(".properties.lastUpdatedBy") + if last_updated_by is not None: + last_updated_by.set_prop("objectId", AAZStrType, ".object_id") + last_updated_by.set_prop("tenantId", AAZStrType, ".tenant_id") + last_updated_by.set_prop("upn", AAZStrType, ".upn") + + recipients = _builder.get(".properties.recipients") + if recipients is not None: + recipients.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.recipients[]") + if _elements is not None: + _elements.set_prop("objectId", AAZStrType, ".object_id") + _elements.set_prop("tenantId", AAZStrType, ".tenant_id") + _elements.set_prop("upn", AAZStrType, ".upn") + + reviewed_by = _builder.get(".properties.reviewedBy") + if reviewed_by is not None: + reviewed_by.set_prop("objectId", AAZStrType, ".object_id") + reviewed_by.set_prop("tenantId", AAZStrType, ".tenant_id") + reviewed_by.set_prop("upn", AAZStrType, ".upn") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_billing_request_read = None + + @classmethod + def _build_schema_billing_request_read(cls, _schema): + if cls._schema_billing_request_read is not None: + _schema.id = cls._schema_billing_request_read.id + _schema.name = cls._schema_billing_request_read.name + _schema.properties = cls._schema_billing_request_read.properties + _schema.system_data = cls._schema_billing_request_read.system_data + _schema.tags = cls._schema_billing_request_read.tags + _schema.type = cls._schema_billing_request_read.type + return + + cls._schema_billing_request_read = _schema_billing_request_read = AAZObjectType() + + billing_request_read = _schema_billing_request_read + billing_request_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_request_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_request_read.properties = AAZObjectType() + billing_request_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_request_read.tags = AAZDictType() + billing_request_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_request_read.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = _schema_billing_request_read.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = _schema_billing_request_read.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = _schema_billing_request_read.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = _schema_billing_request_read.properties.recipients + recipients.Element = AAZObjectType() + + _element = _schema_billing_request_read.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = _schema_billing_request_read.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = _schema_billing_request_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_request_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_request_read.id + _schema.name = cls._schema_billing_request_read.name + _schema.properties = cls._schema_billing_request_read.properties + _schema.system_data = cls._schema_billing_request_read.system_data + _schema.tags = cls._schema_billing_request_read.tags + _schema.type = cls._schema_billing_request_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/request/_wait.py b/src/billing/azext_billing/aaz/latest/billing/request/_wait.py new file mode 100644 index 00000000000..9c5ee30c2e6 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/request/_wait.py @@ -0,0 +1,343 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing request wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingrequests/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_request_name = AAZStrArg( + options=["--billing-request-name"], + help="The ID that uniquely identifies a billing request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRequestsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class BillingRequestsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingRequests/{billingRequestName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingRequestName", self.ctx.args.billing_request_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.additional_information = AAZDictType( + serialized_name="additionalInformation", + ) + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_account_name = AAZStrType( + serialized_name="billingAccountName", + flags={"read_only": True}, + ) + properties.billing_account_primary_billing_tenant_id = AAZStrType( + serialized_name="billingAccountPrimaryBillingTenantId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.billing_scope = AAZStrType( + serialized_name="billingScope", + flags={"read_only": True}, + ) + properties.created_by = AAZObjectType( + serialized_name="createdBy", + ) + properties.creation_date = AAZStrType( + serialized_name="creationDate", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.decision_reason = AAZStrType( + serialized_name="decisionReason", + ) + properties.expiration_date = AAZStrType( + serialized_name="expirationDate", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.justification = AAZStrType() + properties.last_updated_by = AAZObjectType( + serialized_name="lastUpdatedBy", + ) + properties.last_updated_date = AAZStrType( + serialized_name="lastUpdatedDate", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.recipients = AAZListType() + properties.request_scope = AAZStrType( + serialized_name="requestScope", + ) + properties.reviewal_date = AAZStrType( + serialized_name="reviewalDate", + flags={"read_only": True}, + ) + properties.reviewed_by = AAZObjectType( + serialized_name="reviewedBy", + ) + properties.status = AAZStrType() + properties.subscription_display_name = AAZStrType( + serialized_name="subscriptionDisplayName", + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.subscription_name = AAZStrType( + serialized_name="subscriptionName", + flags={"read_only": True}, + ) + properties.type = AAZStrType() + + additional_information = cls._schema_on_200.properties.additional_information + additional_information.Element = AAZStrType() + + created_by = cls._schema_on_200.properties.created_by + created_by.object_id = AAZStrType( + serialized_name="objectId", + ) + created_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + created_by.upn = AAZStrType() + + last_updated_by = cls._schema_on_200.properties.last_updated_by + last_updated_by.object_id = AAZStrType( + serialized_name="objectId", + ) + last_updated_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + last_updated_by.upn = AAZStrType() + + recipients = cls._schema_on_200.properties.recipients + recipients.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.recipients.Element + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.upn = AAZStrType() + + reviewed_by = cls._schema_on_200.properties.reviewed_by + reviewed_by.object_id = AAZStrType( + serialized_name="objectId", + ) + reviewed_by.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + reviewed_by.upn = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/reservation/__cmd_group.py new file mode 100644 index 00000000000..4b896f7d7df --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing reservation", +) +class __CMDGroup(AAZCommandGroup): + """Get, List and Update operations around Reservations at different scopes + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/__init__.py b/src/billing/azext_billing/aaz/latest/billing/reservation/__init__.py new file mode 100644 index 00000000000..43ec5c1f53b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/__init__.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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_by_reservation_order import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_reservation_order import * +from ._update_by_billing_account import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/_get_by_reservation_order.py b/src/billing/azext_billing/aaz/latest/billing/reservation/_get_by_reservation_order.py new file mode 100644 index 00000000000..f10a9f8d389 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/_get_by_reservation_order.py @@ -0,0 +1,547 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation get-by-reservation-order", +) +class GetByReservationOrder(AAZCommand): + """Get specific Reservation details in the billing account. + + :example: reservationGetByBillingAccount + az billing reservation get-by-reservation-order --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --reservation-order-id 20000000-0000-0000-0000-000000000000 --reservation-id 30000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservationorders/{}/reservations/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.reservation_id = AAZStrArg( + options=["--reservation-id"], + help="Id of the reservation item", + required=True, + ) + _args_schema.reservation_order_id = AAZStrArg( + options=["--reservation-order-id"], + help="Order Id of the reservation", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the detail information of some properties.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationsGetByReservationOrder(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ReservationsGetByReservationOrder(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations/{reservationId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "reservationId", self.ctx.args.reservation_id, + required=True, + ), + **self.serialize_url_param( + "reservationOrderId", self.ctx.args.reservation_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZIntType() + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _GetByReservationOrderHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType() + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + merge_properties = cls._schema_on_200.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _GetByReservationOrderHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _GetByReservationOrderHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _GetByReservationOrderHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByReservationOrderHelper: + """Helper class for GetByReservationOrder""" + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + +__all__ = ["GetByReservationOrder"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_billing_account.py new file mode 100644 index 00000000000..7d24cb1b00d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_billing_account.py @@ -0,0 +1,617 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the reservations for a billing account and the roll up counts of reservations group by provisioning states. + + :example: reservationsListByBillingAccount + az billing reservation list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --selected-state Succeeded + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservations", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support 'ne', 'gt', 'le', 'ge', or 'not'.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.refresh_summary = AAZStrArg( + options=["--refresh-summary"], + help="To indicate whether to refresh the roll up counts of the reservations group by provisioning states", + ) + _args_schema.selected_state = AAZStrArg( + options=["--selected-state"], + help="The selected provisioning state", + ) + _args_schema.skiptoken = AAZFloatArg( + options=["--skiptoken"], + help="The number of reservations to skip from the list before returning results", + ) + _args_schema.take = AAZFloatArg( + options=["--take"], + help="The number of reservations to return in API response.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ReservationsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "refreshSummary", self.ctx.args.refresh_summary, + ), + **self.serialize_query_param( + "selectedState", self.ctx.args.selected_state, + ), + **self.serialize_query_param( + "skiptoken", self.ctx.args.skiptoken, + ), + **self.serialize_query_param( + "take", self.ctx.args.take, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.summary = AAZObjectType() + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + summary = cls._schema_on_200.summary + summary.cancelled_count = AAZFloatType( + serialized_name="cancelledCount", + flags={"read_only": True}, + ) + summary.expired_count = AAZFloatType( + serialized_name="expiredCount", + flags={"read_only": True}, + ) + summary.expiring_count = AAZFloatType( + serialized_name="expiringCount", + flags={"read_only": True}, + ) + summary.failed_count = AAZFloatType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + summary.no_benefit_count = AAZFloatType( + serialized_name="noBenefitCount", + flags={"read_only": True}, + ) + summary.pending_count = AAZFloatType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + summary.processing_count = AAZFloatType( + serialized_name="processingCount", + flags={"read_only": True}, + ) + summary.succeeded_count = AAZFloatType( + serialized_name="succeededCount", + flags={"read_only": True}, + ) + summary.warning_count = AAZFloatType( + serialized_name="warningCount", + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZIntType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.value.Element.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType() + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.value.Element.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + merge_properties = cls._schema_on_200.value.Element.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.value.Element.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.value.Element.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.value.Element.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.value.Element.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.value.Element.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.value.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_billing_profile.py new file mode 100644 index 00000000000..ce670c0d7de --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_billing_profile.py @@ -0,0 +1,629 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List the reservations for a billing profile and the roll up counts of reservations group by provisioning state. + + :example: ReservationsListByBillingProfile + az billing reservation list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name AAAA-AAAA-AAA-AAA --selected-state Succeeded + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/reservations", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support 'ne', 'gt', 'le', 'ge', or 'not'.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.refresh_summary = AAZStrArg( + options=["--refresh-summary"], + help="To indicate whether to refresh the roll up counts of the reservations group by provisioning state", + ) + _args_schema.selected_state = AAZStrArg( + options=["--selected-state"], + help="The selected provisioning state", + ) + _args_schema.skiptoken = AAZFloatArg( + options=["--skiptoken"], + help="The number of reservations to skip from the list before returning results", + ) + _args_schema.take = AAZFloatArg( + options=["--take"], + help="The number of reservations to return in API response.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ReservationsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/reservations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "refreshSummary", self.ctx.args.refresh_summary, + ), + **self.serialize_query_param( + "selectedState", self.ctx.args.selected_state, + ), + **self.serialize_query_param( + "skiptoken", self.ctx.args.skiptoken, + ), + **self.serialize_query_param( + "take", self.ctx.args.take, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.summary = AAZObjectType() + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + summary = cls._schema_on_200.summary + summary.cancelled_count = AAZFloatType( + serialized_name="cancelledCount", + flags={"read_only": True}, + ) + summary.expired_count = AAZFloatType( + serialized_name="expiredCount", + flags={"read_only": True}, + ) + summary.expiring_count = AAZFloatType( + serialized_name="expiringCount", + flags={"read_only": True}, + ) + summary.failed_count = AAZFloatType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + summary.no_benefit_count = AAZFloatType( + serialized_name="noBenefitCount", + flags={"read_only": True}, + ) + summary.pending_count = AAZFloatType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + summary.processing_count = AAZFloatType( + serialized_name="processingCount", + flags={"read_only": True}, + ) + summary.succeeded_count = AAZFloatType( + serialized_name="succeededCount", + flags={"read_only": True}, + ) + summary.warning_count = AAZFloatType( + serialized_name="warningCount", + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZIntType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingProfileHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.value.Element.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType() + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.value.Element.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + merge_properties = cls._schema_on_200.value.Element.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.value.Element.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.value.Element.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _ListByBillingProfileHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByBillingProfileHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingProfileHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.value.Element.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.value.Element.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.value.Element.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.value.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_reservation_order.py b/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_reservation_order.py new file mode 100644 index 00000000000..38dd82c9c66 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/_list_by_reservation_order.py @@ -0,0 +1,542 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation list-by-reservation-order", +) +class ListByReservationOrder(AAZCommand): + """List Reservations within a single ReservationOrder in the billing account. + + :example: reservationsGetFromOrderByBillingAccount + az billing reservation list-by-reservation-order --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --reservation-order-id 20000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservationorders/{}/reservations", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.reservation_order_id = AAZStrArg( + options=["--reservation-order-id"], + help="Order Id of the reservation", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationsListByReservationOrder(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ReservationsListByReservationOrder(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "reservationOrderId", self.ctx.args.reservation_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZIntType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByReservationOrderHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.value.Element.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType() + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.value.Element.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + merge_properties = cls._schema_on_200.value.Element.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.value.Element.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.value.Element.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _ListByReservationOrderHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByReservationOrderHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByReservationOrderHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.value.Element.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.value.Element.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.value.Element.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.value.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByReservationOrderHelper: + """Helper class for ListByReservationOrder""" + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + +__all__ = ["ListByReservationOrder"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/_update_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/reservation/_update_by_billing_account.py new file mode 100644 index 00000000000..019cf405a12 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/_update_by_billing_account.py @@ -0,0 +1,781 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation update-by-billing-account", +) +class UpdateByBillingAccount(AAZCommand): + """Update reservation by billing account. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservationorders/{}/reservations/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.reservation_id = AAZStrArg( + options=["--reservation-id"], + help="Id of the reservation item", + required=True, + ) + _args_schema.reservation_order_id = AAZStrArg( + options=["--reservation-order-id"], + help="Order Id of the reservation", + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Body", + help="Tags for this reservation", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.applied_scope_properties = AAZObjectArg( + options=["--applied-scope-properties"], + arg_group="Properties", + help="Properties specific to applied scope type. Not required if not applicable. Required and need to provide tenantId and managementGroupId if AppliedScopeType is ManagementGroup", + ) + cls._build_args_reservation_applied_scope_properties_update(_args_schema.applied_scope_properties) + _args_schema.applied_scope_type = AAZStrArg( + options=["--applied-scope-type"], + arg_group="Properties", + help="Type of the Applied Scope.", + enum={"ManagementGroup": "ManagementGroup", "Shared": "Shared", "Single": "Single"}, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="Display name of the reservation", + ) + _args_schema.instance_flexibility = AAZStrArg( + options=["--instance-flexibility"], + arg_group="Properties", + help="Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.", + enum={"Off": "Off", "On": "On"}, + ) + _args_schema.renew = AAZBoolArg( + options=["--renew"], + arg_group="Properties", + help="Setting this to true will automatically purchase a new reservation on the expiration date time.", + default=False, + ) + _args_schema.review_date_time = AAZDateTimeArg( + options=["--review-date-time"], + arg_group="Properties", + help="This is the date-time when the Azure hybrid benefit needs to be reviewed.", + ) + + # define Arg Group "RenewProperties" + + _args_schema = cls._args_schema + _args_schema.purchase_properties = AAZObjectArg( + options=["--purchase-properties"], + arg_group="RenewProperties", + help="The request for reservation purchase", + ) + + purchase_properties = cls._args_schema.purchase_properties + purchase_properties.applied_scope_properties = AAZObjectArg( + options=["applied-scope-properties"], + ) + cls._build_args_reservation_applied_scope_properties_update(purchase_properties.applied_scope_properties) + purchase_properties.applied_scope_type = AAZStrArg( + options=["applied-scope-type"], + help="Type of the Applied Scope.", + enum={"ManagementGroup": "ManagementGroup", "Shared": "Shared", "Single": "Single"}, + ) + purchase_properties.applied_scopes = AAZListArg( + options=["applied-scopes"], + help="List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared.", + ) + purchase_properties.billing_plan = AAZStrArg( + options=["billing-plan"], + help="Represent the billing plans.", + enum={"Monthly": "Monthly", "Upfront": "Upfront"}, + ) + purchase_properties.display_name = AAZStrArg( + options=["display-name"], + help="Friendly name of the reservation", + ) + purchase_properties.quantity = AAZIntArg( + options=["quantity"], + help="Quantity of the skus that are part of the reservation. Must be greater than zero.", + ) + purchase_properties.renew = AAZBoolArg( + options=["renew"], + help="Setting this to true will automatically purchase a new reservation on the expiration date time.", + default=False, + ) + purchase_properties.instance_flexibility = AAZStrArg( + options=["instance-flexibility"], + help="Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.", + enum={"Off": "Off", "On": "On"}, + ) + purchase_properties.review_date_time = AAZDateTimeArg( + options=["review-date-time"], + help="This is the date-time when the Azure hybrid benefit needs to be reviewed.", + ) + purchase_properties.sku = AAZObjectArg( + options=["sku"], + help="The name of sku", + ) + + applied_scopes = cls._args_schema.purchase_properties.applied_scopes + applied_scopes.Element = AAZStrArg() + + sku = cls._args_schema.purchase_properties.sku + sku.name = AAZStrArg( + options=["name"], + ) + return cls._args_schema + + _args_reservation_applied_scope_properties_update = None + + @classmethod + def _build_args_reservation_applied_scope_properties_update(cls, _schema): + if cls._args_reservation_applied_scope_properties_update is not None: + _schema.display_name = cls._args_reservation_applied_scope_properties_update.display_name + _schema.management_group_id = cls._args_reservation_applied_scope_properties_update.management_group_id + _schema.resource_group_id = cls._args_reservation_applied_scope_properties_update.resource_group_id + _schema.subscription_id = cls._args_reservation_applied_scope_properties_update.subscription_id + _schema.tenant_id = cls._args_reservation_applied_scope_properties_update.tenant_id + return + + cls._args_reservation_applied_scope_properties_update = AAZObjectArg() + + reservation_applied_scope_properties_update = cls._args_reservation_applied_scope_properties_update + reservation_applied_scope_properties_update.display_name = AAZStrArg( + options=["display-name"], + help="Display name", + ) + reservation_applied_scope_properties_update.management_group_id = AAZStrArg( + options=["management-group-id"], + help="Fully-qualified identifier of the management group where the benefit must be applied.", + ) + reservation_applied_scope_properties_update.resource_group_id = AAZStrArg( + options=["resource-group-id"], + help="Fully-qualified identifier of the resource group.", + ) + reservation_applied_scope_properties_update.subscription_id = AAZStrArg( + options=["subscription-id"], + help="Fully-qualified identifier of the subscription.", + ) + reservation_applied_scope_properties_update.tenant_id = AAZStrArg( + options=["tenant-id"], + help="Tenant ID where the reservation should apply benefit.", + ) + + _schema.display_name = cls._args_reservation_applied_scope_properties_update.display_name + _schema.management_group_id = cls._args_reservation_applied_scope_properties_update.management_group_id + _schema.resource_group_id = cls._args_reservation_applied_scope_properties_update.resource_group_id + _schema.subscription_id = cls._args_reservation_applied_scope_properties_update.subscription_id + _schema.tenant_id = cls._args_reservation_applied_scope_properties_update.tenant_id + + def _execute_operations(self): + self.pre_operations() + yield self.ReservationsUpdateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ReservationsUpdateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations/{reservationId}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "reservationId", self.ctx.args.reservation_id, + required=True, + ), + **self.serialize_url_param( + "reservationOrderId", self.ctx.args.reservation_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + _UpdateByBillingAccountHelper._build_schema_reservation_applied_scope_properties_update(properties.set_prop("appliedScopeProperties", AAZObjectType, ".applied_scope_properties")) + properties.set_prop("appliedScopeType", AAZStrType, ".applied_scope_type") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("instanceFlexibility", AAZStrType, ".instance_flexibility") + properties.set_prop("renew", AAZBoolType, ".renew") + properties.set_prop("renewProperties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + properties.set_prop("reviewDateTime", AAZStrType, ".review_date_time") + + renew_properties = _builder.get(".properties.renewProperties") + if renew_properties is not None: + renew_properties.set_prop("purchaseProperties", AAZObjectType, ".purchase_properties") + + purchase_properties = _builder.get(".properties.renewProperties.purchaseProperties") + if purchase_properties is not None: + purchase_properties.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + purchase_properties.set_prop("sku", AAZObjectType, ".sku") + + properties = _builder.get(".properties.renewProperties.purchaseProperties.properties") + if properties is not None: + _UpdateByBillingAccountHelper._build_schema_reservation_applied_scope_properties_update(properties.set_prop("appliedScopeProperties", AAZObjectType, ".applied_scope_properties")) + properties.set_prop("appliedScopeType", AAZStrType, ".applied_scope_type") + properties.set_prop("appliedScopes", AAZListType, ".applied_scopes") + properties.set_prop("billingPlan", AAZStrType, ".billing_plan") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("quantity", AAZIntType, ".quantity") + properties.set_prop("renew", AAZBoolType, ".renew") + properties.set_prop("reservedResourceProperties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + properties.set_prop("reviewDateTime", AAZStrType, ".review_date_time") + + applied_scopes = _builder.get(".properties.renewProperties.purchaseProperties.properties.appliedScopes") + if applied_scopes is not None: + applied_scopes.set_elements(AAZStrType, ".") + + reserved_resource_properties = _builder.get(".properties.renewProperties.purchaseProperties.properties.reservedResourceProperties") + if reserved_resource_properties is not None: + reserved_resource_properties.set_prop("instanceFlexibility", AAZStrType, ".instance_flexibility") + + sku = _builder.get(".properties.renewProperties.purchaseProperties.sku") + if sku is not None: + sku.set_prop("name", AAZStrType, ".name") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZIntType() + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _UpdateByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType() + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + merge_properties = cls._schema_on_200.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _UpdateByBillingAccountHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _UpdateByBillingAccountHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _UpdateByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateByBillingAccountHelper: + """Helper class for UpdateByBillingAccount""" + + @classmethod + def _build_schema_reservation_applied_scope_properties_update(cls, _builder): + if _builder is None: + return + _builder.set_prop("displayName", AAZStrType, ".display_name") + _builder.set_prop("managementGroupId", AAZStrType, ".management_group_id") + _builder.set_prop("resourceGroupId", AAZStrType, ".resource_group_id") + _builder.set_prop("subscriptionId", AAZStrType, ".subscription_id") + _builder.set_prop("tenantId", AAZStrType, ".tenant_id") + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + +__all__ = ["UpdateByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation/_wait.py b/src/billing/azext_billing/aaz/latest/billing/reservation/_wait.py new file mode 100644 index 00000000000..847bdc90b9b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation/_wait.py @@ -0,0 +1,543 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservationorders/{}/reservations/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.reservation_id = AAZStrArg( + options=["--reservation-id"], + help="Id of the reservation item", + required=True, + ) + _args_schema.reservation_order_id = AAZStrArg( + options=["--reservation-order-id"], + help="Order Id of the reservation", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the detail information of some properties.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationsGetByReservationOrder(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class ReservationsGetByReservationOrder(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations/{reservationId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "reservationId", self.ctx.args.reservation_id, + required=True, + ), + **self.serialize_url_param( + "reservationOrderId", self.ctx.args.reservation_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZIntType() + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _WaitHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType() + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + merge_properties = cls._schema_on_200.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _WaitHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _WaitHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _WaitHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation_order/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/reservation_order/__cmd_group.py new file mode 100644 index 00000000000..0fbe4554956 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation_order/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing reservation-order", +) +class __CMDGroup(AAZCommandGroup): + """Get and List operations for Reservation Orders + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation_order/__init__.py b/src/billing/azext_billing/aaz/latest/billing/reservation_order/__init__.py new file mode 100644 index 00000000000..2405576f3a2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation_order/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_by_billing_account import * +from ._list_by_billing_account import * diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation_order/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/reservation_order/_get_by_billing_account.py new file mode 100644 index 00000000000..bb10f4551b2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation_order/_get_by_billing_account.py @@ -0,0 +1,717 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation-order get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get the details of the ReservationOrder in the billing account. + + :example: reservationOrderGetByBillingAccount + az billing reservation-order get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --reservation-order-id 20000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservationorders/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.reservation_order_id = AAZStrArg( + options=["--reservation-order-id"], + help="Order Id of the reservation", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the detail information of some properties.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationOrdersGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ReservationOrdersGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "reservationOrderId", self.ctx.args.reservation_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZIntType() + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _GetByBillingAccountHelper._build_schema_system_data_read(_schema_on_200.system_data) + _schema_on_200.tags = AAZDictType() + _GetByBillingAccountHelper._build_schema_tags_read(_schema_on_200.tags) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.created_date_time = AAZStrType( + serialized_name="createdDateTime", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_id = AAZStrType( + serialized_name="enrollmentId", + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + _GetByBillingAccountHelper._build_schema_reservation_extended_status_info_read(properties.extended_status_info) + properties.original_quantity = AAZIntType( + serialized_name="originalQuantity", + ) + properties.plan_information = AAZObjectType( + serialized_name="planInformation", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.request_date_time = AAZStrType( + serialized_name="requestDateTime", + ) + properties.reservations = AAZListType() + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + plan_information = cls._schema_on_200.properties.plan_information + plan_information.next_payment_due_date = AAZStrType( + serialized_name="nextPaymentDueDate", + ) + plan_information.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(plan_information.pricing_currency_total) + plan_information.start_date = AAZStrType( + serialized_name="startDate", + ) + plan_information.transactions = AAZListType() + + transactions = cls._schema_on_200.properties.plan_information.transactions + transactions.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.plan_information.transactions.Element + _element.billing_account = AAZStrType( + serialized_name="billingAccount", + ) + _element.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(_element.billing_currency_total) + _element.due_date = AAZStrType( + serialized_name="dueDate", + ) + _element.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + _GetByBillingAccountHelper._build_schema_reservation_extended_status_info_read(_element.extended_status_info) + _element.payment_date = AAZStrType( + serialized_name="paymentDate", + ) + _element.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(_element.pricing_currency_total) + _element.status = AAZStrType() + + reservations = cls._schema_on_200.properties.reservations + reservations.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.reservations.Element + _element.etag = AAZIntType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _GetByBillingAccountHelper._build_schema_system_data_read(_element.system_data) + _element.tags = AAZDictType() + _GetByBillingAccountHelper._build_schema_tags_read(_element.tags) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties.reservations.Element.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _GetByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + _GetByBillingAccountHelper._build_schema_reservation_extended_status_info_read(properties.extended_status_info) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.reservations.Element.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + merge_properties = cls._schema_on_200.properties.reservations.Element.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.properties.reservations.Element.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.properties.reservations.Element.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.properties.reservations.Element.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.properties.reservations.Element.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _GetByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.properties.reservations.Element.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.properties.reservations.Element.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.properties.reservations.Element.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.properties.reservations.Element.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.properties.reservations.Element.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.properties.reservations.Element.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.properties.reservations.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.properties.reservations.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.reservations.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.properties.reservations.Element.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + _schema_reservation_extended_status_info_read = None + + @classmethod + def _build_schema_reservation_extended_status_info_read(cls, _schema): + if cls._schema_reservation_extended_status_info_read is not None: + _schema.message = cls._schema_reservation_extended_status_info_read.message + _schema.properties = cls._schema_reservation_extended_status_info_read.properties + _schema.status_code = cls._schema_reservation_extended_status_info_read.status_code + return + + cls._schema_reservation_extended_status_info_read = _schema_reservation_extended_status_info_read = AAZObjectType() + + reservation_extended_status_info_read = _schema_reservation_extended_status_info_read + reservation_extended_status_info_read.message = AAZStrType() + reservation_extended_status_info_read.properties = AAZObjectType() + reservation_extended_status_info_read.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = _schema_reservation_extended_status_info_read.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + _schema.message = cls._schema_reservation_extended_status_info_read.message + _schema.properties = cls._schema_reservation_extended_status_info_read.properties + _schema.status_code = cls._schema_reservation_extended_status_info_read.status_code + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + _schema_tags_read = None + + @classmethod + def _build_schema_tags_read(cls, _schema): + if cls._schema_tags_read is not None: + _schema.Element = cls._schema_tags_read.Element + return + + cls._schema_tags_read = _schema_tags_read = AAZDictType() + + tags_read = _schema_tags_read + tags_read.Element = AAZStrType() + + _schema.Element = cls._schema_tags_read.Element + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/reservation_order/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/reservation_order/_list_by_billing_account.py new file mode 100644 index 00000000000..91f35093778 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/reservation_order/_list_by_billing_account.py @@ -0,0 +1,733 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing reservation-order list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List all the `ReservationOrders in the billing account. + + :example: reservationOrderListByBillingAccount + az billing reservation-order list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/reservationorders", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.skiptoken = AAZFloatArg( + options=["--skiptoken"], + help="The number of reservations to skip from the list before returning results", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReservationOrdersListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ReservationOrdersListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "skiptoken", self.ctx.args.skiptoken, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZIntType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_system_data_read(_element.system_data) + _element.tags = AAZDictType() + _ListByBillingAccountHelper._build_schema_tags_read(_element.tags) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.created_date_time = AAZStrType( + serialized_name="createdDateTime", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_id = AAZStrType( + serialized_name="enrollmentId", + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + _ListByBillingAccountHelper._build_schema_reservation_extended_status_info_read(properties.extended_status_info) + properties.original_quantity = AAZIntType( + serialized_name="originalQuantity", + ) + properties.plan_information = AAZObjectType( + serialized_name="planInformation", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.request_date_time = AAZStrType( + serialized_name="requestDateTime", + ) + properties.reservations = AAZListType() + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + plan_information = cls._schema_on_200.value.Element.properties.plan_information + plan_information.next_payment_due_date = AAZStrType( + serialized_name="nextPaymentDueDate", + ) + plan_information.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(plan_information.pricing_currency_total) + plan_information.start_date = AAZStrType( + serialized_name="startDate", + ) + plan_information.transactions = AAZListType() + + transactions = cls._schema_on_200.value.Element.properties.plan_information.transactions + transactions.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.plan_information.transactions.Element + _element.billing_account = AAZStrType( + serialized_name="billingAccount", + ) + _element.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(_element.billing_currency_total) + _element.due_date = AAZStrType( + serialized_name="dueDate", + ) + _element.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + _ListByBillingAccountHelper._build_schema_reservation_extended_status_info_read(_element.extended_status_info) + _element.payment_date = AAZStrType( + serialized_name="paymentDate", + ) + _element.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(_element.pricing_currency_total) + _element.status = AAZStrType() + + reservations = cls._schema_on_200.value.Element.properties.reservations + reservations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.reservations.Element + _element.etag = AAZIntType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_system_data_read(_element.system_data) + _element.tags = AAZDictType() + _ListByBillingAccountHelper._build_schema_tags_read(_element.tags) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + flags={"read_only": True}, + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.archived = AAZBoolType() + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.capabilities = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date = AAZStrType( + serialized_name="expiryDate", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + ) + _ListByBillingAccountHelper._build_schema_reservation_extended_status_info_read(properties.extended_status_info) + properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + properties.last_updated_date_time = AAZStrType( + serialized_name="lastUpdatedDateTime", + flags={"read_only": True}, + ) + properties.merge_properties = AAZObjectType( + serialized_name="mergeProperties", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_sub_state = AAZStrType( + serialized_name="provisioningSubState", + flags={"read_only": True}, + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + ) + properties.quantity = AAZFloatType( + flags={"read_only": True}, + ) + properties.renew = AAZBoolType( + flags={"read_only": True}, + ) + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + flags={"read_only": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.split_properties = AAZObjectType( + serialized_name="splitProperties", + ) + properties.swap_properties = AAZObjectType( + serialized_name="swapProperties", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.user_friendly_renew_state = AAZStrType( + serialized_name="userFriendlyRenewState", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"client_flatten": True, "read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.reservations.Element.properties.applied_scopes + applied_scopes.Element = AAZStrType( + flags={"read_only": True}, + ) + + merge_properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties.merge_properties + merge_properties.merge_destination = AAZStrType( + serialized_name="mergeDestination", + ) + merge_properties.merge_sources = AAZListType( + serialized_name="mergeSources", + ) + + merge_sources = cls._schema_on_200.value.Element.properties.reservations.Element.properties.merge_properties.merge_sources + merge_sources.Element = AAZStrType() + + renew_properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties.renew_properties + renew_properties.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(renew_properties.billing_currency_total) + renew_properties.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(renew_properties.pricing_currency_total) + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties.renew_properties.purchase_properties + purchase_properties.location = AAZStrType() + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + + properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingAccountHelper._build_schema_reservation_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.applied_scopes = AAZListType( + serialized_name="appliedScopes", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.quantity = AAZIntType() + properties.renew = AAZBoolType() + properties.reserved_resource_properties = AAZObjectType( + serialized_name="reservedResourceProperties", + flags={"client_flatten": True}, + ) + properties.reserved_resource_type = AAZStrType( + serialized_name="reservedResourceType", + flags={"read_only": True}, + ) + properties.review_date_time = AAZStrType( + serialized_name="reviewDateTime", + ) + properties.term = AAZStrType( + flags={"read_only": True}, + ) + + applied_scopes = cls._schema_on_200.value.Element.properties.reservations.Element.properties.renew_properties.purchase_properties.properties.applied_scopes + applied_scopes.Element = AAZStrType() + + reserved_resource_properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties.renew_properties.purchase_properties.properties.reserved_resource_properties + reserved_resource_properties.instance_flexibility = AAZStrType( + serialized_name="instanceFlexibility", + ) + + sku = cls._schema_on_200.value.Element.properties.reservations.Element.properties.renew_properties.purchase_properties.sku + sku.name = AAZStrType() + + split_properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties.split_properties + split_properties.split_destinations = AAZListType( + serialized_name="splitDestinations", + ) + split_properties.split_source = AAZStrType( + serialized_name="splitSource", + ) + + split_destinations = cls._schema_on_200.value.Element.properties.reservations.Element.properties.split_properties.split_destinations + split_destinations.Element = AAZStrType() + + swap_properties = cls._schema_on_200.value.Element.properties.reservations.Element.properties.swap_properties + swap_properties.swap_destination = AAZStrType( + serialized_name="swapDestination", + ) + swap_properties.swap_source = AAZStrType( + serialized_name="swapSource", + ) + + utilization = cls._schema_on_200.value.Element.properties.reservations.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.reservations.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.reservations.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.properties.reservations.Element.sku + sku.name = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + _schema_reservation_applied_scope_properties_read = None + + @classmethod + def _build_schema_reservation_applied_scope_properties_read(cls, _schema): + if cls._schema_reservation_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + return + + cls._schema_reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read = AAZObjectType() + + reservation_applied_scope_properties_read = _schema_reservation_applied_scope_properties_read + reservation_applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + reservation_applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + reservation_applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + reservation_applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + reservation_applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_reservation_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_reservation_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_reservation_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_reservation_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_reservation_applied_scope_properties_read.tenant_id + + _schema_reservation_extended_status_info_read = None + + @classmethod + def _build_schema_reservation_extended_status_info_read(cls, _schema): + if cls._schema_reservation_extended_status_info_read is not None: + _schema.message = cls._schema_reservation_extended_status_info_read.message + _schema.properties = cls._schema_reservation_extended_status_info_read.properties + _schema.status_code = cls._schema_reservation_extended_status_info_read.status_code + return + + cls._schema_reservation_extended_status_info_read = _schema_reservation_extended_status_info_read = AAZObjectType() + + reservation_extended_status_info_read = _schema_reservation_extended_status_info_read + reservation_extended_status_info_read.message = AAZStrType() + reservation_extended_status_info_read.properties = AAZObjectType() + reservation_extended_status_info_read.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = _schema_reservation_extended_status_info_read.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + _schema.message = cls._schema_reservation_extended_status_info_read.message + _schema.properties = cls._schema_reservation_extended_status_info_read.properties + _schema.status_code = cls._schema_reservation_extended_status_info_read.status_code + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + _schema_tags_read = None + + @classmethod + def _build_schema_tags_read(cls, _schema): + if cls._schema_tags_read is not None: + _schema.Element = cls._schema_tags_read.Element + return + + cls._schema_tags_read = _schema_tags_read = AAZDictType() + + tags_read = _schema_tags_read + tags_read.Element = AAZStrType() + + _schema.Element = cls._schema_tags_read.Element + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/__cmd_group.py new file mode 100644 index 00000000000..0f5c18635e8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing role-assignment", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations at the billing profile and billing account scope like create, delete, list etc. around role assignments. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/__init__.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/__init__.py new file mode 100644 index 00000000000..018445535f5 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/__init__.py @@ -0,0 +1,43 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create_by_billing_account import * +from ._create_by_billing_profile import * +from ._create_by_customer import * +from ._create_by_department import * +from ._create_by_ea_billing_account import * +from ._create_by_enrollment_account import * +from ._create_by_invoice_section import * +from ._delete_by_billing_account import * +from ._delete_by_billing_profile import * +from ._delete_by_customer import * +from ._delete_by_department import * +from ._delete_by_enrollment_account import * +from ._delete_by_invoice_section import * +from ._get_by_billing_account import * +from ._get_by_billing_profile import * +from ._get_by_customer import * +from ._get_by_department import * +from ._get_by_enrollment_account import * +from ._get_by_invoice_section import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_customer import * +from ._list_by_department import * +from ._list_by_enrollment_account import * +from ._list_by_invoice_section import * +from ._resolve_by_billing_account import * +from ._resolve_by_billing_profile import * +from ._resolve_by_customer import * +from ._resolve_by_invoice_section import * +from ._update_by_department import * +from ._update_by_ea_account import * +from ._update_by_enrollment_account import * diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_billing_account.py new file mode 100644 index 00000000000..7de13f6b76f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_billing_account.py @@ -0,0 +1,387 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment create-by-billing-account", +) +class CreateByBillingAccount(AAZCommand): + """Adds a role assignment on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: BillingRoleAssignmentCreateByBillingAccount + az billing role-assignment create-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --principal-id 00000000-0000-0000-0000-000000000000 --principal-tenant-id 076915e7-de10-4323-bb34-a58c904068bb --role-definition-id /providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000 --user-email-address john@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/createbillingroleassignment", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Parameters", + help="The object id of the user to whom the role was assigned.", + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Parameters", + help="The principal PUID of the user to whom the role was assigned.", + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Parameters", + help="The principal tenant id of the user to whom the role was assigned.", + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Parameters", + help="The ID of the role definition.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Parameters", + help="The scope at which the role was assigned.", + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Parameters", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Parameters", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsCreateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsCreateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/createBillingRoleAssignment", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("principalId", AAZStrType, ".principal_id") + _builder.set_prop("principalPuid", AAZStrType, ".principal_puid") + _builder.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + _builder.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("scope", AAZStrType, ".scope") + _builder.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + _builder.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CreateByBillingAccountHelper: + """Helper class for CreateByBillingAccount""" + + +__all__ = ["CreateByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_billing_profile.py new file mode 100644 index 00000000000..d64b91f35c2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_billing_profile.py @@ -0,0 +1,399 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment create-by-billing-profile", +) +class CreateByBillingProfile(AAZCommand): + """Adds a role assignment on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: BillingRoleAssignmentCreateByBillingProfile + az billing role-assignment create-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --principal-id 00000000-0000-0000-0000-000000000000 --principal-tenant-id 076915e7-de10-4323-bb34-a58c904068bb --role-definition-id /providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000 --user-email-address john@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/createbillingroleassignment", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Parameters", + help="The object id of the user to whom the role was assigned.", + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Parameters", + help="The principal PUID of the user to whom the role was assigned.", + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Parameters", + help="The principal tenant id of the user to whom the role was assigned.", + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Parameters", + help="The ID of the role definition.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Parameters", + help="The scope at which the role was assigned.", + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Parameters", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Parameters", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsCreateByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsCreateByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/createBillingRoleAssignment", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("principalId", AAZStrType, ".principal_id") + _builder.set_prop("principalPuid", AAZStrType, ".principal_puid") + _builder.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + _builder.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("scope", AAZStrType, ".scope") + _builder.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + _builder.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CreateByBillingProfileHelper: + """Helper class for CreateByBillingProfile""" + + +__all__ = ["CreateByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_customer.py new file mode 100644 index 00000000000..ad304a911fd --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_customer.py @@ -0,0 +1,411 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment create-by-customer", +) +class CreateByCustomer(AAZCommand): + """Adds a role assignment on a customer. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingRoleAssignmentCreateByCustomer + az billing role-assignment create-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --customer-name 703ab484-dda2-4402-827b-a74513b61e2d --principal-id 00000000-0000-0000-0000-000000000000 --principal-tenant-id 076915e7-de10-4323-bb34-a58c904068bb --role-definition-id /providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfileName/BKM6-54VH-BG7-PGB/customers/703ab484-dda2-4402-827b-a74513b61e2d/billingRoleDefinitions/30000000-aaaa-bbbb-cccc-100000000000 --user-email-address john@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/createbillingroleassignment", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Parameters", + help="The object id of the user to whom the role was assigned.", + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Parameters", + help="The principal PUID of the user to whom the role was assigned.", + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Parameters", + help="The principal tenant id of the user to whom the role was assigned.", + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Parameters", + help="The ID of the role definition.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Parameters", + help="The scope at which the role was assigned.", + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Parameters", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Parameters", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsCreateByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsCreateByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/createBillingRoleAssignment", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("principalId", AAZStrType, ".principal_id") + _builder.set_prop("principalPuid", AAZStrType, ".principal_puid") + _builder.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + _builder.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("scope", AAZStrType, ".scope") + _builder.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + _builder.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CreateByCustomerHelper: + """Helper class for CreateByCustomer""" + + +__all__ = ["CreateByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_department.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_department.py new file mode 100644 index 00000000000..cf8f10e9e44 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_department.py @@ -0,0 +1,431 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment create-by-department", +) +class CreateByDepartment(AAZCommand): + """Create a billing role assignment. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleAssignmentCreateOrUpdateByDepartment + az billing role-assignment create-by-department --billing-account-name 7898901 --department-name 12345 --billing-role-assignment-name 9dfd08c2-62a3-4d47-85bd-1cdba1408402 --principal-id 00000000-0000-0000-0000-000000000000 --principal-tenant-id 076915e7-de10-4323-bb34-a58c904068bb --role-definition-id /providers/Microsoft.Billing/billingAccounts/7898901/departments/12345/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db --user-email-address john@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Properties", + help="The object id of the user to whom the role was assigned.", + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Properties", + help="The principal PUID of the user to whom the role was assigned.", + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Properties", + help="The principal tenant id of the user to whom the role was assigned.", + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Properties", + help="The ID of the role definition.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Properties", + help="The scope at which the role was assigned.", + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Properties", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Properties", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsCreateOrUpdateByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsCreateOrUpdateByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("principalId", AAZStrType, ".principal_id") + properties.set_prop("principalPuid", AAZStrType, ".principal_puid") + properties.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + properties.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("scope", AAZStrType, ".scope") + properties.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + properties.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateByDepartmentHelper: + """Helper class for CreateByDepartment""" + + +__all__ = ["CreateByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_ea_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_ea_billing_account.py new file mode 100644 index 00000000000..c2f9e16b318 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_ea_billing_account.py @@ -0,0 +1,419 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment create-by-ea-billing-account", +) +class CreateByEaBillingAccount(AAZCommand): + """Create a billing role assignment. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleAssignmentCreateOrUpdateByBillingAccount + az billing role-assignment create-by-ea-billing-account --billing-account-name 7898901 --billing-role-assignment-name 9dfd08c2-62a3-4d47-85bd-1cdba1408402 --principal-id 00000000-0000-0000-0000-000000000000 --principal-tenant-id 076915e7-de10-4323-bb34-a58c904068bb --role-definition-id /providers/Microsoft.Billing/billingAccounts/7898901/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db --user-email-address john@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Properties", + help="The object id of the user to whom the role was assigned.", + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Properties", + help="The principal PUID of the user to whom the role was assigned.", + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Properties", + help="The principal tenant id of the user to whom the role was assigned.", + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Properties", + help="The ID of the role definition.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Properties", + help="The scope at which the role was assigned.", + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Properties", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Properties", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsCreateOrUpdateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsCreateOrUpdateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("principalId", AAZStrType, ".principal_id") + properties.set_prop("principalPuid", AAZStrType, ".principal_puid") + properties.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + properties.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("scope", AAZStrType, ".scope") + properties.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + properties.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateByEaBillingAccountHelper: + """Helper class for CreateByEaBillingAccount""" + + +__all__ = ["CreateByEaBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_enrollment_account.py new file mode 100644 index 00000000000..ab5a2fadea0 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_enrollment_account.py @@ -0,0 +1,431 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment create-by-enrollment-account", +) +class CreateByEnrollmentAccount(AAZCommand): + """Create a billing role assignment. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleAssignmentCreateOrUpdateByEnrollmentAccount + az billing role-assignment create-by-enrollment-account --billing-account-name 7898901 --enrollment-account-name 123456 --billing-role-assignment-name 9dfd08c2-62a3-4d47-85bd-1cdba1408402 --principal-id 00000000-0000-0000-0000-000000000000 --principal-tenant-id 076915e7-de10-4323-bb34-a58c904068bb --role-definition-id /providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db --user-email-address john@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Properties", + help="The object id of the user to whom the role was assigned.", + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Properties", + help="The principal PUID of the user to whom the role was assigned.", + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Properties", + help="The principal tenant id of the user to whom the role was assigned.", + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Properties", + help="The ID of the role definition.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Properties", + help="The scope at which the role was assigned.", + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Properties", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Properties", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsCreateOrUpdateByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsCreateOrUpdateByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("principalId", AAZStrType, ".principal_id") + properties.set_prop("principalPuid", AAZStrType, ".principal_puid") + properties.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + properties.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("scope", AAZStrType, ".scope") + properties.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + properties.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateByEnrollmentAccountHelper: + """Helper class for CreateByEnrollmentAccount""" + + +__all__ = ["CreateByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_invoice_section.py new file mode 100644 index 00000000000..5e2e8f7c84f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_create_by_invoice_section.py @@ -0,0 +1,411 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment create-by-invoice-section", +) +class CreateByInvoiceSection(AAZCommand): + """Adds a role assignment on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: BillingRoleAssignmentCreateByInvoiceSection + az billing role-assignment create-by-invoice-section --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --invoice-section-name xxxx-xxxx-xxx-xxx --principal-id 00000000-0000-0000-0000-000000000000 --principal-tenant-id 076915e7-de10-4323-bb34-a58c904068bb --role-definition-id /providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30/billingProfiles/BKM6-54VH-BG7-PGB/invoiceSections/xxxx-xxxx-xxx-xxx/billingRoleDefinitions/10000000-aaaa-bbbb-cccc-100000000000 --user-email-address john@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/createbillingroleassignment", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Parameters", + help="The object id of the user to whom the role was assigned.", + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Parameters", + help="The principal PUID of the user to whom the role was assigned.", + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Parameters", + help="The principal tenant id of the user to whom the role was assigned.", + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Parameters", + help="The ID of the role definition.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Parameters", + help="The scope at which the role was assigned.", + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Parameters", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Parameters", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsCreateByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsCreateByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/createBillingRoleAssignment", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("principalId", AAZStrType, ".principal_id") + _builder.set_prop("principalPuid", AAZStrType, ".principal_puid") + _builder.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + _builder.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("scope", AAZStrType, ".scope") + _builder.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + _builder.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CreateByInvoiceSectionHelper: + """Helper class for CreateByInvoiceSection""" + + +__all__ = ["CreateByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_billing_account.py new file mode 100644 index 00000000000..b9eba43c59d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_billing_account.py @@ -0,0 +1,142 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment delete-by-billing-account", + confirmation="Are you sure you want to perform this operation?", +) +class DeleteByBillingAccount(AAZCommand): + """Delete a role assignment on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: BillingRoleAssignmentDeleteByBillingAccount + az billing role-assignment delete-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-role-assignment-name 10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsDeleteByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingRoleAssignmentsDeleteByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteByBillingAccountHelper: + """Helper class for DeleteByBillingAccount""" + + +__all__ = ["DeleteByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_billing_profile.py new file mode 100644 index 00000000000..da53264b119 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_billing_profile.py @@ -0,0 +1,154 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment delete-by-billing-profile", + confirmation="Are you sure you want to perform this operation?", +) +class DeleteByBillingProfile(AAZCommand): + """Delete a role assignment on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: BillingRoleAssignmentDeleteByBillingProfile + az billing role-assignment delete-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --billing-role-assignment-name 10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsDeleteByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingRoleAssignmentsDeleteByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteByBillingProfileHelper: + """Helper class for DeleteByBillingProfile""" + + +__all__ = ["DeleteByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_customer.py new file mode 100644 index 00000000000..10fb043efbe --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_customer.py @@ -0,0 +1,166 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment delete-by-customer", + confirmation="Are you sure you want to perform this operation?", +) +class DeleteByCustomer(AAZCommand): + """Delete a role assignment on a customer. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingRoleAssignmentDeleteByCustomer + az billing role-assignment delete-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --customer-name 703ab484-dda2-4402-827b-a74513b61e2d --billing-role-assignment-name 30000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsDeleteByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingRoleAssignmentsDeleteByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteByCustomerHelper: + """Helper class for DeleteByCustomer""" + + +__all__ = ["DeleteByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_department.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_department.py new file mode 100644 index 00000000000..aabc641128d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_department.py @@ -0,0 +1,154 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment delete-by-department", + confirmation="Are you sure you want to perform this operation?", +) +class DeleteByDepartment(AAZCommand): + """Delete a role assignment on a department. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleAssignmentDeleteByDepartment + az billing role-assignment delete-by-department --billing-account-name 8608480 --department-name 123456 --billing-role-assignment-name 9dfd08c2-62a3-4d47-85bd-1cdba1408402 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsDeleteByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingRoleAssignmentsDeleteByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteByDepartmentHelper: + """Helper class for DeleteByDepartment""" + + +__all__ = ["DeleteByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_enrollment_account.py new file mode 100644 index 00000000000..3401849083c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_enrollment_account.py @@ -0,0 +1,154 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment delete-by-enrollment-account", + confirmation="Are you sure you want to perform this operation?", +) +class DeleteByEnrollmentAccount(AAZCommand): + """Delete a role assignment on a enrollment Account. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleAssignmentDeleteByEnrollmentAccount + az billing role-assignment delete-by-enrollment-account --billing-account-name 8608480 --enrollment-account-name 123456 --billing-role-assignment-name 9dfd08c2-62a3-4d47-85bd-1cdba1408402 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsDeleteByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingRoleAssignmentsDeleteByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteByEnrollmentAccountHelper: + """Helper class for DeleteByEnrollmentAccount""" + + +__all__ = ["DeleteByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_invoice_section.py new file mode 100644 index 00000000000..e6638ab7f7a --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_delete_by_invoice_section.py @@ -0,0 +1,166 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment delete-by-invoice-section", + confirmation="Are you sure you want to perform this operation?", +) +class DeleteByInvoiceSection(AAZCommand): + """Delete a role assignment on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: BillingRoleAssignmentDeleteByInvoiceSection + az billing role-assignment delete-by-invoice-section --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --invoice-section-name xxxx-xxxx-xxx-xxx --billing-role-assignment-name 10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsDeleteByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingRoleAssignmentsDeleteByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteByInvoiceSectionHelper: + """Helper class for DeleteByInvoiceSection""" + + +__all__ = ["DeleteByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_billing_account.py new file mode 100644 index 00000000000..ef07d128382 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_billing_account.py @@ -0,0 +1,319 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get a role assignment for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: BillingRoleAssignmentGetByBillingAccount + az billing role-assignment get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-role-assignment-name 10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_billing_profile.py new file mode 100644 index 00000000000..dcbfec1fdcd --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_billing_profile.py @@ -0,0 +1,331 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment get-by-billing-profile", +) +class GetByBillingProfile(AAZCommand): + """Get 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. + + :example: BillingRoleAssignmentGetByBillingProfile + az billing role-assignment get-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name xxxx-xxxx-xxx-xxx --billing-role-assignment-name 10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingProfileHelper: + """Helper class for GetByBillingProfile""" + + +__all__ = ["GetByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_customer.py new file mode 100644 index 00000000000..ab6839d76b1 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_customer.py @@ -0,0 +1,343 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment get-by-customer", +) +class GetByCustomer(AAZCommand): + """Get a role assignment for the caller on a customer. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingRoleAssignmentGetByCustomer + az billing role-assignment get-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 703ab484-dda2-4402-827b-a74513b61e2d --billing-role-assignment-name 30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByCustomerHelper: + """Helper class for GetByCustomer""" + + +__all__ = ["GetByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_department.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_department.py new file mode 100644 index 00000000000..df24946532d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_department.py @@ -0,0 +1,331 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment get-by-department", +) +class GetByDepartment(AAZCommand): + """Get a role assignment for the caller on a department. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleAssignmentGetByDepartment + az billing role-assignment get-by-department --billing-account-name 7898901 --department-name 225314 --billing-role-assignment-name 9dfd08c2-62a3-4d47-85bd-1cdba1408402 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByDepartmentHelper: + """Helper class for GetByDepartment""" + + +__all__ = ["GetByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_enrollment_account.py new file mode 100644 index 00000000000..09aaf596b95 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_enrollment_account.py @@ -0,0 +1,331 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment get-by-enrollment-account", +) +class GetByEnrollmentAccount(AAZCommand): + """Get a role assignment for the caller on a enrollment Account. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleAssignmentGetByEnrollmentAccount + az billing role-assignment get-by-enrollment-account --billing-account-name 7898901 --enrollment-account-name 225314 --billing-role-assignment-name 9dfd08c2-62a3-4d47-85bd-1cdba1408402 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByEnrollmentAccountHelper: + """Helper class for GetByEnrollmentAccount""" + + +__all__ = ["GetByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_invoice_section.py new file mode 100644 index 00000000000..ae4b4b99f1d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_get_by_invoice_section.py @@ -0,0 +1,343 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment get-by-invoice-section", +) +class GetByInvoiceSection(AAZCommand): + """Get a role assignment for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: BillingRoleAssignmentGetByInvoiceSection + az billing role-assignment get-by-invoice-section --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --invoice-section-name xxxx-xxxx-xxx-xxx --billing-role-assignment-name 10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByInvoiceSectionHelper: + """Helper class for GetByInvoiceSection""" + + +__all__ = ["GetByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_billing_account.py new file mode 100644 index 00000000000..924a9f37423 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_billing_account.py @@ -0,0 +1,342 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the role assignments for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: BillingRoleAssignmentListByBillingAccount + az billing role-assignment list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleAssignmentsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_billing_profile.py new file mode 100644 index 00000000000..edd88045081 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_billing_profile.py @@ -0,0 +1,354 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List the role assignments for the caller on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: BillingRoleAssignmentListByBillingProfile + az billing role-assignment list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleAssignmentsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_customer.py new file mode 100644 index 00000000000..dfea9482f88 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_customer.py @@ -0,0 +1,366 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment list-by-customer", +) +class ListByCustomer(AAZCommand): + """List the role assignments for the caller on customer. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingRoleAssignmentListByCustomer + az billing role-assignment list-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --customer-name 703ab484-dda2-4402-827b-a74513b61e2d + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsListByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleAssignmentsListByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerHelper: + """Helper class for ListByCustomer""" + + +__all__ = ["ListByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_department.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_department.py new file mode 100644 index 00000000000..b33a3f33af9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_department.py @@ -0,0 +1,333 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment list-by-department", +) +class ListByDepartment(AAZCommand): + """List the role assignments for the caller on a department. The operation is supported for billing accounts of type Enterprise Agreement. + + :example: BillingRoleAssignmentListByDepartment + az billing role-assignment list-by-department --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --department-name 12345 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsListByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleAssignmentsListByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByDepartmentHelper: + """Helper class for ListByDepartment""" + + +__all__ = ["ListByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_enrollment_account.py new file mode 100644 index 00000000000..47714c39a76 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_enrollment_account.py @@ -0,0 +1,333 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment list-by-enrollment-account", +) +class ListByEnrollmentAccount(AAZCommand): + """List the role assignments for the caller on a enrollment account. The operation is supported for billing accounts of type Enterprise Agreement. + + :example: BillingRoleAssignmentListByEnrollmentAccount + az billing role-assignment list-by-enrollment-account --billing-account-name 6100092 --enrollment-account-name 123456 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsListByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleAssignmentsListByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByEnrollmentAccountHelper: + """Helper class for ListByEnrollmentAccount""" + + +__all__ = ["ListByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_invoice_section.py new file mode 100644 index 00000000000..1d4aa2e38d4 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_list_by_invoice_section.py @@ -0,0 +1,366 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment list-by-invoice-section", +) +class ListByInvoiceSection(AAZCommand): + """List the role assignments for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: BillingRoleAssignmentListByInvoiceSection + az billing role-assignment list-by-invoice-section --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --invoice-section-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsListByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleAssignmentsListByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceSectionHelper: + """Helper class for ListByInvoiceSection""" + + +__all__ = ["ListByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_billing_account.py new file mode 100644 index 00000000000..cde3fbb2f6d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_billing_account.py @@ -0,0 +1,351 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment resolve-by-billing-account", +) +class ResolveByBillingAccount(AAZCommand): + """Lists the role assignments for the caller on a billing account while fetching user info for each role assignment. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: ResolveBillingRoleAssignmentByBillingAccount + az billing role-assignment resolve-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/resolvebillingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.resolve_scope_display_names = AAZBoolArg( + options=["--resolve-scope-display-names"], + help="Resolves the scope display name for each of the role assignments.", + default=False, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsResolveByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsResolveByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/resolveBillingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "resolveScopeDisplayNames", self.ctx.args.resolve_scope_display_names, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ResolveByBillingAccountHelper: + """Helper class for ResolveByBillingAccount""" + + +__all__ = ["ResolveByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_billing_profile.py new file mode 100644 index 00000000000..bec370ca040 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_billing_profile.py @@ -0,0 +1,363 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment resolve-by-billing-profile", +) +class ResolveByBillingProfile(AAZCommand): + """Lists the role assignments for the caller on an billing profile while fetching user info for each role assignment. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: ResolveBillingRoleAssignmentByBillingProfile + az billing role-assignment resolve-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/resolvebillingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.resolve_scope_display_names = AAZBoolArg( + options=["--resolve-scope-display-names"], + help="Resolves the scope display name for each of the role assignments.", + default=False, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsResolveByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsResolveByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/resolveBillingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "resolveScopeDisplayNames", self.ctx.args.resolve_scope_display_names, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ResolveByBillingProfileHelper: + """Helper class for ResolveByBillingProfile""" + + +__all__ = ["ResolveByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_customer.py new file mode 100644 index 00000000000..c4a5fda9caf --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_customer.py @@ -0,0 +1,375 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment resolve-by-customer", +) +class ResolveByCustomer(AAZCommand): + """Lists the role assignments for the caller on a customer while fetching user info for each role assignment. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement. + + :example: ResolveBillingRoleAssignmentByCustomer + az billing role-assignment resolve-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 703ab484-dda2-4402-827b-a74513b61e2d + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/resolvebillingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.resolve_scope_display_names = AAZBoolArg( + options=["--resolve-scope-display-names"], + help="Resolves the scope display name for each of the role assignments.", + default=False, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsResolveByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsResolveByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/resolveBillingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "resolveScopeDisplayNames", self.ctx.args.resolve_scope_display_names, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ResolveByCustomerHelper: + """Helper class for ResolveByCustomer""" + + +__all__ = ["ResolveByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_invoice_section.py new file mode 100644 index 00000000000..2f7792e8113 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_resolve_by_invoice_section.py @@ -0,0 +1,375 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment resolve-by-invoice-section", +) +class ResolveByInvoiceSection(AAZCommand): + """Lists the role assignments for the caller on an invoice section while fetching user info for each role assignment. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: ResolveBillingRoleAssignmentByInvoiceSection + az billing role-assignment resolve-by-invoice-section --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30 --billing-profile-name BKM6-54VH-BG7-PGB --invoice-section-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/resolvebillingroleassignments", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.resolve_scope_display_names = AAZBoolArg( + options=["--resolve-scope-display-names"], + help="Resolves the scope display name for each of the role assignments.", + default=False, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingRoleAssignmentsResolveByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsResolveByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/resolveBillingRoleAssignments", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "resolveScopeDisplayNames", self.ctx.args.resolve_scope_display_names, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ResolveByInvoiceSectionHelper: + """Helper class for ResolveByInvoiceSection""" + + +__all__ = ["ResolveByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_department.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_department.py new file mode 100644 index 00000000000..ab90cf9d37f --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_department.py @@ -0,0 +1,568 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment update-by-department", +) +class UpdateByDepartment(AAZCommand): + """Update a billing role assignment. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Properties", + help="The object id of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Properties", + help="The principal PUID of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Properties", + help="The principal tenant id of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Properties", + help="The ID of the role definition.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Properties", + help="The scope at which the role was assigned.", + nullable=True, + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Properties", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + nullable=True, + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Properties", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByDepartment(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.BillingRoleAssignmentsCreateOrUpdateByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateByDepartmentHelper._build_schema_billing_role_assignment_read(cls._schema_on_200) + + return cls._schema_on_200 + + class BillingRoleAssignmentsCreateOrUpdateByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateByDepartmentHelper._build_schema_billing_role_assignment_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("principalId", AAZStrType, ".principal_id") + properties.set_prop("principalPuid", AAZStrType, ".principal_puid") + properties.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + properties.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("scope", AAZStrType, ".scope") + properties.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + properties.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + +class _UpdateByDepartmentHelper: + """Helper class for UpdateByDepartment""" + + _schema_billing_role_assignment_read = None + + @classmethod + def _build_schema_billing_role_assignment_read(cls, _schema): + if cls._schema_billing_role_assignment_read is not None: + _schema.id = cls._schema_billing_role_assignment_read.id + _schema.name = cls._schema_billing_role_assignment_read.name + _schema.properties = cls._schema_billing_role_assignment_read.properties + _schema.system_data = cls._schema_billing_role_assignment_read.system_data + _schema.tags = cls._schema_billing_role_assignment_read.tags + _schema.type = cls._schema_billing_role_assignment_read.type + return + + cls._schema_billing_role_assignment_read = _schema_billing_role_assignment_read = AAZObjectType() + + billing_role_assignment_read = _schema_billing_role_assignment_read + billing_role_assignment_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_role_assignment_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_role_assignment_read.properties = AAZObjectType() + billing_role_assignment_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_role_assignment_read.tags = AAZDictType() + billing_role_assignment_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_role_assignment_read.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = _schema_billing_role_assignment_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_role_assignment_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_role_assignment_read.id + _schema.name = cls._schema_billing_role_assignment_read.name + _schema.properties = cls._schema_billing_role_assignment_read.properties + _schema.system_data = cls._schema_billing_role_assignment_read.system_data + _schema.tags = cls._schema_billing_role_assignment_read.tags + _schema.type = cls._schema_billing_role_assignment_read.type + + +__all__ = ["UpdateByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_ea_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_ea_account.py new file mode 100644 index 00000000000..59d8fc1a31c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_ea_account.py @@ -0,0 +1,552 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment update-by-ea-account", +) +class UpdateByEaAccount(AAZCommand): + """Update a billing role assignment. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Properties", + help="The object id of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Properties", + help="The principal PUID of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Properties", + help="The principal tenant id of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Properties", + help="The ID of the role definition.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Properties", + help="The scope at which the role was assigned.", + nullable=True, + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Properties", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + nullable=True, + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Properties", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByBillingAccount(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.BillingRoleAssignmentsCreateOrUpdateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateByEaAccountHelper._build_schema_billing_role_assignment_read(cls._schema_on_200) + + return cls._schema_on_200 + + class BillingRoleAssignmentsCreateOrUpdateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateByEaAccountHelper._build_schema_billing_role_assignment_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("principalId", AAZStrType, ".principal_id") + properties.set_prop("principalPuid", AAZStrType, ".principal_puid") + properties.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + properties.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("scope", AAZStrType, ".scope") + properties.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + properties.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + +class _UpdateByEaAccountHelper: + """Helper class for UpdateByEaAccount""" + + _schema_billing_role_assignment_read = None + + @classmethod + def _build_schema_billing_role_assignment_read(cls, _schema): + if cls._schema_billing_role_assignment_read is not None: + _schema.id = cls._schema_billing_role_assignment_read.id + _schema.name = cls._schema_billing_role_assignment_read.name + _schema.properties = cls._schema_billing_role_assignment_read.properties + _schema.system_data = cls._schema_billing_role_assignment_read.system_data + _schema.tags = cls._schema_billing_role_assignment_read.tags + _schema.type = cls._schema_billing_role_assignment_read.type + return + + cls._schema_billing_role_assignment_read = _schema_billing_role_assignment_read = AAZObjectType() + + billing_role_assignment_read = _schema_billing_role_assignment_read + billing_role_assignment_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_role_assignment_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_role_assignment_read.properties = AAZObjectType() + billing_role_assignment_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_role_assignment_read.tags = AAZDictType() + billing_role_assignment_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_role_assignment_read.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = _schema_billing_role_assignment_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_role_assignment_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_role_assignment_read.id + _schema.name = cls._schema_billing_role_assignment_read.name + _schema.properties = cls._schema_billing_role_assignment_read.properties + _schema.system_data = cls._schema_billing_role_assignment_read.system_data + _schema.tags = cls._schema_billing_role_assignment_read.tags + _schema.type = cls._schema_billing_role_assignment_read.type + + +__all__ = ["UpdateByEaAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_enrollment_account.py new file mode 100644 index 00000000000..49e34f1a309 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_assignment/_update_by_enrollment_account.py @@ -0,0 +1,568 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-assignment update-by-enrollment-account", +) +class UpdateByEnrollmentAccount(AAZCommand): + """Update a billing role assignment. The operation is supported only for billing accounts with agreement type Enterprise Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingroleassignments/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_role_assignment_name = AAZStrArg( + options=["--billing-role-assignment-name"], + help="The ID that uniquely identifies a role assignment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12}(_[a-fA-F0-9]{8}[-]?([a-fA-F0-9]{4}[-]?){3}[a-fA-F0-9]{12})?$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.principal_id = AAZStrArg( + options=["--principal-id"], + arg_group="Properties", + help="The object id of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.principal_puid = AAZStrArg( + options=["--principal-puid"], + arg_group="Properties", + help="The principal PUID of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.principal_tenant_id = AAZStrArg( + options=["--principal-tenant-id"], + arg_group="Properties", + help="The principal tenant id of the user to whom the role was assigned.", + nullable=True, + ) + _args_schema.role_definition_id = AAZStrArg( + options=["--role-definition-id"], + arg_group="Properties", + help="The ID of the role definition.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.scope = AAZStrArg( + options=["--scope"], + arg_group="Properties", + help="The scope at which the role was assigned.", + nullable=True, + ) + _args_schema.user_authentication_type = AAZStrArg( + options=["--user-authentication-type"], + arg_group="Properties", + help="The authentication type of the user, whether Organization or MSA, of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + nullable=True, + ) + _args_schema.user_email_address = AAZStrArg( + options=["--user-email-address"], + arg_group="Properties", + help="The email address of the user to whom the role was assigned. This is supported only for billing accounts with agreement type Enterprise Agreement.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleAssignmentsGetByEnrollmentAccount(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.BillingRoleAssignmentsCreateOrUpdateByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleAssignmentsGetByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateByEnrollmentAccountHelper._build_schema_billing_role_assignment_read(cls._schema_on_200) + + return cls._schema_on_200 + + class BillingRoleAssignmentsCreateOrUpdateByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingRoleAssignmentName", self.ctx.args.billing_role_assignment_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateByEnrollmentAccountHelper._build_schema_billing_role_assignment_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("principalId", AAZStrType, ".principal_id") + properties.set_prop("principalPuid", AAZStrType, ".principal_puid") + properties.set_prop("principalTenantId", AAZStrType, ".principal_tenant_id") + properties.set_prop("roleDefinitionId", AAZStrType, ".role_definition_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("scope", AAZStrType, ".scope") + properties.set_prop("userAuthenticationType", AAZStrType, ".user_authentication_type") + properties.set_prop("userEmailAddress", AAZStrType, ".user_email_address") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + +class _UpdateByEnrollmentAccountHelper: + """Helper class for UpdateByEnrollmentAccount""" + + _schema_billing_role_assignment_read = None + + @classmethod + def _build_schema_billing_role_assignment_read(cls, _schema): + if cls._schema_billing_role_assignment_read is not None: + _schema.id = cls._schema_billing_role_assignment_read.id + _schema.name = cls._schema_billing_role_assignment_read.name + _schema.properties = cls._schema_billing_role_assignment_read.properties + _schema.system_data = cls._schema_billing_role_assignment_read.system_data + _schema.tags = cls._schema_billing_role_assignment_read.tags + _schema.type = cls._schema_billing_role_assignment_read.type + return + + cls._schema_billing_role_assignment_read = _schema_billing_role_assignment_read = AAZObjectType() + + billing_role_assignment_read = _schema_billing_role_assignment_read + billing_role_assignment_read.id = AAZStrType( + flags={"read_only": True}, + ) + billing_role_assignment_read.name = AAZStrType( + flags={"read_only": True}, + ) + billing_role_assignment_read.properties = AAZObjectType() + billing_role_assignment_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + billing_role_assignment_read.tags = AAZDictType() + billing_role_assignment_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_billing_role_assignment_read.properties + properties.billing_account_display_name = AAZStrType( + serialized_name="billingAccountDisplayName", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_request_id = AAZStrType( + serialized_name="billingRequestId", + flags={"read_only": True}, + ) + properties.created_by_principal_id = AAZStrType( + serialized_name="createdByPrincipalId", + flags={"read_only": True}, + ) + properties.created_by_principal_puid = AAZStrType( + serialized_name="createdByPrincipalPuid", + flags={"read_only": True}, + ) + properties.created_by_principal_tenant_id = AAZStrType( + serialized_name="createdByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.created_by_user_email_address = AAZStrType( + serialized_name="createdByUserEmailAddress", + flags={"read_only": True}, + ) + properties.created_on = AAZStrType( + serialized_name="createdOn", + flags={"read_only": True}, + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + flags={"read_only": True}, + ) + properties.modified_by_principal_id = AAZStrType( + serialized_name="modifiedByPrincipalId", + flags={"read_only": True}, + ) + properties.modified_by_principal_puid = AAZStrType( + serialized_name="modifiedByPrincipalPuid", + flags={"read_only": True}, + ) + properties.modified_by_principal_tenant_id = AAZStrType( + serialized_name="modifiedByPrincipalTenantId", + flags={"read_only": True}, + ) + properties.modified_by_user_email_address = AAZStrType( + serialized_name="modifiedByUserEmailAddress", + flags={"read_only": True}, + ) + properties.modified_on = AAZStrType( + serialized_name="modifiedOn", + flags={"read_only": True}, + ) + properties.principal_display_name = AAZStrType( + serialized_name="principalDisplayName", + flags={"read_only": True}, + ) + properties.principal_id = AAZStrType( + serialized_name="principalId", + ) + properties.principal_puid = AAZStrType( + serialized_name="principalPuid", + ) + properties.principal_tenant_id = AAZStrType( + serialized_name="principalTenantId", + ) + properties.principal_tenant_name = AAZStrType( + serialized_name="principalTenantName", + flags={"read_only": True}, + ) + properties.principal_type = AAZStrType( + serialized_name="principalType", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.role_definition_id = AAZStrType( + serialized_name="roleDefinitionId", + flags={"required": True}, + ) + properties.scope = AAZStrType() + properties.user_authentication_type = AAZStrType( + serialized_name="userAuthenticationType", + ) + properties.user_email_address = AAZStrType( + serialized_name="userEmailAddress", + ) + + system_data = _schema_billing_role_assignment_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_billing_role_assignment_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_billing_role_assignment_read.id + _schema.name = cls._schema_billing_role_assignment_read.name + _schema.properties = cls._schema_billing_role_assignment_read.properties + _schema.system_data = cls._schema_billing_role_assignment_read.system_data + _schema.tags = cls._schema_billing_role_assignment_read.tags + _schema.type = cls._schema_billing_role_assignment_read.type + + +__all__ = ["UpdateByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/__cmd_group.py new file mode 100644 index 00000000000..f69afd454cc --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing role-definition", +) +class __CMDGroup(AAZCommandGroup): + """Get and List operations at the billing profile and billing account scope around role definitions. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/__init__.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/__init__.py new file mode 100644 index 00000000000..4eec5c9b18c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/__init__.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_by_billing_account import * +from ._get_by_billing_profile import * +from ._get_by_customer import * +from ._get_by_department import * +from ._get_by_enrollment_account import * +from ._get_by_invoice_section import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_customer import * +from ._list_by_department import * +from ._list_by_enrollment_account import * +from ._list_by_invoice_section import * diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_billing_account.py new file mode 100644 index 00000000000..e8e7fc39f8b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_billing_account.py @@ -0,0 +1,237 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get the definition for a role on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: BillingRoleDefinitionGetByBillingAccount + az billing role-definition get-by-billing-account --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --role-definition-name 50000000-aaaa-bbbb-cccc-100000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingroledefinitions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.role_definition_name = AAZStrArg( + options=["--role-definition-name"], + help="The ID that uniquely identifies a role definition.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleDefinitionGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{roleDefinitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "roleDefinitionName", self.ctx.args.role_definition_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_billing_profile.py new file mode 100644 index 00000000000..92fcbdfb3d8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_billing_profile.py @@ -0,0 +1,249 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition get-by-billing-profile", +) +class GetByBillingProfile(AAZCommand): + """Get 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. + + :example: BillingRoleDefinitionGetByBillingProfile + az billing role-definition get-by-billing-profile --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --role-definition-name 40000000-aaaa-bbbb-cccc-100000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingroledefinitions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.role_definition_name = AAZStrArg( + options=["--role-definition-name"], + help="The ID that uniquely identifies a role definition.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionGetByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleDefinitionGetByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{roleDefinitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "roleDefinitionName", self.ctx.args.role_definition_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingProfileHelper: + """Helper class for GetByBillingProfile""" + + +__all__ = ["GetByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_customer.py new file mode 100644 index 00000000000..f360559d896 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_customer.py @@ -0,0 +1,261 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition get-by-customer", +) +class GetByCustomer(AAZCommand): + """Get the definition for a role on a customer. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingRoleDefinitionGetByCustomer + az billing role-definition get-by-customer --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 --role-definition-name 30000000-aaaa-bbbb-cccc-100000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingroledefinitions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.role_definition_name = AAZStrArg( + options=["--role-definition-name"], + help="The ID that uniquely identifies a role definition.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionGetByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleDefinitionGetByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleDefinitions/{roleDefinitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + **self.serialize_url_param( + "roleDefinitionName", self.ctx.args.role_definition_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByCustomerHelper: + """Helper class for GetByCustomer""" + + +__all__ = ["GetByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_department.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_department.py new file mode 100644 index 00000000000..f4d7718cab6 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_department.py @@ -0,0 +1,249 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition get-by-department", +) +class GetByDepartment(AAZCommand): + """Get the definition for a role on a department. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleDefinitionGetByDepartment + az billing role-definition get-by-department --billing-account-name 123456 --department-name 7368531 --role-definition-name 50000000-aaaa-bbbb-cccc-100000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingroledefinitions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.role_definition_name = AAZStrArg( + options=["--role-definition-name"], + help="The ID that uniquely identifies a role definition.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionGetByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleDefinitionGetByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleDefinitions/{roleDefinitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + **self.serialize_url_param( + "roleDefinitionName", self.ctx.args.role_definition_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByDepartmentHelper: + """Helper class for GetByDepartment""" + + +__all__ = ["GetByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_enrollment_account.py new file mode 100644 index 00000000000..e46022e82d1 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_enrollment_account.py @@ -0,0 +1,249 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition get-by-enrollment-account", +) +class GetByEnrollmentAccount(AAZCommand): + """Get the definition for a role on an enrollment account. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleDefinitionGetByEnrollmentAccount + az billing role-definition get-by-enrollment-account --billing-account-name 123456 --enrollment-account-name 4568789 --role-definition-name 50000000-aaaa-bbbb-cccc-100000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingroledefinitions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.role_definition_name = AAZStrArg( + options=["--role-definition-name"], + help="The ID that uniquely identifies a role definition.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionGetByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleDefinitionGetByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleDefinitions/{roleDefinitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + **self.serialize_url_param( + "roleDefinitionName", self.ctx.args.role_definition_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByEnrollmentAccountHelper: + """Helper class for GetByEnrollmentAccount""" + + +__all__ = ["GetByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_invoice_section.py new file mode 100644 index 00000000000..c12693e1f05 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_get_by_invoice_section.py @@ -0,0 +1,261 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition get-by-invoice-section", +) +class GetByInvoiceSection(AAZCommand): + """Get the definition for a role on an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: BillingRoleDefinitionGetByInvoiceSection + az billing role-definition get-by-invoice-section --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy --role-definition-name 30000000-aaaa-bbbb-cccc-100000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingroledefinitions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.role_definition_name = AAZStrArg( + options=["--role-definition-name"], + help="The ID that uniquely identifies a role definition.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionGetByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingRoleDefinitionGetByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{roleDefinitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + **self.serialize_url_param( + "roleDefinitionName", self.ctx.args.role_definition_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByInvoiceSectionHelper: + """Helper class for GetByInvoiceSection""" + + +__all__ = ["GetByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_billing_account.py new file mode 100644 index 00000000000..1f280e90ec7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_billing_account.py @@ -0,0 +1,239 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the role definitions for a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: BillingRoleDefinitionListByBillingAccount + az billing role-definition list-by-billing-account --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingroledefinitions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleDefinitionListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.value.Element.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_billing_profile.py new file mode 100644 index 00000000000..b13db23876d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_billing_profile.py @@ -0,0 +1,251 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List the role definitions for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement, Microsoft Customer Agreement or Enterprise Agreement. + + :example: BillingRoleDefinitionListByBillingProfile + az billing role-definition list-by-billing-profile --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingroledefinitions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleDefinitionListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.value.Element.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_customer.py new file mode 100644 index 00000000000..a0d7fba54b8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_customer.py @@ -0,0 +1,263 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition list-by-customer", +) +class ListByCustomer(AAZCommand): + """List the role definitions for a customer. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingRoleDefinitionListByCustomer + az billing role-definition list-by-customer --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingroledefinitions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionListByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleDefinitionListByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingRoleDefinitions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.value.Element.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerHelper: + """Helper class for ListByCustomer""" + + +__all__ = ["ListByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_department.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_department.py new file mode 100644 index 00000000000..b7bd89b017d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_department.py @@ -0,0 +1,251 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition list-by-department", +) +class ListByDepartment(AAZCommand): + """List the definition for a department. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleDefinitionListByDepartment + az billing role-definition list-by-department --billing-account-name 123456 --department-name 7368531 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/departments/{}/billingroledefinitions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.department_name = AAZStrArg( + options=["--department-name"], + help="The name of the department.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionListByDepartment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleDefinitionListByDepartment(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}/billingRoleDefinitions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "departmentName", self.ctx.args.department_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.value.Element.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByDepartmentHelper: + """Helper class for ListByDepartment""" + + +__all__ = ["ListByDepartment"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_enrollment_account.py new file mode 100644 index 00000000000..cacc565b7f8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_enrollment_account.py @@ -0,0 +1,251 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition list-by-enrollment-account", +) +class ListByEnrollmentAccount(AAZCommand): + """List the definition for an enrollment account. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: BillingRoleDefinitionListByEnrollmentAccount + az billing role-definition list-by-enrollment-account --billing-account-name 123456 --enrollment-account-name 4568789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingroledefinitions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionListByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleDefinitionListByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingRoleDefinitions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.value.Element.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByEnrollmentAccountHelper: + """Helper class for ListByEnrollmentAccount""" + + +__all__ = ["ListByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_invoice_section.py new file mode 100644 index 00000000000..2f8df21402d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/role_definition/_list_by_invoice_section.py @@ -0,0 +1,263 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing role-definition list-by-invoice-section", +) +class ListByInvoiceSection(AAZCommand): + """List the role definitions for an invoice section. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: BillingRoleDefinitionListByInvoiceSection + az billing role-definition list-by-invoice-section --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingroledefinitions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingRoleDefinitionListByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingRoleDefinitionListByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType( + flags={"read_only": True}, + ) + properties.permissions = AAZListType( + flags={"read_only": True}, + ) + properties.role_name = AAZStrType( + serialized_name="roleName", + flags={"required": True}, + ) + + permissions = cls._schema_on_200.value.Element.properties.permissions + permissions.Element = AAZObjectType( + flags={"read_only": True}, + ) + + _element = cls._schema_on_200.value.Element.properties.permissions.Element + _element.actions = AAZListType( + flags={"read_only": True}, + ) + _element.not_actions = AAZListType( + serialized_name="notActions", + flags={"read_only": True}, + ) + + actions = cls._schema_on_200.value.Element.properties.permissions.Element.actions + actions.Element = AAZStrType() + + not_actions = cls._schema_on_200.value.Element.properties.permissions.Element.not_actions + not_actions.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceSectionHelper: + """Helper class for ListByInvoiceSection""" + + +__all__ = ["ListByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/__cmd_group.py new file mode 100644 index 00000000000..196c45d4f1e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing savings-plan", +) +class __CMDGroup(AAZCommandGroup): + """Get, List and Update operations around Savings Plan at different scopes + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/__init__.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/__init__.py new file mode 100644 index 00000000000..9a50482ca75 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/__init__.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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_by_billing_account import * +from ._list_by_billing_account import * +from ._list_by_savings_plan_order import * +from ._update_by_billing_account import * +from ._validate_update_by_billing_account import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_get_by_billing_account.py new file mode 100644 index 00000000000..c1963e6a5eb --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_get_by_billing_account.py @@ -0,0 +1,453 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get savings plan by billing account. + + :example: SavingsPlanGet + az billing savings-plan get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --savings-plan-order-id 20000000-0000-0000-0000-000000000000 --savings-plan-id 30000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplanorders/{}/savingsplans/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.savings_plan_id = AAZStrArg( + options=["--savings-plan-id"], + help="ID of the savings plan", + required=True, + ) + _args_schema.savings_plan_order_id = AAZStrArg( + options=["--savings-plan-order-id"], + help="Order ID of the savings plan", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the planInformation.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SavingsPlansGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class SavingsPlansGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "savingsPlanId", self.ctx.args.savings_plan_id, + required=True, + ), + **self.serialize_url_param( + "savingsPlanOrderId", self.ctx.args.savings_plan_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType( + flags={"required": True}, + ) + _GetByBillingAccountHelper._build_schema_sku_read(_schema_on_200.sku) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _GetByBillingAccountHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _GetByBillingAccountHelper._build_schema_commitment_read(properties.commitment) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + flags={"read_only": True}, + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + flags={"read_only": True}, + ) + properties.renew = AAZBoolType() + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + ) + properties.term = AAZStrType() + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + renew_properties = cls._schema_on_200.properties.renew_properties + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.properties.renew_properties.purchase_properties + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + _GetByBillingAccountHelper._build_schema_sku_read(purchase_properties.sku) + + properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _GetByBillingAccountHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _GetByBillingAccountHelper._build_schema_commitment_read(properties.commitment) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.renew = AAZBoolType() + properties.term = AAZStrType() + + utilization = cls._schema_on_200.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + _schema_applied_scope_properties_read = None + + @classmethod + def _build_schema_applied_scope_properties_read(cls, _schema): + if cls._schema_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + return + + cls._schema_applied_scope_properties_read = _schema_applied_scope_properties_read = AAZObjectType() + + applied_scope_properties_read = _schema_applied_scope_properties_read + applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + + _schema_commitment_read = None + + @classmethod + def _build_schema_commitment_read(cls, _schema): + if cls._schema_commitment_read is not None: + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + return + + cls._schema_commitment_read = _schema_commitment_read = AAZObjectType() + + commitment_read = _schema_commitment_read + commitment_read.amount = AAZFloatType() + commitment_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + commitment_read.grain = AAZStrType() + + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + + _schema_sku_read = None + + @classmethod + def _build_schema_sku_read(cls, _schema): + if cls._schema_sku_read is not None: + _schema.name = cls._schema_sku_read.name + return + + cls._schema_sku_read = _schema_sku_read = AAZObjectType() + + sku_read = _schema_sku_read + sku_read.name = AAZStrType() + + _schema.name = cls._schema_sku_read.name + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_list_by_billing_account.py new file mode 100644 index 00000000000..8f4d59a39f4 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_list_by_billing_account.py @@ -0,0 +1,520 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List savings plans by billing account. + + :example: SavingsPlansList + az billing savings-plan list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --take 3 --selected-state Succeeded --refresh-summary true + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplans", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.refresh_summary = AAZStrArg( + options=["--refresh-summary"], + help="To indicate whether to refresh the roll up counts of the savings plans group by provisioning states", + ) + _args_schema.selected_state = AAZStrArg( + options=["--selected-state"], + help="The selected provisioning state", + ) + _args_schema.skiptoken = AAZFloatArg( + options=["--skiptoken"], + help="The number of savings plans to skip from the list before returning results", + ) + _args_schema.take = AAZFloatArg( + options=["--take"], + help="The number of savings plans to return", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SavingsPlansListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class SavingsPlansListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlans", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "refreshSummary", self.ctx.args.refresh_summary, + ), + **self.serialize_query_param( + "selectedState", self.ctx.args.selected_state, + ), + **self.serialize_query_param( + "skiptoken", self.ctx.args.skiptoken, + ), + **self.serialize_query_param( + "take", self.ctx.args.take, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.summary = AAZObjectType() + _schema_on_200.value = AAZListType() + + summary = cls._schema_on_200.summary + summary.cancelled_count = AAZFloatType( + serialized_name="cancelledCount", + flags={"read_only": True}, + ) + summary.expired_count = AAZFloatType( + serialized_name="expiredCount", + flags={"read_only": True}, + ) + summary.expiring_count = AAZFloatType( + serialized_name="expiringCount", + flags={"read_only": True}, + ) + summary.failed_count = AAZFloatType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + summary.no_benefit_count = AAZFloatType( + serialized_name="noBenefitCount", + flags={"read_only": True}, + ) + summary.pending_count = AAZFloatType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + summary.processing_count = AAZFloatType( + serialized_name="processingCount", + flags={"read_only": True}, + ) + summary.succeeded_count = AAZFloatType( + serialized_name="succeededCount", + flags={"read_only": True}, + ) + summary.warning_count = AAZFloatType( + serialized_name="warningCount", + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType( + flags={"required": True}, + ) + _ListByBillingAccountHelper._build_schema_sku_read(_element.sku) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingAccountHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _ListByBillingAccountHelper._build_schema_commitment_read(properties.commitment) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + flags={"read_only": True}, + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + flags={"read_only": True}, + ) + properties.renew = AAZBoolType() + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + ) + properties.term = AAZStrType() + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.value.Element.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.value.Element.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + renew_properties = cls._schema_on_200.value.Element.properties.renew_properties + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + _ListByBillingAccountHelper._build_schema_sku_read(purchase_properties.sku) + + properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListByBillingAccountHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _ListByBillingAccountHelper._build_schema_commitment_read(properties.commitment) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.renew = AAZBoolType() + properties.term = AAZStrType() + + utilization = cls._schema_on_200.value.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + _schema_applied_scope_properties_read = None + + @classmethod + def _build_schema_applied_scope_properties_read(cls, _schema): + if cls._schema_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + return + + cls._schema_applied_scope_properties_read = _schema_applied_scope_properties_read = AAZObjectType() + + applied_scope_properties_read = _schema_applied_scope_properties_read + applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + + _schema_commitment_read = None + + @classmethod + def _build_schema_commitment_read(cls, _schema): + if cls._schema_commitment_read is not None: + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + return + + cls._schema_commitment_read = _schema_commitment_read = AAZObjectType() + + commitment_read = _schema_commitment_read + commitment_read.amount = AAZFloatType() + commitment_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + commitment_read.grain = AAZStrType() + + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + + _schema_sku_read = None + + @classmethod + def _build_schema_sku_read(cls, _schema): + if cls._schema_sku_read is not None: + _schema.name = cls._schema_sku_read.name + return + + cls._schema_sku_read = _schema_sku_read = AAZObjectType() + + sku_read = _schema_sku_read + sku_read.name = AAZStrType() + + _schema.name = cls._schema_sku_read.name + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/_list_by_savings_plan_order.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_list_by_savings_plan_order.py new file mode 100644 index 00000000000..fe882b0ee45 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_list_by_savings_plan_order.py @@ -0,0 +1,448 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan list-by-savings-plan-order", +) +class ListBySavingsPlanOrder(AAZCommand): + """List savings plans in an order by billing account. + + :example: SavingsPlansInOrderList + az billing savings-plan list-by-savings-plan-order --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --savings-plan-order-id 20000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplanorders/{}/savingsplans", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.savings_plan_order_id = AAZStrArg( + options=["--savings-plan-order-id"], + help="Order ID of the savings plan", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SavingsPlansListBySavingsPlanOrder(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class SavingsPlansListBySavingsPlanOrder(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "savingsPlanOrderId", self.ctx.args.savings_plan_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType( + flags={"required": True}, + ) + _ListBySavingsPlanOrderHelper._build_schema_sku_read(_element.sku) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListBySavingsPlanOrderHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _ListBySavingsPlanOrderHelper._build_schema_commitment_read(properties.commitment) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + flags={"read_only": True}, + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + flags={"read_only": True}, + ) + properties.renew = AAZBoolType() + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + ) + properties.term = AAZStrType() + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.value.Element.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.value.Element.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + renew_properties = cls._schema_on_200.value.Element.properties.renew_properties + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + _ListBySavingsPlanOrderHelper._build_schema_sku_read(purchase_properties.sku) + + properties = cls._schema_on_200.value.Element.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _ListBySavingsPlanOrderHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _ListBySavingsPlanOrderHelper._build_schema_commitment_read(properties.commitment) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.renew = AAZBoolType() + properties.term = AAZStrType() + + utilization = cls._schema_on_200.value.Element.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.value.Element.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListBySavingsPlanOrderHelper: + """Helper class for ListBySavingsPlanOrder""" + + _schema_applied_scope_properties_read = None + + @classmethod + def _build_schema_applied_scope_properties_read(cls, _schema): + if cls._schema_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + return + + cls._schema_applied_scope_properties_read = _schema_applied_scope_properties_read = AAZObjectType() + + applied_scope_properties_read = _schema_applied_scope_properties_read + applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + + _schema_commitment_read = None + + @classmethod + def _build_schema_commitment_read(cls, _schema): + if cls._schema_commitment_read is not None: + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + return + + cls._schema_commitment_read = _schema_commitment_read = AAZObjectType() + + commitment_read = _schema_commitment_read + commitment_read.amount = AAZFloatType() + commitment_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + commitment_read.grain = AAZStrType() + + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + + _schema_sku_read = None + + @classmethod + def _build_schema_sku_read(cls, _schema): + if cls._schema_sku_read is not None: + _schema.name = cls._schema_sku_read.name + return + + cls._schema_sku_read = _schema_sku_read = AAZObjectType() + + sku_read = _schema_sku_read + sku_read.name = AAZStrType() + + _schema.name = cls._schema_sku_read.name + + +__all__ = ["ListBySavingsPlanOrder"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/_update_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_update_by_billing_account.py new file mode 100644 index 00000000000..1a39a1d94ff --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_update_by_billing_account.py @@ -0,0 +1,702 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan update-by-billing-account", +) +class UpdateByBillingAccount(AAZCommand): + """Update savings plan by billing account. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplanorders/{}/savingsplans/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.savings_plan_id = AAZStrArg( + options=["--savings-plan-id"], + help="ID of the savings plan", + required=True, + ) + _args_schema.savings_plan_order_id = AAZStrArg( + options=["--savings-plan-order-id"], + help="Order ID of the savings plan", + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.sku = AAZObjectArg( + options=["--sku"], + arg_group="Body", + ) + cls._build_args_sku_update(_args_schema.sku) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Body", + help="Tags for this reservation", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.applied_scope_properties = AAZObjectArg( + options=["--applied-scope-properties"], + arg_group="Properties", + help="Properties specific to applied scope type. Not required if not applicable.", + ) + cls._build_args_applied_scope_properties_update(_args_schema.applied_scope_properties) + _args_schema.applied_scope_type = AAZStrArg( + options=["--applied-scope-type"], + arg_group="Properties", + help="Type of the Applied Scope.", + enum={"ManagementGroup": "ManagementGroup", "Shared": "Shared", "Single": "Single"}, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="Display name", + ) + _args_schema.renew = AAZBoolArg( + options=["--renew"], + arg_group="Properties", + help="Setting this to true will automatically purchase a new benefit on the expiration date time.", + default=False, + ) + _args_schema.renew_properties = AAZObjectArg( + options=["--renew-properties"], + arg_group="Properties", + help="Properties specific to renew.", + ) + + renew_properties = cls._args_schema.renew_properties + renew_properties.purchase_properties = AAZObjectArg( + options=["purchase-properties"], + help="Purchase request.", + ) + + purchase_properties = cls._args_schema.renew_properties.purchase_properties + purchase_properties.applied_scope_properties = AAZObjectArg( + options=["applied-scope-properties"], + ) + cls._build_args_applied_scope_properties_update(purchase_properties.applied_scope_properties) + purchase_properties.applied_scope_type = AAZStrArg( + options=["applied-scope-type"], + help="Type of the Applied Scope.", + enum={"ManagementGroup": "ManagementGroup", "Shared": "Shared", "Single": "Single"}, + ) + purchase_properties.billing_plan = AAZStrArg( + options=["billing-plan"], + help="Represents the billing plan in ISO 8601 format. Required only for monthly purchases.", + enum={"P1M": "P1M"}, + ) + purchase_properties.billing_scope_id = AAZStrArg( + options=["billing-scope-id"], + help="Subscription that will be charged for purchasing SavingsPlan", + ) + purchase_properties.commitment = AAZObjectArg( + options=["commitment"], + help="Commitment towards the benefit.", + ) + purchase_properties.display_name = AAZStrArg( + options=["display-name"], + help="Friendly name of the savings plan", + ) + purchase_properties.renew = AAZBoolArg( + options=["renew"], + help="Setting this to true will automatically purchase a new benefit on the expiration date time.", + default=False, + ) + purchase_properties.term = AAZStrArg( + options=["term"], + help="Represents the Savings plan term in ISO 8601 format.", + enum={"P1Y": "P1Y", "P3Y": "P3Y", "P5Y": "P5Y"}, + ) + purchase_properties.sku = AAZObjectArg( + options=["sku"], + help="The SKU to be applied for this resource", + ) + cls._build_args_sku_update(purchase_properties.sku) + + commitment = cls._args_schema.renew_properties.purchase_properties.commitment + commitment.amount = AAZFloatArg( + options=["amount"], + ) + commitment.currency_code = AAZStrArg( + options=["currency-code"], + help="The ISO 4217 3-letter currency code for the currency used by this purchase record.", + ) + commitment.grain = AAZStrArg( + options=["grain"], + help="Commitment grain.", + enum={"Hourly": "Hourly"}, + ) + return cls._args_schema + + _args_applied_scope_properties_update = None + + @classmethod + def _build_args_applied_scope_properties_update(cls, _schema): + if cls._args_applied_scope_properties_update is not None: + _schema.display_name = cls._args_applied_scope_properties_update.display_name + _schema.management_group_id = cls._args_applied_scope_properties_update.management_group_id + _schema.resource_group_id = cls._args_applied_scope_properties_update.resource_group_id + _schema.subscription_id = cls._args_applied_scope_properties_update.subscription_id + _schema.tenant_id = cls._args_applied_scope_properties_update.tenant_id + return + + cls._args_applied_scope_properties_update = AAZObjectArg() + + applied_scope_properties_update = cls._args_applied_scope_properties_update + applied_scope_properties_update.display_name = AAZStrArg( + options=["display-name"], + help="Display name", + ) + applied_scope_properties_update.management_group_id = AAZStrArg( + options=["management-group-id"], + help="Fully-qualified identifier of the management group where the benefit is applied.", + ) + applied_scope_properties_update.resource_group_id = AAZStrArg( + options=["resource-group-id"], + help="Fully-qualified identifier of the resource group where the benefit is applied.", + ) + applied_scope_properties_update.subscription_id = AAZStrArg( + options=["subscription-id"], + help="Fully-qualified identifier of the subscription where the benefit is applied.", + ) + applied_scope_properties_update.tenant_id = AAZStrArg( + options=["tenant-id"], + help="Tenant ID where the savings plan where the benefit is applied.", + ) + + _schema.display_name = cls._args_applied_scope_properties_update.display_name + _schema.management_group_id = cls._args_applied_scope_properties_update.management_group_id + _schema.resource_group_id = cls._args_applied_scope_properties_update.resource_group_id + _schema.subscription_id = cls._args_applied_scope_properties_update.subscription_id + _schema.tenant_id = cls._args_applied_scope_properties_update.tenant_id + + _args_sku_update = None + + @classmethod + def _build_args_sku_update(cls, _schema): + if cls._args_sku_update is not None: + _schema.name = cls._args_sku_update.name + return + + cls._args_sku_update = AAZObjectArg() + + sku_update = cls._args_sku_update + sku_update.name = AAZStrArg( + options=["name"], + help="Name of the SKU to be applied", + ) + + _schema.name = cls._args_sku_update.name + + def _execute_operations(self): + self.pre_operations() + yield self.SavingsPlansUpdateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class SavingsPlansUpdateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "savingsPlanId", self.ctx.args.savings_plan_id, + required=True, + ), + **self.serialize_url_param( + "savingsPlanOrderId", self.ctx.args.savings_plan_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + _UpdateByBillingAccountHelper._build_schema_sku_update(_builder.set_prop("sku", AAZObjectType, ".sku")) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + _UpdateByBillingAccountHelper._build_schema_applied_scope_properties_update(properties.set_prop("appliedScopeProperties", AAZObjectType, ".applied_scope_properties")) + properties.set_prop("appliedScopeType", AAZStrType, ".applied_scope_type") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("renew", AAZBoolType, ".renew") + properties.set_prop("renewProperties", AAZObjectType, ".renew_properties") + + renew_properties = _builder.get(".properties.renewProperties") + if renew_properties is not None: + renew_properties.set_prop("purchaseProperties", AAZObjectType, ".purchase_properties") + + purchase_properties = _builder.get(".properties.renewProperties.purchaseProperties") + if purchase_properties is not None: + purchase_properties.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _UpdateByBillingAccountHelper._build_schema_sku_update(purchase_properties.set_prop("sku", AAZObjectType, ".sku")) + + properties = _builder.get(".properties.renewProperties.purchaseProperties.properties") + if properties is not None: + _UpdateByBillingAccountHelper._build_schema_applied_scope_properties_update(properties.set_prop("appliedScopeProperties", AAZObjectType, ".applied_scope_properties")) + properties.set_prop("appliedScopeType", AAZStrType, ".applied_scope_type") + properties.set_prop("billingPlan", AAZStrType, ".billing_plan") + properties.set_prop("billingScopeId", AAZStrType, ".billing_scope_id") + properties.set_prop("commitment", AAZObjectType, ".commitment") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("renew", AAZBoolType, ".renew") + properties.set_prop("term", AAZStrType, ".term") + + commitment = _builder.get(".properties.renewProperties.purchaseProperties.properties.commitment") + if commitment is not None: + commitment.set_prop("amount", AAZFloatType, ".amount") + commitment.set_prop("currencyCode", AAZStrType, ".currency_code") + commitment.set_prop("grain", AAZStrType, ".grain") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType( + flags={"required": True}, + ) + _UpdateByBillingAccountHelper._build_schema_sku_read(_schema_on_200.sku) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _UpdateByBillingAccountHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _UpdateByBillingAccountHelper._build_schema_commitment_read(properties.commitment) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + flags={"read_only": True}, + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + flags={"read_only": True}, + ) + properties.renew = AAZBoolType() + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + ) + properties.term = AAZStrType() + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + renew_properties = cls._schema_on_200.properties.renew_properties + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.properties.renew_properties.purchase_properties + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + _UpdateByBillingAccountHelper._build_schema_sku_read(purchase_properties.sku) + + properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _UpdateByBillingAccountHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _UpdateByBillingAccountHelper._build_schema_commitment_read(properties.commitment) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.renew = AAZBoolType() + properties.term = AAZStrType() + + utilization = cls._schema_on_200.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateByBillingAccountHelper: + """Helper class for UpdateByBillingAccount""" + + @classmethod + def _build_schema_applied_scope_properties_update(cls, _builder): + if _builder is None: + return + _builder.set_prop("displayName", AAZStrType, ".display_name") + _builder.set_prop("managementGroupId", AAZStrType, ".management_group_id") + _builder.set_prop("resourceGroupId", AAZStrType, ".resource_group_id") + _builder.set_prop("subscriptionId", AAZStrType, ".subscription_id") + _builder.set_prop("tenantId", AAZStrType, ".tenant_id") + + @classmethod + def _build_schema_sku_update(cls, _builder): + if _builder is None: + return + _builder.set_prop("name", AAZStrType, ".name") + + _schema_applied_scope_properties_read = None + + @classmethod + def _build_schema_applied_scope_properties_read(cls, _schema): + if cls._schema_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + return + + cls._schema_applied_scope_properties_read = _schema_applied_scope_properties_read = AAZObjectType() + + applied_scope_properties_read = _schema_applied_scope_properties_read + applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + + _schema_commitment_read = None + + @classmethod + def _build_schema_commitment_read(cls, _schema): + if cls._schema_commitment_read is not None: + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + return + + cls._schema_commitment_read = _schema_commitment_read = AAZObjectType() + + commitment_read = _schema_commitment_read + commitment_read.amount = AAZFloatType() + commitment_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + commitment_read.grain = AAZStrType() + + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + + _schema_sku_read = None + + @classmethod + def _build_schema_sku_read(cls, _schema): + if cls._schema_sku_read is not None: + _schema.name = cls._schema_sku_read.name + return + + cls._schema_sku_read = _schema_sku_read = AAZObjectType() + + sku_read = _schema_sku_read + sku_read.name = AAZStrType() + + _schema.name = cls._schema_sku_read.name + + +__all__ = ["UpdateByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/_validate_update_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_validate_update_by_billing_account.py new file mode 100644 index 00000000000..bf7681789d0 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_validate_update_by_billing_account.py @@ -0,0 +1,400 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan validate-update-by-billing-account", +) +class ValidateUpdateByBillingAccount(AAZCommand): + """Validate savings plan patch by billing account. + + :example: SavingsPlanValidateUpdate + az billing savings-plan validate-update-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --savings-plan-order-id 20000000-0000-0000-0000-000000000000 --savings-plan-id 30000000-0000-0000-0000-000000000000 --benefits "[{applied-scope-type:Single,applied-scope-properties:{subscriptionId:/subscriptions/50000000-0000-0000-0000-000000000000}}]" + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplanorders/{}/savingsplans/{}/validate", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.savings_plan_id = AAZStrArg( + options=["--savings-plan-id"], + help="ID of the savings plan", + required=True, + ) + _args_schema.savings_plan_order_id = AAZStrArg( + options=["--savings-plan-order-id"], + help="Order ID of the savings plan", + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.benefits = AAZListArg( + options=["--benefits"], + arg_group="Body", + help="The benefits of a savings plan.", + ) + + benefits = cls._args_schema.benefits + benefits.Element = AAZObjectArg() + + _element = cls._args_schema.benefits.Element + _element.applied_scope_properties = AAZObjectArg( + options=["applied-scope-properties"], + help="Properties specific to applied scope type. Not required if not applicable.", + ) + cls._build_args_applied_scope_properties_create(_element.applied_scope_properties) + _element.applied_scope_type = AAZStrArg( + options=["applied-scope-type"], + help="Type of the Applied Scope.", + enum={"ManagementGroup": "ManagementGroup", "Shared": "Shared", "Single": "Single"}, + ) + _element.display_name = AAZStrArg( + options=["display-name"], + help="Display name", + ) + _element.renew = AAZBoolArg( + options=["renew"], + help="Setting this to true will automatically purchase a new benefit on the expiration date time.", + default=False, + ) + _element.renew_properties = AAZObjectArg( + options=["renew-properties"], + help="Properties specific to renew.", + ) + + renew_properties = cls._args_schema.benefits.Element.renew_properties + renew_properties.purchase_properties = AAZObjectArg( + options=["purchase-properties"], + help="Purchase request.", + ) + + purchase_properties = cls._args_schema.benefits.Element.renew_properties.purchase_properties + purchase_properties.applied_scope_properties = AAZObjectArg( + options=["applied-scope-properties"], + ) + cls._build_args_applied_scope_properties_create(purchase_properties.applied_scope_properties) + purchase_properties.applied_scope_type = AAZStrArg( + options=["applied-scope-type"], + help="Type of the Applied Scope.", + enum={"ManagementGroup": "ManagementGroup", "Shared": "Shared", "Single": "Single"}, + ) + purchase_properties.billing_plan = AAZStrArg( + options=["billing-plan"], + help="Represents the billing plan in ISO 8601 format. Required only for monthly purchases.", + enum={"P1M": "P1M"}, + ) + purchase_properties.billing_scope_id = AAZStrArg( + options=["billing-scope-id"], + help="Subscription that will be charged for purchasing SavingsPlan", + ) + purchase_properties.commitment = AAZObjectArg( + options=["commitment"], + help="Commitment towards the benefit.", + ) + purchase_properties.display_name = AAZStrArg( + options=["display-name"], + help="Friendly name of the savings plan", + ) + purchase_properties.renew = AAZBoolArg( + options=["renew"], + help="Setting this to true will automatically purchase a new benefit on the expiration date time.", + default=False, + ) + purchase_properties.term = AAZStrArg( + options=["term"], + help="Represents the Savings plan term in ISO 8601 format.", + enum={"P1Y": "P1Y", "P3Y": "P3Y", "P5Y": "P5Y"}, + ) + purchase_properties.sku = AAZObjectArg( + options=["sku"], + help="The SKU to be applied for this resource", + ) + + commitment = cls._args_schema.benefits.Element.renew_properties.purchase_properties.commitment + commitment.amount = AAZFloatArg( + options=["amount"], + ) + commitment.currency_code = AAZStrArg( + options=["currency-code"], + help="The ISO 4217 3-letter currency code for the currency used by this purchase record.", + ) + commitment.grain = AAZStrArg( + options=["grain"], + help="Commitment grain.", + enum={"Hourly": "Hourly"}, + ) + + sku = cls._args_schema.benefits.Element.renew_properties.purchase_properties.sku + sku.name = AAZStrArg( + options=["name"], + help="Name of the SKU to be applied", + ) + return cls._args_schema + + _args_applied_scope_properties_create = None + + @classmethod + def _build_args_applied_scope_properties_create(cls, _schema): + if cls._args_applied_scope_properties_create is not None: + _schema.display_name = cls._args_applied_scope_properties_create.display_name + _schema.management_group_id = cls._args_applied_scope_properties_create.management_group_id + _schema.resource_group_id = cls._args_applied_scope_properties_create.resource_group_id + _schema.subscription_id = cls._args_applied_scope_properties_create.subscription_id + _schema.tenant_id = cls._args_applied_scope_properties_create.tenant_id + return + + cls._args_applied_scope_properties_create = AAZObjectArg() + + applied_scope_properties_create = cls._args_applied_scope_properties_create + applied_scope_properties_create.display_name = AAZStrArg( + options=["display-name"], + help="Display name", + ) + applied_scope_properties_create.management_group_id = AAZStrArg( + options=["management-group-id"], + help="Fully-qualified identifier of the management group where the benefit is applied.", + ) + applied_scope_properties_create.resource_group_id = AAZStrArg( + options=["resource-group-id"], + help="Fully-qualified identifier of the resource group where the benefit is applied.", + ) + applied_scope_properties_create.subscription_id = AAZStrArg( + options=["subscription-id"], + help="Fully-qualified identifier of the subscription where the benefit is applied.", + ) + applied_scope_properties_create.tenant_id = AAZStrArg( + options=["tenant-id"], + help="Tenant ID where the savings plan where the benefit is applied.", + ) + + _schema.display_name = cls._args_applied_scope_properties_create.display_name + _schema.management_group_id = cls._args_applied_scope_properties_create.management_group_id + _schema.resource_group_id = cls._args_applied_scope_properties_create.resource_group_id + _schema.subscription_id = cls._args_applied_scope_properties_create.subscription_id + _schema.tenant_id = cls._args_applied_scope_properties_create.tenant_id + + def _execute_operations(self): + self.pre_operations() + self.SavingsPlansValidateUpdateByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class SavingsPlansValidateUpdateByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/validate", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "savingsPlanId", self.ctx.args.savings_plan_id, + required=True, + ), + **self.serialize_url_param( + "savingsPlanOrderId", self.ctx.args.savings_plan_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("benefits", AAZListType, ".benefits") + + benefits = _builder.get(".benefits") + if benefits is not None: + benefits.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".benefits[]") + if _elements is not None: + _ValidateUpdateByBillingAccountHelper._build_schema_applied_scope_properties_create(_elements.set_prop("appliedScopeProperties", AAZObjectType, ".applied_scope_properties")) + _elements.set_prop("appliedScopeType", AAZStrType, ".applied_scope_type") + _elements.set_prop("displayName", AAZStrType, ".display_name") + _elements.set_prop("renew", AAZBoolType, ".renew") + _elements.set_prop("renewProperties", AAZObjectType, ".renew_properties") + + renew_properties = _builder.get(".benefits[].renewProperties") + if renew_properties is not None: + renew_properties.set_prop("purchaseProperties", AAZObjectType, ".purchase_properties") + + purchase_properties = _builder.get(".benefits[].renewProperties.purchaseProperties") + if purchase_properties is not None: + purchase_properties.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + purchase_properties.set_prop("sku", AAZObjectType, ".sku") + + properties = _builder.get(".benefits[].renewProperties.purchaseProperties.properties") + if properties is not None: + _ValidateUpdateByBillingAccountHelper._build_schema_applied_scope_properties_create(properties.set_prop("appliedScopeProperties", AAZObjectType, ".applied_scope_properties")) + properties.set_prop("appliedScopeType", AAZStrType, ".applied_scope_type") + properties.set_prop("billingPlan", AAZStrType, ".billing_plan") + properties.set_prop("billingScopeId", AAZStrType, ".billing_scope_id") + properties.set_prop("commitment", AAZObjectType, ".commitment") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("renew", AAZBoolType, ".renew") + properties.set_prop("term", AAZStrType, ".term") + + commitment = _builder.get(".benefits[].renewProperties.purchaseProperties.properties.commitment") + if commitment is not None: + commitment.set_prop("amount", AAZFloatType, ".amount") + commitment.set_prop("currencyCode", AAZStrType, ".currency_code") + commitment.set_prop("grain", AAZStrType, ".grain") + + sku = _builder.get(".benefits[].renewProperties.purchaseProperties.sku") + if sku is not None: + sku.set_prop("name", AAZStrType, ".name") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.benefits = AAZListType() + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + + benefits = cls._schema_on_200.benefits + benefits.Element = AAZObjectType() + + _element = cls._schema_on_200.benefits.Element + _element.reason = AAZStrType() + _element.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + _element.valid = AAZBoolType() + + return cls._schema_on_200 + + +class _ValidateUpdateByBillingAccountHelper: + """Helper class for ValidateUpdateByBillingAccount""" + + @classmethod + def _build_schema_applied_scope_properties_create(cls, _builder): + if _builder is None: + return + _builder.set_prop("displayName", AAZStrType, ".display_name") + _builder.set_prop("managementGroupId", AAZStrType, ".management_group_id") + _builder.set_prop("resourceGroupId", AAZStrType, ".resource_group_id") + _builder.set_prop("subscriptionId", AAZStrType, ".subscription_id") + _builder.set_prop("tenantId", AAZStrType, ".tenant_id") + + +__all__ = ["ValidateUpdateByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan/_wait.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_wait.py new file mode 100644 index 00000000000..184917d8e79 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan/_wait.py @@ -0,0 +1,449 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplanorders/{}/savingsplans/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.savings_plan_id = AAZStrArg( + options=["--savings-plan-id"], + help="ID of the savings plan", + required=True, + ) + _args_schema.savings_plan_order_id = AAZStrArg( + options=["--savings-plan-order-id"], + help="Order ID of the savings plan", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the planInformation.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SavingsPlansGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class SavingsPlansGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "savingsPlanId", self.ctx.args.savings_plan_id, + required=True, + ), + **self.serialize_url_param( + "savingsPlanOrderId", self.ctx.args.savings_plan_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType( + flags={"required": True}, + ) + _WaitHelper._build_schema_sku_read(_schema_on_200.sku) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _WaitHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _WaitHelper._build_schema_commitment_read(properties.commitment) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.display_provisioning_state = AAZStrType( + serialized_name="displayProvisioningState", + flags={"read_only": True}, + ) + properties.effective_date_time = AAZStrType( + serialized_name="effectiveDateTime", + flags={"read_only": True}, + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + flags={"read_only": True}, + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.purchase_date_time = AAZStrType( + serialized_name="purchaseDateTime", + flags={"read_only": True}, + ) + properties.renew = AAZBoolType() + properties.renew_destination = AAZStrType( + serialized_name="renewDestination", + ) + properties.renew_properties = AAZObjectType( + serialized_name="renewProperties", + ) + properties.renew_source = AAZStrType( + serialized_name="renewSource", + ) + properties.term = AAZStrType() + properties.user_friendly_applied_scope_type = AAZStrType( + serialized_name="userFriendlyAppliedScopeType", + flags={"read_only": True}, + ) + properties.utilization = AAZObjectType( + flags={"read_only": True}, + ) + + extended_status_info = cls._schema_on_200.properties.extended_status_info + extended_status_info.message = AAZStrType() + extended_status_info.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + extended_status_info.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = cls._schema_on_200.properties.extended_status_info.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + renew_properties = cls._schema_on_200.properties.renew_properties + renew_properties.purchase_properties = AAZObjectType( + serialized_name="purchaseProperties", + ) + + purchase_properties = cls._schema_on_200.properties.renew_properties.purchase_properties + purchase_properties.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + purchase_properties.sku = AAZObjectType() + _WaitHelper._build_schema_sku_read(purchase_properties.sku) + + properties = cls._schema_on_200.properties.renew_properties.purchase_properties.properties + properties.applied_scope_properties = AAZObjectType( + serialized_name="appliedScopeProperties", + ) + _WaitHelper._build_schema_applied_scope_properties_read(properties.applied_scope_properties) + properties.applied_scope_type = AAZStrType( + serialized_name="appliedScopeType", + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.commitment = AAZObjectType() + _WaitHelper._build_schema_commitment_read(properties.commitment) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.renew = AAZBoolType() + properties.term = AAZStrType() + + utilization = cls._schema_on_200.properties.utilization + utilization.aggregates = AAZListType() + utilization.trend = AAZStrType( + flags={"read_only": True}, + ) + + aggregates = cls._schema_on_200.properties.utilization.aggregates + aggregates.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.utilization.aggregates.Element + _element.grain = AAZFloatType( + flags={"read_only": True}, + ) + _element.grain_unit = AAZStrType( + serialized_name="grainUnit", + flags={"read_only": True}, + ) + _element.value = AAZFloatType( + flags={"read_only": True}, + ) + _element.value_unit = AAZStrType( + serialized_name="valueUnit", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_applied_scope_properties_read = None + + @classmethod + def _build_schema_applied_scope_properties_read(cls, _schema): + if cls._schema_applied_scope_properties_read is not None: + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + return + + cls._schema_applied_scope_properties_read = _schema_applied_scope_properties_read = AAZObjectType() + + applied_scope_properties_read = _schema_applied_scope_properties_read + applied_scope_properties_read.display_name = AAZStrType( + serialized_name="displayName", + ) + applied_scope_properties_read.management_group_id = AAZStrType( + serialized_name="managementGroupId", + ) + applied_scope_properties_read.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + ) + applied_scope_properties_read.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + applied_scope_properties_read.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + _schema.display_name = cls._schema_applied_scope_properties_read.display_name + _schema.management_group_id = cls._schema_applied_scope_properties_read.management_group_id + _schema.resource_group_id = cls._schema_applied_scope_properties_read.resource_group_id + _schema.subscription_id = cls._schema_applied_scope_properties_read.subscription_id + _schema.tenant_id = cls._schema_applied_scope_properties_read.tenant_id + + _schema_commitment_read = None + + @classmethod + def _build_schema_commitment_read(cls, _schema): + if cls._schema_commitment_read is not None: + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + return + + cls._schema_commitment_read = _schema_commitment_read = AAZObjectType() + + commitment_read = _schema_commitment_read + commitment_read.amount = AAZFloatType() + commitment_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + commitment_read.grain = AAZStrType() + + _schema.amount = cls._schema_commitment_read.amount + _schema.currency_code = cls._schema_commitment_read.currency_code + _schema.grain = cls._schema_commitment_read.grain + + _schema_sku_read = None + + @classmethod + def _build_schema_sku_read(cls, _schema): + if cls._schema_sku_read is not None: + _schema.name = cls._schema_sku_read.name + return + + cls._schema_sku_read = _schema_sku_read = AAZObjectType() + + sku_read = _schema_sku_read + sku_read.name = AAZStrType() + + _schema.name = cls._schema_sku_read.name + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/__cmd_group.py new file mode 100644 index 00000000000..9155c75fca8 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing savings-plan-order", +) +class __CMDGroup(AAZCommandGroup): + """Get and List operations for Savings Plan Order + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/__init__.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/__init__.py new file mode 100644 index 00000000000..2405576f3a2 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_by_billing_account import * +from ._list_by_billing_account import * diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/_get_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/_get_by_billing_account.py new file mode 100644 index 00000000000..930865a400e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/_get_by_billing_account.py @@ -0,0 +1,362 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan-order get-by-billing-account", +) +class GetByBillingAccount(AAZCommand): + """Get a savings plan order by billing account. + + :example: SavingsPlanOrderGet + az billing savings-plan-order get-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --savings-plan-order-id 20000000-0000-0000-0000-000000000000 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplanorders/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.savings_plan_order_id = AAZStrArg( + options=["--savings-plan-order-id"], + help="Order ID of the savings plan", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="May be used to expand the planInformation.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SavingsPlanOrdersGetByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class SavingsPlanOrdersGetByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "savingsPlanOrderId", self.ctx.args.savings_plan_order_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + flags={"read_only": True}, + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + _GetByBillingAccountHelper._build_schema_extended_status_info_read(properties.extended_status_info) + properties.plan_information = AAZObjectType( + serialized_name="planInformation", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.savings_plans = AAZListType( + serialized_name="savingsPlans", + ) + properties.term = AAZStrType() + + plan_information = cls._schema_on_200.properties.plan_information + plan_information.next_payment_due_date = AAZStrType( + serialized_name="nextPaymentDueDate", + ) + plan_information.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(plan_information.pricing_currency_total) + plan_information.start_date = AAZStrType( + serialized_name="startDate", + ) + plan_information.transactions = AAZListType() + + transactions = cls._schema_on_200.properties.plan_information.transactions + transactions.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.plan_information.transactions.Element + _element.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(_element.billing_currency_total) + _element.due_date = AAZStrType( + serialized_name="dueDate", + ) + _element.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + _GetByBillingAccountHelper._build_schema_extended_status_info_read(_element.extended_status_info) + _element.payment_date = AAZStrType( + serialized_name="paymentDate", + ) + _element.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _GetByBillingAccountHelper._build_schema_price_read(_element.pricing_currency_total) + _element.status = AAZStrType() + + savings_plans = cls._schema_on_200.properties.savings_plans + savings_plans.Element = AAZStrType( + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.sku + sku.name = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingAccountHelper: + """Helper class for GetByBillingAccount""" + + _schema_extended_status_info_read = None + + @classmethod + def _build_schema_extended_status_info_read(cls, _schema): + if cls._schema_extended_status_info_read is not None: + _schema.message = cls._schema_extended_status_info_read.message + _schema.properties = cls._schema_extended_status_info_read.properties + _schema.status_code = cls._schema_extended_status_info_read.status_code + return + + cls._schema_extended_status_info_read = _schema_extended_status_info_read = AAZObjectType( + flags={"read_only": True} + ) + + extended_status_info_read = _schema_extended_status_info_read + extended_status_info_read.message = AAZStrType() + extended_status_info_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + extended_status_info_read.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = _schema_extended_status_info_read.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + _schema.message = cls._schema_extended_status_info_read.message + _schema.properties = cls._schema_extended_status_info_read.properties + _schema.status_code = cls._schema_extended_status_info_read.status_code + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + +__all__ = ["GetByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/_list_by_billing_account.py new file mode 100644 index 00000000000..1070f072034 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/savings_plan_order/_list_by_billing_account.py @@ -0,0 +1,378 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing savings-plan-order list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List all Savings plan orders by billing account. + + :example: SavingsPlanOrderList + az billing savings-plan-order list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/savingsplanorders", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.skiptoken = AAZFloatArg( + options=["--skiptoken"], + help="The number of savings plans to skip from the list before returning results", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SavingsPlanOrdersListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class SavingsPlanOrdersListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "skiptoken", self.ctx.args.skiptoken, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType( + flags={"required": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.benefit_start_time = AAZStrType( + serialized_name="benefitStartTime", + flags={"read_only": True}, + ) + properties.billing_account_id = AAZStrType( + serialized_name="billingAccountId", + flags={"read_only": True}, + ) + properties.billing_plan = AAZStrType( + serialized_name="billingPlan", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + flags={"read_only": True}, + ) + properties.billing_scope_id = AAZStrType( + serialized_name="billingScopeId", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.expiry_date_time = AAZStrType( + serialized_name="expiryDateTime", + flags={"read_only": True}, + ) + properties.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_extended_status_info_read(properties.extended_status_info) + properties.plan_information = AAZObjectType( + serialized_name="planInformation", + ) + properties.product_code = AAZStrType( + serialized_name="productCode", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.savings_plans = AAZListType( + serialized_name="savingsPlans", + ) + properties.term = AAZStrType() + + plan_information = cls._schema_on_200.value.Element.properties.plan_information + plan_information.next_payment_due_date = AAZStrType( + serialized_name="nextPaymentDueDate", + ) + plan_information.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(plan_information.pricing_currency_total) + plan_information.start_date = AAZStrType( + serialized_name="startDate", + ) + plan_information.transactions = AAZListType() + + transactions = cls._schema_on_200.value.Element.properties.plan_information.transactions + transactions.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.plan_information.transactions.Element + _element.billing_currency_total = AAZObjectType( + serialized_name="billingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(_element.billing_currency_total) + _element.due_date = AAZStrType( + serialized_name="dueDate", + ) + _element.extended_status_info = AAZObjectType( + serialized_name="extendedStatusInfo", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_extended_status_info_read(_element.extended_status_info) + _element.payment_date = AAZStrType( + serialized_name="paymentDate", + ) + _element.pricing_currency_total = AAZObjectType( + serialized_name="pricingCurrencyTotal", + ) + _ListByBillingAccountHelper._build_schema_price_read(_element.pricing_currency_total) + _element.status = AAZStrType() + + savings_plans = cls._schema_on_200.value.Element.properties.savings_plans + savings_plans.Element = AAZStrType( + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.name = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + _schema_extended_status_info_read = None + + @classmethod + def _build_schema_extended_status_info_read(cls, _schema): + if cls._schema_extended_status_info_read is not None: + _schema.message = cls._schema_extended_status_info_read.message + _schema.properties = cls._schema_extended_status_info_read.properties + _schema.status_code = cls._schema_extended_status_info_read.status_code + return + + cls._schema_extended_status_info_read = _schema_extended_status_info_read = AAZObjectType( + flags={"read_only": True} + ) + + extended_status_info_read = _schema_extended_status_info_read + extended_status_info_read.message = AAZStrType() + extended_status_info_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + extended_status_info_read.status_code = AAZStrType( + serialized_name="statusCode", + ) + + properties = _schema_extended_status_info_read.properties + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + _schema.message = cls._schema_extended_status_info_read.message + _schema.properties = cls._schema_extended_status_info_read.properties + _schema.status_code = cls._schema_extended_status_info_read.status_code + + _schema_price_read = None + + @classmethod + def _build_schema_price_read(cls, _schema): + if cls._schema_price_read is not None: + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + return + + cls._schema_price_read = _schema_price_read = AAZObjectType() + + price_read = _schema_price_read + price_read.amount = AAZFloatType() + price_read.currency_code = AAZStrType( + serialized_name="currencyCode", + ) + + _schema.amount = cls._schema_price_read.amount + _schema.currency_code = cls._schema_price_read.currency_code + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/subscription/__cmd_group.py new file mode 100644 index 00000000000..b06ec432c46 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing subscription", +) +class __CMDGroup(AAZCommandGroup): + """Multiple operations (Get, List, Delete, Cancel etc.) at the billing profile , billing account, customer, enrollment, invoice section etc. scope around subscriptions. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/__init__.py b/src/billing/azext_billing/aaz/latest/billing/subscription/__init__.py new file mode 100644 index 00000000000..b3c9ad8a6b5 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/__init__.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._cancel import * +from ._delete import * +from ._get import * +from ._get_by_billing_profile import * +from ._list_by_billing_account import * +from ._list_by_billing_profile import * +from ._list_by_customer import * +from ._list_by_customer_at_billing_account import * +from ._list_by_enrollment_account import * +from ._list_by_invoice_section import * +from ._merge import * +from ._move import * +from ._split import * +from ._update import * +from ._validate_move_eligibility import * +from ._wait import * diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_cancel.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_cancel.py new file mode 100644 index 00000000000..08da25622f5 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_cancel.py @@ -0,0 +1,172 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription cancel", +) +class Cancel(AAZCommand): + """Cancels a usage-based subscription. This operation is supported only for billing accounts of type Microsoft Partner Agreement. + + :example: BillingSubscriptionsCancel + az billing subscription cancel --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-subscription-name 11111111-1111-1111-1111-111111111111 --cancellation-reason Compromise --customer-id 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}/cancel", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.cancellation_reason = AAZStrArg( + options=["--cancellation-reason"], + arg_group="Parameters", + help="Cancellation reason.", + required=True, + enum={"Compromise": "Compromise", "Dispute": "Dispute", "Other": "Other"}, + ) + _args_schema.customer_id = AAZStrArg( + options=["--customer-id"], + arg_group="Parameters", + help="The fully qualified ID that uniquely identifies a customer.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingSubscriptionsCancel(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingSubscriptionsCancel(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + None, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/cancel", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("cancellationReason", AAZStrType, ".cancellation_reason", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("customerId", AAZStrType, ".customer_id") + + return self.serialize_content(_content_value) + + +class _CancelHelper: + """Helper class for Cancel""" + + +__all__ = ["Cancel"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_delete.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_delete.py new file mode 100644 index 00000000000..45bb45bb413 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_delete.py @@ -0,0 +1,160 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a billing subscription. This operation is supported only for billing accounts of type Microsoft Partner Agreement or Microsoft Customer Agreement. + + :example: BillingSubscriptionsDelete + az billing subscription delete --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-subscription-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingSubscriptionsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class BillingSubscriptionsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_get.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_get.py new file mode 100644 index 00000000000..5dede640dfc --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_get.py @@ -0,0 +1,478 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription get", +) +class Get(AAZCommand): + """Get a subscription by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement, Microsoft Partner Agreement, and Enterprise Agreement. + + :example: BillingSubscriptionsGet + az billing subscription get --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-subscription-name 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _GetHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _GetHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_get_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_get_by_billing_profile.py new file mode 100644 index 00000000000..c0f23ca8b35 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_get_by_billing_profile.py @@ -0,0 +1,487 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription get-by-billing-profile", +) +class GetByBillingProfile(AAZCommand): + """Get a subscription by its billing profile and ID. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: BillingSubscriptionGetByBillingProfile + az billing subscription get-by-billing-profile --billing-account-name pcn.94077792 --billing-profile-name 6478903 --billing-subscription-name 6b96d3f2-9008-4a9d-912f-f87744185aa3 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingsubscriptions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsGetByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsGetByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions/{billingSubscriptionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _GetByBillingProfileHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _GetByBillingProfileHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetByBillingProfileHelper: + """Helper class for GetByBillingProfile""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["GetByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_billing_account.py new file mode 100644 index 00000000000..68acbe4ae61 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_billing_account.py @@ -0,0 +1,553 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription list-by-billing-account", +) +class ListByBillingAccount(AAZCommand): + """List the subscriptions for a billing account. + + :example: BillingSubscriptionsListByBillingAccount + az billing subscription list-by-billing-account --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --include-deleted False --include-tenant-subscriptions False + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted billing subscriptions.", + default=False, + ) + _args_schema.include_failed = AAZBoolArg( + options=["--include-failed"], + help="Can be used to get failed billing subscriptions.", + default=False, + ) + _args_schema.include_tenant_subscriptions = AAZBoolArg( + options=["--include-tenant-subscriptions"], + help="Can be used to get tenant-owned billing subscriptions. This field is only applies to Microsoft Online Services Program billing accounts.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsListByBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingSubscriptionsListByBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "includeFailed", self.ctx.args.include_failed, + ), + **self.serialize_query_param( + "includeTenantSubscriptions", self.ctx.args.include_tenant_subscriptions, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.total_count = AAZFloatType( + serialized_name="totalCount", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _ListByBillingAccountHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.value.Element.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.value.Element.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.value.Element.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.value.Element.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.value.Element.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.value.Element.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.value.Element.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.value.Element.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingAccountHelper: + """Helper class for ListByBillingAccount""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["ListByBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_billing_profile.py new file mode 100644 index 00000000000..ad8d42a9058 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_billing_profile.py @@ -0,0 +1,546 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List 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. + + :example: BillingSubscriptionsListByBillingProfileMCA + az billing subscription list-by-billing-profile --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --billing-profile-name ea36e548-1505-41db-bebc-46fff3d37998 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/billingsubscriptions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted billing subscriptions.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingSubscriptionsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.total_count = AAZFloatType( + serialized_name="totalCount", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _ListByBillingProfileHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _ListByBillingProfileHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.value.Element.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.value.Element.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.value.Element.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.value.Element.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.value.Element.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.value.Element.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.value.Element.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.value.Element.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_customer.py new file mode 100644 index 00000000000..677c2e68740 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_customer.py @@ -0,0 +1,555 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription list-by-customer", +) +class ListByCustomer(AAZCommand): + """List the subscriptions for a customer. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingSubscriptionsListByCustomer + az billing subscription list-by-customer --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --billing-profile-name ea36e548-1505-41db-bebc-46fff3d37998 --customer-name Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/billingsubscriptions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted billing subscriptions.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsListByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingSubscriptionsListByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/billingSubscriptions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.total_count = AAZFloatType( + serialized_name="totalCount", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _ListByCustomerHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _ListByCustomerHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.value.Element.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.value.Element.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.value.Element.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.value.Element.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.value.Element.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.value.Element.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.value.Element.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.value.Element.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerHelper: + """Helper class for ListByCustomer""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["ListByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_customer_at_billing_account.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_customer_at_billing_account.py new file mode 100644 index 00000000000..acc6af31975 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_customer_at_billing_account.py @@ -0,0 +1,546 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription list-by-customer-at-billing-account", +) +class ListByCustomerAtBillingAccount(AAZCommand): + """List the subscriptions for a customer at billing account level. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. + + :example: BillingSubscriptionsListByCustomerAtBillingAccount + az billing subscription list-by-customer-at-billing-account --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --customer-name Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/customers/{}/billingsubscriptions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted billing subscriptions.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsListByCustomerAtBillingAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingSubscriptionsListByCustomerAtBillingAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingSubscriptions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.total_count = AAZFloatType( + serialized_name="totalCount", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _ListByCustomerAtBillingAccountHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _ListByCustomerAtBillingAccountHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.value.Element.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.value.Element.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.value.Element.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.value.Element.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.value.Element.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.value.Element.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.value.Element.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.value.Element.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerAtBillingAccountHelper: + """Helper class for ListByCustomerAtBillingAccount""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["ListByCustomerAtBillingAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_enrollment_account.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_enrollment_account.py new file mode 100644 index 00000000000..6361c34bf5b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_enrollment_account.py @@ -0,0 +1,534 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription list-by-enrollment-account", +) +class ListByEnrollmentAccount(AAZCommand): + """List the subscriptions for an enrollment account. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: BillingSubscriptionsListByEnrollmentAccount + az billing subscription list-by-enrollment-account --billing-account-name 6564892 --enrollment-account-name 172988 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/enrollmentaccounts/{}/billingsubscriptions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.enrollment_account_name = AAZStrArg( + options=["--enrollment-account-name"], + help="The name of the enrollment account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsListByEnrollmentAccount(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingSubscriptionsListByEnrollmentAccount(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}/billingSubscriptions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "enrollmentAccountName", self.ctx.args.enrollment_account_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.total_count = AAZFloatType( + serialized_name="totalCount", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _ListByEnrollmentAccountHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _ListByEnrollmentAccountHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.value.Element.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.value.Element.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.value.Element.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.value.Element.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.value.Element.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.value.Element.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.value.Element.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.value.Element.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByEnrollmentAccountHelper: + """Helper class for ListByEnrollmentAccount""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["ListByEnrollmentAccount"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_invoice_section.py new file mode 100644 index 00000000000..1dad64946af --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_list_by_invoice_section.py @@ -0,0 +1,555 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription list-by-invoice-section", +) +class ListByInvoiceSection(AAZCommand): + """List the subscriptions that are billed to an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: BillingSubscriptionsListByInvoiceSection + az billing subscription list-by-invoice-section --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --billing-profile-name ea36e548-1505-41db-bebc-46fff3d37998 --invoice-section-name Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/billingsubscriptions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.include_deleted = AAZBoolArg( + options=["--include-deleted"], + help="Can be used to get deleted billing subscriptions.", + default=False, + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsListByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class BillingSubscriptionsListByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingSubscriptions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "includeDeleted", self.ctx.args.include_deleted, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.total_count = AAZFloatType( + serialized_name="totalCount", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _ListByInvoiceSectionHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _ListByInvoiceSectionHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.value.Element.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.value.Element.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.value.Element.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.value.Element.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.value.Element.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.value.Element.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.value.Element.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.value.Element.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.value.Element.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceSectionHelper: + """Helper class for ListByInvoiceSection""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["ListByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_merge.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_merge.py new file mode 100644 index 00000000000..7b12aa90f57 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_merge.py @@ -0,0 +1,517 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription merge", +) +class Merge(AAZCommand): + """Merges the billing subscription provided in the request with a target billing subscription. + + :example: BillingSubscriptionsMerge + az billing subscription merge --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-subscription-name 11111111-1111-1111-1111-111111111111 --target-billing-subscription-name 22222222-2222-2222-2222-222222222222 --quantity 1 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}/merge", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.quantity = AAZIntArg( + options=["--quantity"], + arg_group="Parameters", + help="The quantity of the source billing subscription that will be merged with the target billing subscription.", + ) + _args_schema.target_billing_subscription_name = AAZStrArg( + options=["--target-billing-subscription-name"], + arg_group="Parameters", + help="The ID of the target billing subscription that will be merged with the source subscription provided in the request.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingSubscriptionsMerge(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsMerge(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/merge", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("quantity", AAZIntType, ".quantity") + _builder.set_prop("targetBillingSubscriptionName", AAZStrType, ".target_billing_subscription_name") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _MergeHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _MergeHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _MergeHelper: + """Helper class for Merge""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Merge"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_move.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_move.py new file mode 100644 index 00000000000..859f1ff5005 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_move.py @@ -0,0 +1,517 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription move", +) +class Move(AAZCommand): + """Moves charges for a subscription 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. + + :example: BillingSubscriptionMove + az billing subscription move --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --billing-subscription-name 6b96d3f2-9008-4a9d-912f-f87744185aa3 --destination-invoice-section-id /providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}/move", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.destination_enrollment_account_id = AAZStrArg( + options=["--destination-enrollment-account-id"], + arg_group="Parameters", + help="The destination enrollment account id.", + ) + _args_schema.destination_invoice_section_id = AAZStrArg( + options=["--destination-invoice-section-id"], + arg_group="Parameters", + help="The destination invoice section id.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingSubscriptionsMove(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsMove(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/move", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("destinationEnrollmentAccountId", AAZStrType, ".destination_enrollment_account_id") + _builder.set_prop("destinationInvoiceSectionId", AAZStrType, ".destination_invoice_section_id") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _MoveHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _MoveHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _MoveHelper: + """Helper class for Move""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Move"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_split.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_split.py new file mode 100644 index 00000000000..9a7751e40e9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_split.py @@ -0,0 +1,535 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription split", +) +class Split(AAZCommand): + """Splits a subscription into a new subscription with quantity less than current subscription quantity and not equal to 0. + + :example: BillingSubscriptionsSplit + az billing subscription split --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-subscription-name 11111111-1111-1111-1111-111111111111 --target-product-type-id XYZ56789 --target-sku-id 0001 --quantity 1 --term-duration P1M --billing-frequency P1M + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}/split", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.billing_frequency = AAZStrArg( + options=["--billing-frequency"], + arg_group="Parameters", + help="The billing frequency of the target subscription in the ISO8601 format. Example: P1M, P3M, P1Y\"", + ) + _args_schema.quantity = AAZIntArg( + options=["--quantity"], + arg_group="Parameters", + help="The quantity of the target product to which the subscription needs to be split into.", + ) + _args_schema.target_product_type_id = AAZStrArg( + options=["--target-product-type-id"], + arg_group="Parameters", + help="The ID of the target product to which the subscription needs to be split into. This value is not same as the value returned in Get API call and can be retrieved from Catalog API to know the product id to split into.", + ) + _args_schema.target_sku_id = AAZStrArg( + options=["--target-sku-id"], + arg_group="Parameters", + help="The ID of the target product to which the subscription needs to be split into. This value is not same as the value returned in Get API call and can be retrieved from Catalog API to know the sku id to split into.", + ) + _args_schema.term_duration = AAZStrArg( + options=["--term-duration"], + arg_group="Parameters", + help="The term duration of the target in ISO8601 format product to which the subscription needs to be split into. Example: P1M, P1Y", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingSubscriptionsSplit(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsSplit(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/split", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("billingFrequency", AAZStrType, ".billing_frequency") + _builder.set_prop("quantity", AAZIntType, ".quantity") + _builder.set_prop("targetProductTypeId", AAZStrType, ".target_product_type_id") + _builder.set_prop("targetSkuId", AAZStrType, ".target_sku_id") + _builder.set_prop("termDuration", AAZStrType, ".term_duration") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _SplitHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _SplitHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _SplitHelper: + """Helper class for Split""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Split"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_update.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_update.py new file mode 100644 index 00000000000..be9a2f9783d --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_update.py @@ -0,0 +1,623 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription update", +) +class Update(AAZCommand): + """Update the properties of a billing subscription. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Dictionary of metadata associated with the resource. It may not be populated for all resource types. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \\ ? /", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.auto_renew = AAZStrArg( + options=["--auto-renew"], + arg_group="Properties", + help="Indicates whether auto renewal is turned on or off for a product.", + enum={"Off": "Off", "On": "On"}, + ) + _args_schema.beneficiary = AAZObjectArg( + options=["--beneficiary"], + arg_group="Properties", + help="The beneficiary of the billing subscription.", + ) + _args_schema.beneficiary_tenant_id = AAZStrArg( + options=["--beneficiary-tenant-id"], + arg_group="Properties", + help="The provisioning tenant of the subscription.", + ) + _args_schema.billing_frequency = AAZStrArg( + options=["--billing-frequency"], + arg_group="Properties", + help="The billing frequency in ISO8601 format of product in the subscription. Example: P1M, P3M, P1Y", + ) + _args_schema.billing_profile_id = AAZStrArg( + options=["--billing-profile-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies a billing profile.", + ) + _args_schema.consumption_cost_center = AAZStrArg( + options=["--consumption-cost-center"], + arg_group="Properties", + help="The cost center applied to the subscription. This field is only available for consumption subscriptions of Microsoft Customer Agreement or Enterprise Agreement Type billing accounts.", + ) + _args_schema.customer_id = AAZStrArg( + options=["--customer-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies a customer.", + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The name of the billing subscription.", + ) + _args_schema.invoice_section_id = AAZStrArg( + options=["--invoice-section-id"], + arg_group="Properties", + help="The fully qualified ID that uniquely identifies an invoice section.", + ) + _args_schema.product_type_id = AAZStrArg( + options=["--product-type-id"], + arg_group="Properties", + help="Id of the product for which the subscription is purchased.", + ) + _args_schema.provisioning_tenant_id = AAZStrArg( + options=["--provisioning-tenant-id"], + arg_group="Properties", + help="The tenant in which the subscription is provisioned.", + ) + _args_schema.quantity = AAZIntArg( + options=["--quantity"], + arg_group="Properties", + help="The quantity of licenses or fulfillment units for the subscription.", + ) + _args_schema.sku_id = AAZStrArg( + options=["--sku-id"], + arg_group="Properties", + help="The SKU ID of the product for which the subscription is purchased. This field is is only available for Microsoft Customer Agreement billing accounts.", + ) + _args_schema.term_duration = AAZStrArg( + options=["--term-duration"], + arg_group="Properties", + help="The duration in ISO8601 format for which you can use the subscription. Example: P1M, P3M, P1Y", + ) + + beneficiary = cls._args_schema.beneficiary + beneficiary.object_id = AAZStrArg( + options=["object-id"], + help="The ID that uniquely identifies a user in a tenant.", + ) + beneficiary.tenant_id = AAZStrArg( + options=["tenant-id"], + help="The ID that uniquely identifies a tenant.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.BillingSubscriptionsUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("autoRenew", AAZStrType, ".auto_renew") + properties.set_prop("beneficiary", AAZObjectType, ".beneficiary") + properties.set_prop("beneficiaryTenantId", AAZStrType, ".beneficiary_tenant_id") + properties.set_prop("billingFrequency", AAZStrType, ".billing_frequency") + properties.set_prop("billingProfileId", AAZStrType, ".billing_profile_id") + properties.set_prop("consumptionCostCenter", AAZStrType, ".consumption_cost_center") + properties.set_prop("customerId", AAZStrType, ".customer_id") + properties.set_prop("displayName", AAZStrType, ".display_name") + properties.set_prop("invoiceSectionId", AAZStrType, ".invoice_section_id") + properties.set_prop("productTypeId", AAZStrType, ".product_type_id") + properties.set_prop("provisioningTenantId", AAZStrType, ".provisioning_tenant_id") + properties.set_prop("quantity", AAZIntType, ".quantity") + properties.set_prop("skuId", AAZStrType, ".sku_id") + properties.set_prop("termDuration", AAZStrType, ".term_duration") + + beneficiary = _builder.get(".properties.beneficiary") + if beneficiary is not None: + beneficiary.set_prop("objectId", AAZStrType, ".object_id") + beneficiary.set_prop("tenantId", AAZStrType, ".tenant_id") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _UpdateHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _UpdateHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_validate_move_eligibility.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_validate_move_eligibility.py new file mode 100644 index 00000000000..ee704ed6fe7 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_validate_move_eligibility.py @@ -0,0 +1,202 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription validate-move-eligibility", +) +class ValidateMoveEligibility(AAZCommand): + """Validates if charges for a subscription can be moved to a new invoice section. This operation is supported for billing accounts with agreement type Microsoft Customer Agreement. + + :example: BillingSubscriptionValidateMoveSuccess + az billing subscription validate-move-eligibility --billing-account-name a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31 --billing-subscription-name 6b96d3f2-9008-4a9d-912f-f87744185aa3 --destination-invoice-section-id /providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}/validatemoveeligibility", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.destination_enrollment_account_id = AAZStrArg( + options=["--destination-enrollment-account-id"], + arg_group="Parameters", + help="The destination enrollment account id.", + ) + _args_schema.destination_invoice_section_id = AAZStrArg( + options=["--destination-invoice-section-id"], + arg_group="Parameters", + help="The destination invoice section id.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsValidateMoveEligibility(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class BillingSubscriptionsValidateMoveEligibility(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}/validateMoveEligibility", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("destinationEnrollmentAccountId", AAZStrType, ".destination_enrollment_account_id") + _builder.set_prop("destinationInvoiceSectionId", AAZStrType, ".destination_invoice_section_id") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _schema_on_200.is_move_eligible = AAZBoolType( + serialized_name="isMoveEligible", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.error_details + error_details.code = AAZStrType() + error_details.details = AAZStrType() + error_details.message = AAZStrType() + + return cls._schema_on_200 + + +class _ValidateMoveEligibilityHelper: + """Helper class for ValidateMoveEligibility""" + + +__all__ = ["ValidateMoveEligibility"] diff --git a/src/billing/azext_billing/aaz/latest/billing/subscription/_wait.py b/src/billing/azext_billing/aaz/latest/billing/subscription/_wait.py new file mode 100644 index 00000000000..6fe0ca5aa69 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/subscription/_wait.py @@ -0,0 +1,474 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing subscription wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingsubscriptions/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + ) + _args_schema.billing_subscription_name = AAZStrArg( + options=["--billing-subscription-name"], + help="The ID that uniquely identifies a subscription.", + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="Can be used to expand `Reseller`, `ConsumptionCostCenter`, `LastMonthCharges` and `MonthToDateCharges`", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.BillingSubscriptionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class BillingSubscriptionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{billingSubscriptionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingSubscriptionName", self.ctx.args.billing_subscription_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.auto_renew = AAZStrType( + serialized_name="autoRenew", + ) + properties.beneficiary = AAZObjectType() + properties.beneficiary_tenant_id = AAZStrType( + serialized_name="beneficiaryTenantId", + ) + properties.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + ) + properties.billing_policies = AAZDictType( + serialized_name="billingPolicies", + flags={"read_only": True}, + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + flags={"read_only": True}, + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.billing_profile_name = AAZStrType( + serialized_name="billingProfileName", + flags={"read_only": True}, + ) + properties.consumption_cost_center = AAZStrType( + serialized_name="consumptionCostCenter", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + flags={"read_only": True}, + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.customer_name = AAZStrType( + serialized_name="customerName", + flags={"read_only": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.enrollment_account_display_name = AAZStrType( + serialized_name="enrollmentAccountDisplayName", + flags={"read_only": True}, + ) + properties.enrollment_account_id = AAZStrType( + serialized_name="enrollmentAccountId", + flags={"read_only": True}, + ) + properties.enrollment_account_subscription_details = AAZObjectType( + serialized_name="enrollmentAccountSubscriptionDetails", + flags={"client_flatten": True, "read_only": True}, + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + flags={"read_only": True}, + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.invoice_section_name = AAZStrType( + serialized_name="invoiceSectionName", + flags={"read_only": True}, + ) + properties.last_month_charges = AAZObjectType( + serialized_name="lastMonthCharges", + flags={"read_only": True}, + ) + _WaitHelper._build_schema_amount_read(properties.last_month_charges) + properties.month_to_date_charges = AAZObjectType( + serialized_name="monthToDateCharges", + flags={"read_only": True}, + ) + _WaitHelper._build_schema_amount_read(properties.month_to_date_charges) + properties.next_billing_cycle_details = AAZObjectType( + serialized_name="nextBillingCycleDetails", + flags={"read_only": True}, + ) + properties.offer_id = AAZStrType( + serialized_name="offerId", + flags={"read_only": True}, + ) + properties.operation_status = AAZStrType( + serialized_name="operationStatus", + flags={"read_only": True}, + ) + properties.product_category = AAZStrType( + serialized_name="productCategory", + flags={"read_only": True}, + ) + properties.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_tenant_id = AAZStrType( + serialized_name="provisioningTenantId", + ) + properties.purchase_date = AAZStrType( + serialized_name="purchaseDate", + flags={"read_only": True}, + ) + properties.quantity = AAZIntType() + properties.renewal_term_details = AAZObjectType( + serialized_name="renewalTermDetails", + flags={"read_only": True}, + ) + properties.reseller = AAZObjectType( + flags={"read_only": True}, + ) + properties.resource_uri = AAZStrType( + serialized_name="resourceUri", + flags={"read_only": True}, + ) + properties.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + properties.sku_id = AAZStrType( + serialized_name="skuId", + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + properties.suspension_reason_details = AAZListType( + serialized_name="suspensionReasonDetails", + flags={"read_only": True}, + ) + properties.suspension_reasons = AAZListType( + serialized_name="suspensionReasons", + flags={"read_only": True}, + ) + properties.system_overrides = AAZObjectType( + serialized_name="systemOverrides", + ) + properties.term_duration = AAZStrType( + serialized_name="termDuration", + ) + properties.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + properties.term_start_date = AAZStrType( + serialized_name="termStartDate", + flags={"read_only": True}, + ) + + beneficiary = cls._schema_on_200.properties.beneficiary + beneficiary.object_id = AAZStrType( + serialized_name="objectId", + ) + beneficiary.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + billing_policies = cls._schema_on_200.properties.billing_policies + billing_policies.Element = AAZStrType() + + enrollment_account_subscription_details = cls._schema_on_200.properties.enrollment_account_subscription_details + enrollment_account_subscription_details.enrollment_account_start_date = AAZStrType( + serialized_name="enrollmentAccountStartDate", + flags={"read_only": True}, + ) + enrollment_account_subscription_details.subscription_enrollment_account_status = AAZStrType( + serialized_name="subscriptionEnrollmentAccountStatus", + flags={"read_only": True}, + ) + + next_billing_cycle_details = cls._schema_on_200.properties.next_billing_cycle_details + next_billing_cycle_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + + renewal_term_details = cls._schema_on_200.properties.renewal_term_details + renewal_term_details.billing_frequency = AAZStrType( + serialized_name="billingFrequency", + flags={"read_only": True}, + ) + renewal_term_details.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + renewal_term_details.product_type_id = AAZStrType( + serialized_name="productTypeId", + flags={"read_only": True}, + ) + renewal_term_details.quantity = AAZIntType() + renewal_term_details.sku_id = AAZStrType( + serialized_name="skuId", + flags={"read_only": True}, + ) + renewal_term_details.term_duration = AAZStrType( + serialized_name="termDuration", + flags={"read_only": True}, + ) + renewal_term_details.term_end_date = AAZStrType( + serialized_name="termEndDate", + flags={"read_only": True}, + ) + + reseller = cls._schema_on_200.properties.reseller + reseller.description = AAZStrType( + flags={"read_only": True}, + ) + reseller.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + + suspension_reason_details = cls._schema_on_200.properties.suspension_reason_details + suspension_reason_details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.suspension_reason_details.Element + _element.effective_date = AAZStrType( + serialized_name="effectiveDate", + flags={"read_only": True}, + ) + _element.reason = AAZStrType( + flags={"read_only": True}, + ) + + suspension_reasons = cls._schema_on_200.properties.suspension_reasons + suspension_reasons.Element = AAZStrType() + + system_overrides = cls._schema_on_200.properties.system_overrides + system_overrides.cancellation = AAZStrType( + flags={"read_only": True}, + ) + system_overrides.cancellation_allowed_end_date = AAZStrType( + serialized_name="cancellationAllowedEndDate", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_amount_read = None + + @classmethod + def _build_schema_amount_read(cls, _schema): + if cls._schema_amount_read is not None: + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + return + + cls._schema_amount_read = _schema_amount_read = AAZObjectType( + flags={"read_only": True} + ) + + amount_read = _schema_amount_read + amount_read.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_read.value = AAZFloatType( + flags={"read_only": True}, + ) + + _schema.currency = cls._schema_amount_read.currency + _schema.value = cls._schema_amount_read.value + + +__all__ = ["Wait"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/transaction/__cmd_group.py new file mode 100644 index 00000000000..ce375bbf40a --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing transaction", +) +class __CMDGroup(AAZCommandGroup): + """Get, List, Transactions Download operations for usage/purchase transactions at different scopes + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/__init__.py b/src/billing/azext_billing/aaz/latest/billing/transaction/__init__.py new file mode 100644 index 00000000000..87f2d19774b --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/__init__.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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_transaction_summary_by_invoice import * +from ._list_by_billing_profile import * +from ._list_by_customer import * +from ._list_by_invoice import * +from ._list_by_invoice_section import * +from ._transactions_download_by_invoice import * diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/_get_transaction_summary_by_invoice.py b/src/billing/azext_billing/aaz/latest/billing/transaction/_get_transaction_summary_by_invoice.py new file mode 100644 index 00000000000..c84f6253fd4 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/_get_transaction_summary_by_invoice.py @@ -0,0 +1,203 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transaction get-transaction-summary-by-invoice", +) +class GetTransactionSummaryByInvoice(AAZCommand): + """Get the transaction summary for an invoice. Transactions include purchases, refunds and Azure usage charges. + + :example: TransactionSummaryGetByInvoice + az billing transaction get-transaction-summary-by-invoice --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --invoice-name G123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices/{}/transactionsummary", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter the line items that are aggregated to create the line item summary.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to filter the line items that are aggregated to create the line item summary.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransactionsGetTransactionSummaryByInvoice(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TransactionsGetTransactionSummaryByInvoice(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactionSummary", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.azure_credit_applied = AAZFloatType( + serialized_name="azureCreditApplied", + flags={"read_only": True}, + ) + _schema_on_200.billing_currency = AAZStrType( + serialized_name="billingCurrency", + flags={"read_only": True}, + ) + _schema_on_200.consumption_commitment_decremented = AAZFloatType( + serialized_name="consumptionCommitmentDecremented", + flags={"read_only": True}, + ) + _schema_on_200.sub_total = AAZFloatType( + serialized_name="subTotal", + flags={"read_only": True}, + ) + _schema_on_200.tax = AAZFloatType( + flags={"read_only": True}, + ) + _schema_on_200.total = AAZFloatType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _GetTransactionSummaryByInvoiceHelper: + """Helper class for GetTransactionSummaryByInvoice""" + + +__all__ = ["GetTransactionSummaryByInvoice"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_billing_profile.py b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_billing_profile.py new file mode 100644 index 00000000000..c215dd82f75 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_billing_profile.py @@ -0,0 +1,477 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transaction list-by-billing-profile", +) +class ListByBillingProfile(AAZCommand): + """List the billed or unbilled transactions by billing profile name for given start and end date. Transactions include purchases, refunds and Azure usage charges. Unbilled transactions are listed under pending invoice Id and do not include tax. Tax is added to the amount once an invoice is generated. + + :example: TransactionsListByBillingProfile + az billing transaction list-by-billing-profile --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --period-start-date 2024-04-01 --period-end-date 2023-05-30 --type Billed --filter properties/date gt '2020-10-01' --search storage + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/transactions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.period_end_date = AAZDateArg( + options=["--period-end-date"], + help="The end date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + _args_schema.period_start_date = AAZDateArg( + options=["--period-start-date"], + help="The start date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + _args_schema.type = AAZStrArg( + options=["--type"], + help="The type of transaction.", + required=True, + enum={"Billed": "Billed", "Other": "Other", "Unbilled": "Unbilled"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransactionsListByBillingProfile(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class TransactionsListByBillingProfile(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/transactions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "periodEndDate", self.ctx.args.period_end_date, + required=True, + ), + **self.serialize_query_param( + "periodStartDate", self.ctx.args.period_start_date, + required=True, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "type", self.ctx.args.type, + required=True, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.azure_credit_applied = AAZObjectType( + serialized_name="azureCreditApplied", + ) + properties.azure_plan = AAZStrType( + serialized_name="azurePlan", + ) + properties.billing_currency = AAZStrType( + serialized_name="billingCurrency", + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.consumption_commitment_decremented = AAZObjectType( + serialized_name="consumptionCommitmentDecremented", + ) + properties.credit_type = AAZStrType( + serialized_name="creditType", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.date = AAZStrType() + properties.discount = AAZFloatType() + properties.effective_price = AAZObjectType( + serialized_name="effectivePrice", + ) + properties.exchange_rate = AAZFloatType( + serialized_name="exchangeRate", + ) + properties.invoice = AAZStrType() + properties.invoice_id = AAZStrType( + serialized_name="invoiceId", + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.is_third_party = AAZBoolType( + serialized_name="isThirdParty", + ) + properties.kind = AAZStrType() + properties.market_price = AAZObjectType( + serialized_name="marketPrice", + ) + properties.part_number = AAZStrType( + serialized_name="partNumber", + ) + properties.pricing_currency = AAZStrType( + serialized_name="pricingCurrency", + ) + properties.product_description = AAZStrType( + serialized_name="productDescription", + ) + properties.product_family = AAZStrType( + serialized_name="productFamily", + ) + properties.product_type = AAZStrType( + serialized_name="productType", + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.quantity = AAZIntType() + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.refund_transaction_details = AAZObjectType( + serialized_name="refundTransactionDetails", + ) + properties.service_period_end_date = AAZStrType( + serialized_name="servicePeriodEndDate", + ) + properties.service_period_start_date = AAZStrType( + serialized_name="servicePeriodStartDate", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.tax = AAZObjectType() + properties.transaction_amount = AAZObjectType( + serialized_name="transactionAmount", + ) + properties.transaction_type = AAZStrType( + serialized_name="transactionType", + ) + properties.unit_of_measure = AAZStrType( + serialized_name="unitOfMeasure", + ) + properties.unit_type = AAZStrType( + serialized_name="unitType", + ) + properties.units = AAZFloatType() + + azure_credit_applied = cls._schema_on_200.value.Element.properties.azure_credit_applied + azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + consumption_commitment_decremented = cls._schema_on_200.value.Element.properties.consumption_commitment_decremented + consumption_commitment_decremented.currency = AAZStrType( + flags={"read_only": True}, + ) + consumption_commitment_decremented.value = AAZFloatType( + flags={"read_only": True}, + ) + + effective_price = cls._schema_on_200.value.Element.properties.effective_price + effective_price.currency = AAZStrType( + flags={"read_only": True}, + ) + effective_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + market_price = cls._schema_on_200.value.Element.properties.market_price + market_price.currency = AAZStrType( + flags={"read_only": True}, + ) + market_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_transaction_details = cls._schema_on_200.value.Element.properties.refund_transaction_details + refund_transaction_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_transaction_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_transaction_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + ) + + amount_refunded = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.value.Element.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax = cls._schema_on_200.value.Element.properties.tax + tax.currency = AAZStrType( + flags={"read_only": True}, + ) + tax.value = AAZFloatType( + flags={"read_only": True}, + ) + + transaction_amount = cls._schema_on_200.value.Element.properties.transaction_amount + transaction_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + transaction_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByBillingProfileHelper: + """Helper class for ListByBillingProfile""" + + +__all__ = ["ListByBillingProfile"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_customer.py b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_customer.py new file mode 100644 index 00000000000..827b128950c --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_customer.py @@ -0,0 +1,489 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transaction list-by-customer", +) +class ListByCustomer(AAZCommand): + """List the billed or unbilled transactions by customer id for given start date and end date. Transactions include purchases, refunds and Azure usage charges. Unbilled transactions are listed under pending invoice Id and do not include tax. Tax is added to the amount once an invoice is generated. + + :example: TransactionsListByCustomer + az billing transaction list-by-customer --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --customer-name 22000000-0000-0000-0000-000000000000 --period-start-date 2024-04-01 --period-end-date 2023-05-30 --type Billed --filter properties/date gt '2020-10-01' --search storage + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/customers/{}/transactions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.customer_name = AAZStrArg( + options=["--customer-name"], + help="The ID that uniquely identifies a customer.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.period_end_date = AAZDateArg( + options=["--period-end-date"], + help="The end date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + _args_schema.period_start_date = AAZDateArg( + options=["--period-start-date"], + help="The start date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + _args_schema.type = AAZStrArg( + options=["--type"], + help="The type of transaction.", + required=True, + enum={"Billed": "Billed", "Other": "Other", "Unbilled": "Unbilled"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransactionsListByCustomer(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class TransactionsListByCustomer(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/transactions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "customerName", self.ctx.args.customer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "periodEndDate", self.ctx.args.period_end_date, + required=True, + ), + **self.serialize_query_param( + "periodStartDate", self.ctx.args.period_start_date, + required=True, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "type", self.ctx.args.type, + required=True, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.azure_credit_applied = AAZObjectType( + serialized_name="azureCreditApplied", + ) + properties.azure_plan = AAZStrType( + serialized_name="azurePlan", + ) + properties.billing_currency = AAZStrType( + serialized_name="billingCurrency", + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.consumption_commitment_decremented = AAZObjectType( + serialized_name="consumptionCommitmentDecremented", + ) + properties.credit_type = AAZStrType( + serialized_name="creditType", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.date = AAZStrType() + properties.discount = AAZFloatType() + properties.effective_price = AAZObjectType( + serialized_name="effectivePrice", + ) + properties.exchange_rate = AAZFloatType( + serialized_name="exchangeRate", + ) + properties.invoice = AAZStrType() + properties.invoice_id = AAZStrType( + serialized_name="invoiceId", + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.is_third_party = AAZBoolType( + serialized_name="isThirdParty", + ) + properties.kind = AAZStrType() + properties.market_price = AAZObjectType( + serialized_name="marketPrice", + ) + properties.part_number = AAZStrType( + serialized_name="partNumber", + ) + properties.pricing_currency = AAZStrType( + serialized_name="pricingCurrency", + ) + properties.product_description = AAZStrType( + serialized_name="productDescription", + ) + properties.product_family = AAZStrType( + serialized_name="productFamily", + ) + properties.product_type = AAZStrType( + serialized_name="productType", + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.quantity = AAZIntType() + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.refund_transaction_details = AAZObjectType( + serialized_name="refundTransactionDetails", + ) + properties.service_period_end_date = AAZStrType( + serialized_name="servicePeriodEndDate", + ) + properties.service_period_start_date = AAZStrType( + serialized_name="servicePeriodStartDate", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.tax = AAZObjectType() + properties.transaction_amount = AAZObjectType( + serialized_name="transactionAmount", + ) + properties.transaction_type = AAZStrType( + serialized_name="transactionType", + ) + properties.unit_of_measure = AAZStrType( + serialized_name="unitOfMeasure", + ) + properties.unit_type = AAZStrType( + serialized_name="unitType", + ) + properties.units = AAZFloatType() + + azure_credit_applied = cls._schema_on_200.value.Element.properties.azure_credit_applied + azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + consumption_commitment_decremented = cls._schema_on_200.value.Element.properties.consumption_commitment_decremented + consumption_commitment_decremented.currency = AAZStrType( + flags={"read_only": True}, + ) + consumption_commitment_decremented.value = AAZFloatType( + flags={"read_only": True}, + ) + + effective_price = cls._schema_on_200.value.Element.properties.effective_price + effective_price.currency = AAZStrType( + flags={"read_only": True}, + ) + effective_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + market_price = cls._schema_on_200.value.Element.properties.market_price + market_price.currency = AAZStrType( + flags={"read_only": True}, + ) + market_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_transaction_details = cls._schema_on_200.value.Element.properties.refund_transaction_details + refund_transaction_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_transaction_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_transaction_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + ) + + amount_refunded = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.value.Element.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax = cls._schema_on_200.value.Element.properties.tax + tax.currency = AAZStrType( + flags={"read_only": True}, + ) + tax.value = AAZFloatType( + flags={"read_only": True}, + ) + + transaction_amount = cls._schema_on_200.value.Element.properties.transaction_amount + transaction_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + transaction_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByCustomerHelper: + """Helper class for ListByCustomer""" + + +__all__ = ["ListByCustomer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_invoice.py b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_invoice.py new file mode 100644 index 00000000000..36bf1f4581a --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_invoice.py @@ -0,0 +1,449 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transaction list-by-invoice", +) +class ListByInvoice(AAZCommand): + """List the transactions for an invoice. Transactions include purchases, refunds and Azure usage charges. + + :example: TransactionsListByInvoice + az billing transaction list-by-invoice --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --invoice-name G123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices/{}/transactions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransactionsListByInvoice(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class TransactionsListByInvoice(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.azure_credit_applied = AAZObjectType( + serialized_name="azureCreditApplied", + ) + properties.azure_plan = AAZStrType( + serialized_name="azurePlan", + ) + properties.billing_currency = AAZStrType( + serialized_name="billingCurrency", + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.consumption_commitment_decremented = AAZObjectType( + serialized_name="consumptionCommitmentDecremented", + ) + properties.credit_type = AAZStrType( + serialized_name="creditType", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.date = AAZStrType() + properties.discount = AAZFloatType() + properties.effective_price = AAZObjectType( + serialized_name="effectivePrice", + ) + properties.exchange_rate = AAZFloatType( + serialized_name="exchangeRate", + ) + properties.invoice = AAZStrType() + properties.invoice_id = AAZStrType( + serialized_name="invoiceId", + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.is_third_party = AAZBoolType( + serialized_name="isThirdParty", + ) + properties.kind = AAZStrType() + properties.market_price = AAZObjectType( + serialized_name="marketPrice", + ) + properties.part_number = AAZStrType( + serialized_name="partNumber", + ) + properties.pricing_currency = AAZStrType( + serialized_name="pricingCurrency", + ) + properties.product_description = AAZStrType( + serialized_name="productDescription", + ) + properties.product_family = AAZStrType( + serialized_name="productFamily", + ) + properties.product_type = AAZStrType( + serialized_name="productType", + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.quantity = AAZIntType() + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.refund_transaction_details = AAZObjectType( + serialized_name="refundTransactionDetails", + ) + properties.service_period_end_date = AAZStrType( + serialized_name="servicePeriodEndDate", + ) + properties.service_period_start_date = AAZStrType( + serialized_name="servicePeriodStartDate", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.tax = AAZObjectType() + properties.transaction_amount = AAZObjectType( + serialized_name="transactionAmount", + ) + properties.transaction_type = AAZStrType( + serialized_name="transactionType", + ) + properties.unit_of_measure = AAZStrType( + serialized_name="unitOfMeasure", + ) + properties.unit_type = AAZStrType( + serialized_name="unitType", + ) + properties.units = AAZFloatType() + + azure_credit_applied = cls._schema_on_200.value.Element.properties.azure_credit_applied + azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + consumption_commitment_decremented = cls._schema_on_200.value.Element.properties.consumption_commitment_decremented + consumption_commitment_decremented.currency = AAZStrType( + flags={"read_only": True}, + ) + consumption_commitment_decremented.value = AAZFloatType( + flags={"read_only": True}, + ) + + effective_price = cls._schema_on_200.value.Element.properties.effective_price + effective_price.currency = AAZStrType( + flags={"read_only": True}, + ) + effective_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + market_price = cls._schema_on_200.value.Element.properties.market_price + market_price.currency = AAZStrType( + flags={"read_only": True}, + ) + market_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_transaction_details = cls._schema_on_200.value.Element.properties.refund_transaction_details + refund_transaction_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_transaction_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_transaction_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + ) + + amount_refunded = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.value.Element.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax = cls._schema_on_200.value.Element.properties.tax + tax.currency = AAZStrType( + flags={"read_only": True}, + ) + tax.value = AAZFloatType( + flags={"read_only": True}, + ) + + transaction_amount = cls._schema_on_200.value.Element.properties.transaction_amount + transaction_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + transaction_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceHelper: + """Helper class for ListByInvoice""" + + +__all__ = ["ListByInvoice"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_invoice_section.py b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_invoice_section.py new file mode 100644 index 00000000000..4f807c17c6e --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/_list_by_invoice_section.py @@ -0,0 +1,489 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transaction list-by-invoice-section", +) +class ListByInvoiceSection(AAZCommand): + """List the billed or unbilled transactions by invoice section name for given start date and end date. Transactions include purchases, refunds and Azure usage charges. Unbilled transactions are listed under pending invoice Id and do not include tax. Tax is added to the amount once an invoice is generated. + + :example: TransactionsListByInvoiceSection + az billing transaction list-by-invoice-section --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name 22000000-0000-0000-0000-000000000000 --period-start-date 2024-04-01 --period-end-date 2023-05-30 --type Billed --filter properties/date gt '2020-10-01' --search storage + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/transactions", "2024-04-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="The count query option allows clients to request a count of the matching resources included with the resources in the response.", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The filter query option allows clients to filter a collection of resources that are addressed by a request URL.", + ) + _args_schema.order_by = AAZStrArg( + options=["--order-by"], + help="The orderby query option allows clients to request resources in a particular order.", + ) + _args_schema.period_end_date = AAZDateArg( + options=["--period-end-date"], + help="The end date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + _args_schema.period_start_date = AAZDateArg( + options=["--period-start-date"], + help="The start date to fetch the transactions. The date should be specified in MM-DD-YYYY format.", + required=True, + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="The search query option allows clients to request items within a collection matching a free-text search expression. search is only supported for string fields.", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The top query option requests the number of items in the queried collection to be included in the result. The maximum supported value for top is 50.", + ) + _args_schema.type = AAZStrArg( + options=["--type"], + help="The type of transaction.", + required=True, + enum={"Billed": "Billed", "Other": "Other", "Unbilled": "Unbilled"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransactionsListByInvoiceSection(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class TransactionsListByInvoiceSection(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transactions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "count", self.ctx.args.count, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "orderBy", self.ctx.args.order_by, + ), + **self.serialize_query_param( + "periodEndDate", self.ctx.args.period_end_date, + required=True, + ), + **self.serialize_query_param( + "periodStartDate", self.ctx.args.period_start_date, + required=True, + ), + **self.serialize_query_param( + "search", self.ctx.args.search, + ), + **self.serialize_query_param( + "skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "type", self.ctx.args.type, + required=True, + ), + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.azure_credit_applied = AAZObjectType( + serialized_name="azureCreditApplied", + ) + properties.azure_plan = AAZStrType( + serialized_name="azurePlan", + ) + properties.billing_currency = AAZStrType( + serialized_name="billingCurrency", + ) + properties.billing_profile_display_name = AAZStrType( + serialized_name="billingProfileDisplayName", + ) + properties.billing_profile_id = AAZStrType( + serialized_name="billingProfileId", + ) + properties.consumption_commitment_decremented = AAZObjectType( + serialized_name="consumptionCommitmentDecremented", + ) + properties.credit_type = AAZStrType( + serialized_name="creditType", + ) + properties.customer_display_name = AAZStrType( + serialized_name="customerDisplayName", + ) + properties.customer_id = AAZStrType( + serialized_name="customerId", + ) + properties.date = AAZStrType() + properties.discount = AAZFloatType() + properties.effective_price = AAZObjectType( + serialized_name="effectivePrice", + ) + properties.exchange_rate = AAZFloatType( + serialized_name="exchangeRate", + ) + properties.invoice = AAZStrType() + properties.invoice_id = AAZStrType( + serialized_name="invoiceId", + ) + properties.invoice_section_display_name = AAZStrType( + serialized_name="invoiceSectionDisplayName", + ) + properties.invoice_section_id = AAZStrType( + serialized_name="invoiceSectionId", + ) + properties.is_third_party = AAZBoolType( + serialized_name="isThirdParty", + ) + properties.kind = AAZStrType() + properties.market_price = AAZObjectType( + serialized_name="marketPrice", + ) + properties.part_number = AAZStrType( + serialized_name="partNumber", + ) + properties.pricing_currency = AAZStrType( + serialized_name="pricingCurrency", + ) + properties.product_description = AAZStrType( + serialized_name="productDescription", + ) + properties.product_family = AAZStrType( + serialized_name="productFamily", + ) + properties.product_type = AAZStrType( + serialized_name="productType", + ) + properties.product_type_id = AAZStrType( + serialized_name="productTypeId", + ) + properties.quantity = AAZIntType() + properties.reason_code = AAZStrType( + serialized_name="reasonCode", + ) + properties.refund_transaction_details = AAZObjectType( + serialized_name="refundTransactionDetails", + ) + properties.service_period_end_date = AAZStrType( + serialized_name="servicePeriodEndDate", + ) + properties.service_period_start_date = AAZStrType( + serialized_name="servicePeriodStartDate", + ) + properties.special_taxation_type = AAZStrType( + serialized_name="specialTaxationType", + ) + properties.sub_total = AAZObjectType( + serialized_name="subTotal", + ) + properties.tax = AAZObjectType() + properties.transaction_amount = AAZObjectType( + serialized_name="transactionAmount", + ) + properties.transaction_type = AAZStrType( + serialized_name="transactionType", + ) + properties.unit_of_measure = AAZStrType( + serialized_name="unitOfMeasure", + ) + properties.unit_type = AAZStrType( + serialized_name="unitType", + ) + properties.units = AAZFloatType() + + azure_credit_applied = cls._schema_on_200.value.Element.properties.azure_credit_applied + azure_credit_applied.currency = AAZStrType( + flags={"read_only": True}, + ) + azure_credit_applied.value = AAZFloatType( + flags={"read_only": True}, + ) + + consumption_commitment_decremented = cls._schema_on_200.value.Element.properties.consumption_commitment_decremented + consumption_commitment_decremented.currency = AAZStrType( + flags={"read_only": True}, + ) + consumption_commitment_decremented.value = AAZFloatType( + flags={"read_only": True}, + ) + + effective_price = cls._schema_on_200.value.Element.properties.effective_price + effective_price.currency = AAZStrType( + flags={"read_only": True}, + ) + effective_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + market_price = cls._schema_on_200.value.Element.properties.market_price + market_price.currency = AAZStrType( + flags={"read_only": True}, + ) + market_price.value = AAZFloatType( + flags={"read_only": True}, + ) + + refund_transaction_details = cls._schema_on_200.value.Element.properties.refund_transaction_details + refund_transaction_details.amount_refunded = AAZObjectType( + serialized_name="amountRefunded", + ) + refund_transaction_details.amount_requested = AAZObjectType( + serialized_name="amountRequested", + ) + refund_transaction_details.refund_operation_id = AAZStrType( + serialized_name="refundOperationId", + ) + + amount_refunded = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_refunded + amount_refunded.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_refunded.value = AAZFloatType( + flags={"read_only": True}, + ) + + amount_requested = cls._schema_on_200.value.Element.properties.refund_transaction_details.amount_requested + amount_requested.currency = AAZStrType( + flags={"read_only": True}, + ) + amount_requested.value = AAZFloatType( + flags={"read_only": True}, + ) + + sub_total = cls._schema_on_200.value.Element.properties.sub_total + sub_total.currency = AAZStrType( + flags={"read_only": True}, + ) + sub_total.value = AAZFloatType( + flags={"read_only": True}, + ) + + tax = cls._schema_on_200.value.Element.properties.tax + tax.currency = AAZStrType( + flags={"read_only": True}, + ) + tax.value = AAZFloatType( + flags={"read_only": True}, + ) + + transaction_amount = cls._schema_on_200.value.Element.properties.transaction_amount + transaction_amount.currency = AAZStrType( + flags={"read_only": True}, + ) + transaction_amount.value = AAZFloatType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListByInvoiceSectionHelper: + """Helper class for ListByInvoiceSection""" + + +__all__ = ["ListByInvoiceSection"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transaction/_transactions_download_by_invoice.py b/src/billing/azext_billing/aaz/latest/billing/transaction/_transactions_download_by_invoice.py new file mode 100644 index 00000000000..23ffbbb9c32 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transaction/_transactions_download_by_invoice.py @@ -0,0 +1,191 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transaction transactions-download-by-invoice", +) +class TransactionsDownloadByInvoice(AAZCommand): + """Gets a URL to download the transactions document for an invoice. The operation is supported for billing accounts with agreement type Enterprise Agreement. + + :example: TransactionsDownloadByInvoice + az billing transaction transactions-download-by-invoice --billing-account-name 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --invoice-name G123456789 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/invoices/{}/transactionsdownload", "2024-04-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.invoice_name = AAZStrArg( + options=["--invoice-name"], + help="The ID that uniquely identifies an invoice.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(H[0-9]-[A-Z0-9]+)$|^(?:([GHT]|HT){1}[A-Z0-9]{9})$|^(?:[D]{1}[A-Z0-9]{9})$|^(?:E{1}[B-Z0-9]{1}[A-Z0-9]{8})$|^(?:EA[A-Z0-9]{8})$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.TransactionsTransactionsDownloadByInvoice(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TransactionsTransactionsDownloadByInvoice(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactionsDownload", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "invoiceName", self.ctx.args.invoice_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.expiry_time = AAZStrType( + serialized_name="expiryTime", + flags={"read_only": True}, + ) + _schema_on_200.url = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _TransactionsDownloadByInvoiceHelper: + """Helper class for TransactionsDownloadByInvoice""" + + +__all__ = ["TransactionsDownloadByInvoice"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/__cmd_group.py b/src/billing/azext_billing/aaz/latest/billing/transfer/__cmd_group.py new file mode 100644 index 00000000000..950129e3e79 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "billing transfer", +) +class __CMDGroup(AAZCommandGroup): + """Get, List, Cancel, Initiate operations at Billing Account scope for Transfers and is only for customers on MCA and MPA + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/__init__.py b/src/billing/azext_billing/aaz/latest/billing/transfer/__init__.py new file mode 100644 index 00000000000..606c16b3eba --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/__init__.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._accept_transfer import * +from ._cancel import * +from ._get import * +from ._initiate import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/_accept_transfer.py b/src/billing/azext_billing/aaz/latest/billing/transfer/_accept_transfer.py new file mode 100644 index 00000000000..91be888bdc9 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/_accept_transfer.py @@ -0,0 +1,282 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transfer accept-transfer", +) +class AcceptTransfer(AAZCommand): + """Accepts a transfer request. + """ + + _aaz_info = { + "version": "2019-10-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers/{}/accepttransfer", "2019-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.product_details = AAZListArg( + options=["--product-details"], + arg_group="Properties", + help="Request parameters to accept transfer.", + ) + + product_details = cls._args_schema.product_details + product_details.Element = AAZObjectArg() + + _element = cls._args_schema.product_details.Element + _element.product_id = AAZStrArg( + options=["product-id"], + help="The ID of the product that is transferred.", + ) + _element.product_type = AAZStrArg( + options=["product-type"], + help="Type of the product that is transferred.", + enum={"AzureReservation": "AzureReservation", "AzureSubscription": "AzureSubscription"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersAccept(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class RecipientTransfersAccept(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers/{transferName}/acceptTransfer", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("productDetails", AAZListType, ".product_details") + + product_details = _builder.get(".properties.productDetails") + if product_details is not None: + product_details.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.productDetails[]") + if _elements is not None: + _elements.set_prop("productId", AAZStrType, ".product_id") + _elements.set_prop("productType", AAZStrType, ".product_type") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + + properties = cls._schema_on_200.properties + properties.allowed_product_type = AAZListType( + serialized_name="allowedProductType", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.creation_time = AAZStrType( + serialized_name="creationTime", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.last_modified_time = AAZStrType( + serialized_name="lastModifiedTime", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + allowed_product_type = cls._schema_on_200.properties.allowed_product_type + allowed_product_type.Element = AAZStrType() + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.error_code = AAZStrType( + serialized_name="errorCode", + flags={"read_only": True}, + ) + error_details.error_message = AAZStrType( + serialized_name="errorMessage", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _AcceptTransferHelper: + """Helper class for AcceptTransfer""" + + +__all__ = ["AcceptTransfer"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/_cancel.py b/src/billing/azext_billing/aaz/latest/billing/transfer/_cancel.py new file mode 100644 index 00000000000..ae03e40a191 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/_cancel.py @@ -0,0 +1,293 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transfer cancel", +) +class Cancel(AAZCommand): + """Cancels a transfer request. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: TransferCancel + az billing transfer cancel --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy --transfer-name aabb123 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/transfers/{}/cancel", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransfersCancel(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TransfersCancel(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}/cancel", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CancelHelper: + """Helper class for Cancel""" + + +__all__ = ["Cancel"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/_get.py b/src/billing/azext_billing/aaz/latest/billing/transfer/_get.py new file mode 100644 index 00000000000..f7915851280 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/_get.py @@ -0,0 +1,293 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transfer get", +) +class Get(AAZCommand): + """Get a transfer request by ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: TransferGet + az billing transfer get --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy --transfer-name aabb123 + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/transfers/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransfersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TransfersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetHelper: + """Helper class for Get""" + + +__all__ = ["Get"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/_initiate.py b/src/billing/azext_billing/aaz/latest/billing/transfer/_initiate.py new file mode 100644 index 00000000000..6f20693f0ca --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/_initiate.py @@ -0,0 +1,320 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transfer initiate", +) +class Initiate(AAZCommand): + """Create a request to a user in another billing account to transfer billing ownership of their subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + + :example: InitiateTransfer + az billing invoice-section transfer create --billing-account-name 10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31 --billing-profile-name xxxx-xxxx-xxx-xxx --invoice-section-name yyyy-yyyy-yyy-yyy --transfer-name aabb123 --recipient-email-id user@contoso.com + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/transfers/{}", "2024-04-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.recipient_email_id = AAZStrArg( + options=["--recipient-email-id"], + arg_group="Properties", + help="The email ID of the recipient to whom the transfer request is sent.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransfersInitiate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TransfersInitiate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("recipientEmailId", AAZStrType, ".recipient_email_id") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = cls._schema_on_200_201.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = cls._schema_on_200_201.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _InitiateHelper: + """Helper class for Initiate""" + + +__all__ = ["Initiate"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/_list.py b/src/billing/azext_billing/aaz/latest/billing/transfer/_list.py new file mode 100644 index 00000000000..f947c7fc236 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/_list.py @@ -0,0 +1,218 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transfer list", +) +class List(AAZCommand): + """List the transfer requests for an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + """ + + _aaz_info = { + "version": "2019-10-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers", "2019-10-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class RecipientTransfersList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.allowed_product_type = AAZListType( + serialized_name="allowedProductType", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.creation_time = AAZStrType( + serialized_name="creationTime", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.last_modified_time = AAZStrType( + serialized_name="lastModifiedTime", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + allowed_product_type = cls._schema_on_200.value.Element.properties.allowed_product_type + allowed_product_type.Element = AAZStrType() + + detailed_transfer_status = cls._schema_on_200.value.Element.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + error_details = cls._schema_on_200.value.Element.properties.detailed_transfer_status.Element.error_details + error_details.error_code = AAZStrType( + serialized_name="errorCode", + flags={"read_only": True}, + ) + error_details.error_message = AAZStrType( + serialized_name="errorMessage", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/_show.py b/src/billing/azext_billing/aaz/latest/billing/transfer/_show.py new file mode 100644 index 00000000000..7c28c42c245 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/_show.py @@ -0,0 +1,232 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transfer show", +) +class Show(AAZCommand): + """Get a transfer request by ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + """ + + _aaz_info = { + "version": "2019-10-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/transfers/{}", "2019-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.RecipientTransfersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class RecipientTransfersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + + properties = cls._schema_on_200.properties + properties.allowed_product_type = AAZListType( + serialized_name="allowedProductType", + flags={"read_only": True}, + ) + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.creation_time = AAZStrType( + serialized_name="creationTime", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_customer_type = AAZStrType( + serialized_name="initiatorCustomerType", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.last_modified_time = AAZStrType( + serialized_name="lastModifiedTime", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.reseller_id = AAZStrType( + serialized_name="resellerId", + flags={"read_only": True}, + ) + properties.reseller_name = AAZStrType( + serialized_name="resellerName", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + allowed_product_type = cls._schema_on_200.properties.allowed_product_type + allowed_product_type.Element = AAZStrType() + + detailed_transfer_status = cls._schema_on_200.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + ) + + error_details = cls._schema_on_200.properties.detailed_transfer_status.Element.error_details + error_details.error_code = AAZStrType( + serialized_name="errorCode", + flags={"read_only": True}, + ) + error_details.error_message = AAZStrType( + serialized_name="errorMessage", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/billing/azext_billing/aaz/latest/billing/transfer/_update.py b/src/billing/azext_billing/aaz/latest/billing/transfer/_update.py new file mode 100644 index 00000000000..9908fb94005 --- /dev/null +++ b/src/billing/azext_billing/aaz/latest/billing/transfer/_update.py @@ -0,0 +1,464 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "billing transfer update", +) +class Update(AAZCommand): + """Update a request to a user in another billing account to transfer billing ownership of their subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. + """ + + _aaz_info = { + "version": "2024-04-01", + "resources": [ + ["mgmt-plane", "/providers/microsoft.billing/billingaccounts/{}/billingprofiles/{}/invoicesections/{}/transfers/{}", "2024-04-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.billing_account_name = AAZStrArg( + options=["--billing-account-name"], + help="The ID that uniquely identifies a billing account.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([0-9]+|([Pp][Cc][Nn]\\.[A-Za-z0-9]+)|[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(:[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}_[0-9]{4}(-[0-9]{2}){2})?)$", + ), + ) + _args_schema.billing_profile_name = AAZStrArg( + options=["--billing-profile-name"], + help="The ID that uniquely identifies a billing profile.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.invoice_section_name = AAZStrArg( + options=["--invoice-section-name"], + help="The ID that uniquely identifies an invoice section.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,128}$", + ), + ) + _args_schema.transfer_name = AAZStrArg( + options=["--transfer-name"], + help="The ID that uniquely identifies a transfer request.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]*$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.recipient_email_id = AAZStrArg( + options=["--recipient-email-id"], + arg_group="Properties", + help="The email ID of the recipient to whom the transfer request is sent.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TransfersGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.TransfersInitiate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TransfersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_transfer_details_read(cls._schema_on_200) + + return cls._schema_on_200 + + class TransfersInitiate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "billingAccountName", self.ctx.args.billing_account_name, + required=True, + ), + **self.serialize_url_param( + "billingProfileName", self.ctx.args.billing_profile_name, + required=True, + ), + **self.serialize_url_param( + "invoiceSectionName", self.ctx.args.invoice_section_name, + required=True, + ), + **self.serialize_url_param( + "transferName", self.ctx.args.transfer_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-04-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_transfer_details_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("recipientEmailId", AAZStrType, ".recipient_email_id") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_transfer_details_read = None + + @classmethod + def _build_schema_transfer_details_read(cls, _schema): + if cls._schema_transfer_details_read is not None: + _schema.id = cls._schema_transfer_details_read.id + _schema.name = cls._schema_transfer_details_read.name + _schema.properties = cls._schema_transfer_details_read.properties + _schema.system_data = cls._schema_transfer_details_read.system_data + _schema.tags = cls._schema_transfer_details_read.tags + _schema.type = cls._schema_transfer_details_read.type + return + + cls._schema_transfer_details_read = _schema_transfer_details_read = AAZObjectType() + + transfer_details_read = _schema_transfer_details_read + transfer_details_read.id = AAZStrType( + flags={"read_only": True}, + ) + transfer_details_read.name = AAZStrType( + flags={"read_only": True}, + ) + transfer_details_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + transfer_details_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + transfer_details_read.tags = AAZDictType() + transfer_details_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_transfer_details_read.properties + properties.canceled_by = AAZStrType( + serialized_name="canceledBy", + flags={"read_only": True}, + ) + properties.detailed_transfer_status = AAZListType( + serialized_name="detailedTransferStatus", + flags={"read_only": True}, + ) + properties.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + properties.initiator_email_id = AAZStrType( + serialized_name="initiatorEmailId", + flags={"read_only": True}, + ) + properties.recipient_email_id = AAZStrType( + serialized_name="recipientEmailId", + flags={"read_only": True}, + ) + properties.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + detailed_transfer_status = _schema_transfer_details_read.properties.detailed_transfer_status + detailed_transfer_status.Element = AAZObjectType() + + _element = _schema_transfer_details_read.properties.detailed_transfer_status.Element + _element.error_details = AAZObjectType( + serialized_name="errorDetails", + ) + _element.product_id = AAZStrType( + serialized_name="productId", + flags={"read_only": True}, + ) + _element.product_name = AAZStrType( + serialized_name="productName", + flags={"read_only": True}, + ) + _element.product_type = AAZStrType( + serialized_name="productType", + flags={"read_only": True}, + ) + _element.sku_description = AAZStrType( + serialized_name="skuDescription", + flags={"read_only": True}, + ) + _element.transfer_status = AAZStrType( + serialized_name="transferStatus", + flags={"read_only": True}, + ) + + error_details = _schema_transfer_details_read.properties.detailed_transfer_status.Element.error_details + error_details.code = AAZStrType( + flags={"read_only": True}, + ) + error_details.message = AAZStrType( + flags={"read_only": True}, + ) + + system_data = _schema_transfer_details_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_transfer_details_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_transfer_details_read.id + _schema.name = cls._schema_transfer_details_read.name + _schema.properties = cls._schema_transfer_details_read.properties + _schema.system_data = cls._schema_transfer_details_read.system_data + _schema.tags = cls._schema_transfer_details_read.tags + _schema.type = cls._schema_transfer_details_read.type + + +__all__ = ["Update"] diff --git a/src/billing/azext_billing/azext_metadata.json b/src/billing/azext_billing/azext_metadata.json new file mode 100644 index 00000000000..b1e08d1f4b1 --- /dev/null +++ b/src/billing/azext_billing/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.61.0" +} \ No newline at end of file diff --git a/src/billing/azext_billing/commands.py b/src/billing/azext_billing/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/billing/azext_billing/commands.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): # pylint: disable=unused-argument + pass diff --git a/src/billing/azext_billing/custom.py b/src/billing/azext_billing/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/billing/azext_billing/custom.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger + + +logger = get_logger(__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..5757aea3175 --- /dev/null +++ b/src/billing/azext_billing/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- 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..5757aea3175 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/billing/azext_billing/tests/latest/recordings/test_address_validate.yaml b/src/billing/azext_billing/tests/latest/recordings/test_address_validate.yaml new file mode 100644 index 00000000000..c5a40460804 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_address_validate.yaml @@ -0,0 +1,63 @@ +interactions: +- request: + body: '{"addressLine1": "1 Microsoft Way", "city": "Redmond", "country": "US", + "postalCode": "98052", "region": "wa"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing address validate + Connection: + - keep-alive + Content-Length: + - '110' + Content-Type: + - application/json + ParameterSetName: + - --address-line1 --city --country --postal-code --region + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: POST + uri: https://management.azure.com/providers/Microsoft.Billing/validateAddress?api-version=2024-04-01 + response: + body: + string: '{"status":"Valid","suggestedAddresses":[{"addressLine1":"1 Microsoft + Way","city":"Redmond","country":"US","postalCode":"98052-8300","region":"WA","isValidAddress":true}]}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2022-10-01-privatepreview, 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '170' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:18:50 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-resource-requests: + - '99' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 849A9EBB47834650A78AADF48936D94A Ref B: CO6AA3150219053 Ref C: 2024-09-30T18:18:51Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/recordings/test_agreement_get_and_list.yaml b/src/billing/azext_billing/tests/latest/recordings/test_agreement_get_and_list.yaml new file mode 100644 index 00000000000..763217d8129 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_agreement_get_and_list.yaml @@ -0,0 +1,165 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing account list + Connection: + - keep-alive + ParameterSetName: + - --include-all + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts?includeAll=true&includeAllWithoutBillingProfiles=false&includeDeleted=false&includePendingAgreement=false&includeResellee=false&api-version=2024-04-01 + response: + body: + string: '{"value":[{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","name":"e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","properties":{"accountStatus":"Active","accountType":"Individual","accountSubType":"Professional","agreementType":"MicrosoftCustomerAgreement","displayName":"Account + Name Updated Via CLI Test","hasReadAccess":true,"primaryBillingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","billingRelationshipTypes":["Direct"],"qualifications":["Commercial"]},"type":"Microsoft.Billing/billingAccounts"},{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31","name":"e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31","properties":{"accountStatus":"Active","accountType":"Individual","accountSubType":"Professional","agreementType":"MicrosoftCustomerAgreement","displayName":"SMB + Account 1","hasReadAccess":true,"primaryBillingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","registrationNumber":{"id":"12345678","required":false,"type":["RegistrationNumber"]},"billingRelationshipTypes":["Direct"],"qualifications":["Commercial"]},"type":"Microsoft.Billing/billingAccounts"}]}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2022-10-01-privatepreview, 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '1327' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:27:17 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 91AF8583F7F74A25A9C932659438972C Ref B: CO6AA3150218011 Ref C: 2024-09-30T18:27:17Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing agreement list-by-billing-account + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3Aefd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31/agreements?api-version=2024-04-01 + response: + body: + string: '{"value":[{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31/agreements/5CD4D96401D9","name":"5CD4D96401D9","properties":{"acceptanceMode":"ClickToAccept","agreementLink":"https://wopihost.l2o.microsoft.com/v1/officehost/agreement/files/68188751-0eec-4fe4-a4a7-f76c8eccbc68?accesstoken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImUyNjFlZjQwLTM1MTctNTE1ZC0zNjgwLThiZTQyNTJhZTE0OF9lZmQ0NWQxNC1lNDU5LTRiZDctYTg4My1mM2IxNzZkMGMzMzVfMjAxOS0wNS0zMSIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2NvbnRhaW5lciI6ImFncmVlbWVudHMiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9kb2N1bWVudGlkcyI6IjY4MTg4NzUxLTBlZWMtNGZlNC1hNGE3LWY3NmM4ZWNjYmM2OCIsIm5iZiI6MTcyNzcyMDgzOCwiZXhwIjoxNzI3NzMxNjM4LCJpYXQiOjE3Mjc3MjA4MzgsImlzcyI6Imh0dHBzOi8vd29waWhvc3QuaW50Lmwyby5taWNyb3NvZnQuY29tIiwiYXVkIjoiaHR0cHM6Ly93b3BpaG9zdC5pbnQubDJvLm1pY3Jvc29mdC5jb20ifQ.hBBci11SfoQzJenaxUbZMK2gAtQeYKGSKDkqFG9W8ic","category":"MicrosoftCustomerAgreement","displayName":"Microsoft + Customer Agreement","effectiveDate":"2024-09-26T21:45:27.5582197Z","expirationDate":"9999-12-31T00:00:00.0000000Z","status":"Active"},"type":"Microsoft.Billing/billingAccounts/agreements"}]}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01 + cache-control: + - no-cache + content-length: + - '1288' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:27:17 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 2CBEE79CA45F46BD86C714FB942C9B23 Ref B: CO6AA3150218039 Ref C: 2024-09-30T18:27:18Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing agreement get + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --agreement-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3Aefd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31/agreements/5CD4D96401D9?api-version=2024-04-01 + response: + body: + string: '{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31/agreements/5CD4D96401D9","name":"5CD4D96401D9","properties":{"acceptanceMode":"ClickToAccept","agreementLink":"https://wopihost.l2o.microsoft.com/v1/officehost/agreement/files/68188751-0eec-4fe4-a4a7-f76c8eccbc68?accesstoken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImUyNjFlZjQwLTM1MTctNTE1ZC0zNjgwLThiZTQyNTJhZTE0OF9lZmQ0NWQxNC1lNDU5LTRiZDctYTg4My1mM2IxNzZkMGMzMzVfMjAxOS0wNS0zMSIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2NvbnRhaW5lciI6ImFncmVlbWVudHMiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9kb2N1bWVudGlkcyI6IjY4MTg4NzUxLTBlZWMtNGZlNC1hNGE3LWY3NmM4ZWNjYmM2OCIsIm5iZiI6MTcyNzcyMDgzOCwiZXhwIjoxNzI3NzMxNjM4LCJpYXQiOjE3Mjc3MjA4MzgsImlzcyI6Imh0dHBzOi8vd29waWhvc3QuaW50Lmwyby5taWNyb3NvZnQuY29tIiwiYXVkIjoiaHR0cHM6Ly93b3BpaG9zdC5pbnQubDJvLm1pY3Jvc29mdC5jb20ifQ.hBBci11SfoQzJenaxUbZMK2gAtQeYKGSKDkqFG9W8ic","category":"MicrosoftCustomerAgreement","displayName":"Microsoft + Customer Agreement","effectiveDate":"2024-09-26T21:45:27.5582197Z","expirationDate":"9999-12-31T00:00:00.0000000Z","participants":[{"status":"Accepted","statusDate":"2024-09-26T21:45:27.5582197Z"}],"status":"Active"},"type":"Microsoft.Billing/billingAccounts/agreements"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01 + cache-control: + - no-cache + content-length: + - '1359' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:27:17 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 81277E3AA5024AEC863C23B0715F98E8 Ref B: CO6AA3150220053 Ref C: 2024-09-30T18:27:18Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/recordings/test_get_billing_prooperty.yaml b/src/billing/azext_billing/tests/latest/recordings/test_get_billing_prooperty.yaml new file mode 100644 index 00000000000..680175b084d --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_get_billing_prooperty.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing billing-property get + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingProperty/default?includeBillingCountry=false&includeTransitionStatus=false&api-version=2024-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingProperty/default","name":"default","properties":{"billingAccountAgreementType":"MicrosoftCustomerAgreement","billingAccountDisplayName":"SMB + Account 1","billingAccountId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31","billingAccountStatus":"Active","billingAccountType":"Individual","billingAccountSubType":"Other","billingCurrency":"USD","billingProfileDisplayName":"Microsoft","billingProfileId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB","billingProfileSpendingLimit":"Off","billingProfileSpendingLimitDetails":[{"startDate":"2024-07-09T00:00:00.0000000Z","type":"Sandbox","status":"Active"}],"billingProfileStatus":"Active","billingProfilePaymentMethodFamily":"Other","billingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","invoiceSectionDisplayName":"Microsoft + (P10109641)","invoiceSectionId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/DVPC-HA6G-PJA-MAOR-SGB","invoiceSectionStatus":"Active","skuDescription":"Microsoft + Azure Plan","skuId":"0001","subscriptionBillingStatus":"Active","subscriptionBillingType":"Paid","subscriptionWorkloadType":"Production","productId":"DZH318Z0BPS6","productName":"Microsoft"},"type":"Microsoft.Billing/billingProperty"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-10-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '1612' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 19:10:42 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-subscription-global-reads: + - '3749' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: FE4D98D6BD7D4510B5A3DFE51832534D Ref B: CO6AA3150217025 Ref C: 2024-09-30T19:10:42Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/recordings/test_list_accounts.yaml b/src/billing/azext_billing/tests/latest/recordings/test_list_accounts.yaml new file mode 100644 index 00000000000..45e205db5cb --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_list_accounts.yaml @@ -0,0 +1,175 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing account list + Connection: + - keep-alive + ParameterSetName: + - --include-all + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts?includeAll=true&includeAllWithoutBillingProfiles=false&includeDeleted=false&includePendingAgreement=false&includeResellee=false&api-version=2024-04-01 + response: + body: + string: '{"value":[{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","name":"e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","properties":{"accountStatus":"Active","accountType":"Individual","accountSubType":"Professional","agreementType":"MicrosoftCustomerAgreement","displayName":"Account + Name Updated Via CLI Test","hasReadAccess":true,"primaryBillingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","billingRelationshipTypes":["Direct"],"qualifications":["Commercial"]},"type":"Microsoft.Billing/billingAccounts"},{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31","name":"e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31","properties":{"accountStatus":"Active","accountType":"Individual","accountSubType":"Professional","agreementType":"MicrosoftCustomerAgreement","displayName":"SMB + Account 1","hasReadAccess":true,"primaryBillingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","registrationNumber":{"id":"12345678","required":false,"type":["RegistrationNumber"]},"billingRelationshipTypes":["Direct"],"qualifications":["Commercial"]},"type":"Microsoft.Billing/billingAccounts"}]}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2022-10-01-privatepreview, 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '1327' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:17:38 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: BE83FEACCBE944448C6946D04C71CE16 Ref B: CO6AA3150219025 Ref C: 2024-09-30T18:17:38Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing account get + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3Aefd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31?api-version=2024-04-01 + response: + body: + string: '{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","name":"e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","properties":{"accountStatus":"Active","accountType":"Individual","accountSubType":"Professional","agreementType":"MicrosoftCustomerAgreement","displayName":"Account + Name Updated Via CLI Test","hasReadAccess":true,"primaryBillingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","soldTo":{"addressLine1":"1 + Microsoft Way","city":"Redmond","companyName":"BillingRP CLI","country":"US","postalCode":"98052","region":"WA","isValidAddress":true},"registrationNumber":{"required":false,"type":["RegistrationNumber"]},"billingRelationshipTypes":["Direct"],"qualifications":["Commercial"]},"type":"Microsoft.Billing/billingAccounts"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2022-10-01-privatepreview, 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '857' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:17:38 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 09986DEF57CC45309EB5CFEEA491BE63 Ref B: CO6AA3150218021 Ref C: 2024-09-30T18:17:39Z' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"displayName": "Account Name Updated Via CLI Test", "soldTo": + {"addressLine1": "1 Microsoft Way", "city": "Redmond", "companyName": "BillingRP + CLI", "country": "US", "postalCode": "98052", "region": "WA"}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing account update + Connection: + - keep-alive + Content-Length: + - '222' + Content-Type: + - application/json + ParameterSetName: + - --billing-account-name --display-name --sold-to + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: PATCH + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3Aefd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31?api-version=2024-04-01 + response: + body: + string: '{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","name":"e261ef40-3517-515d-3680-8be4252ae148:efd45d14-e459-4bd7-a883-f3b176d0c335_2019-05-31","properties":{"accountStatus":"Active","accountType":"Business","accountSubType":"Professional","agreementType":"MicrosoftCustomerAgreement","displayName":"Account + Name Updated Via CLI Test","hasReadAccess":true,"primaryBillingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","soldTo":{"addressLine1":"1 + Microsoft Way","city":"Redmond","companyName":"BillingRP CLI","country":"US","postalCode":"98052","region":"WA","isValidAddress":true},"registrationNumber":{"required":false,"type":["RegistrationNumber"]},"billingRelationshipTypes":["Direct"],"qualifications":["Commercial"]},"type":"Microsoft.Billing/billingAccounts"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2022-10-01-privatepreview, 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '855' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:17:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-writes: + - '199' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 5F85F68B40674C93A5C9D261E6994C51 Ref B: CO6AA3150220017 Ref C: 2024-09-30T18:17:39Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/recordings/test_list_invoice_sections.yaml b/src/billing/azext_billing/tests/latest/recordings/test_list_invoice_sections.yaml new file mode 100644 index 00000000000..7001ac61687 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_list_invoice_sections.yaml @@ -0,0 +1,496 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section list-by-billing-profile + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3A0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections?includeDeleted=false&api-version=2024-04-01 + response: + body: + string: '{"totalCount":2,"value":[{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI","name":"InvoiceSectionViaCLI","properties":{"displayName":"Invoice + Section Updated","state":"Active","systemId":"UGYN-BKDH-PJA-MAOR-SGB"},"type":"Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"},{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/DVPC-HA6G-PJA-MAOR-SGB","name":"DVPC-HA6G-PJA-MAOR-SGB","properties":{"displayName":"Microsoft + (P10109641)","state":"Active","systemId":"DVPC-HA6G-PJA-MAOR-SGB"},"type":"Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections","tags":{"pcCode":"P10109641","serviceTreeId":"a9305e6b-3d6c-477c-b3cf-1a81498037be"}}]}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '969' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 01 Oct 2024 17:31:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-resource-requests: + - '98' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: BA074B3D614149BF94B25D0AE9E4B490 Ref B: CO6AA3150217021 Ref C: 2024-10-01T17:31:12Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section get + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3A0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI?api-version=2024-04-01 + response: + body: + string: '{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI","name":"InvoiceSectionViaCLI","properties":{"displayName":"Invoice + Section Updated","state":"Active","systemId":"UGYN-BKDH-PJA-MAOR-SGB"},"type":"Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '427' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 01 Oct 2024 17:31:12 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-resource-requests: + - '99' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 6B9195AF553C4DA997343B6306E430FA Ref B: CO6AA3150217051 Ref C: 2024-10-01T17:31:12Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section validate-delete-eligibility + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: POST + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3A0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI/validateDeleteEligibility?api-version=2024-04-01 + response: + body: + string: '{"eligibilityStatus":"Allowed"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '31' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 01 Oct 2024 17:31:12 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-writes: + - '199' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 78A24A66728048849E7F98896A7DD735 Ref B: CO6AA3150219045 Ref C: 2024-10-01T17:31:12Z' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"displayName": "Invoice Section 1"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section create + Connection: + - keep-alive + Content-Length: + - '52' + Content-Type: + - application/json + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name --display-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3A0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI?api-version=2024-04-01 + response: + body: + string: '' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '0' + date: + - Tue, 01 Oct 2024 17:31:14 GMT + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_79df231a-88aa-484a-9c83-aa84e7b0f11b?api-version=2024-04-01&t=638634006746053276&c=MIIHhzCCBm-gAwIBAgITHgVxvH65_BmPrKxDIgAABXG8fjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjQwOTI1MTkzNzA4WhcNMjUwMzI0MTkzNzA4WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKlHcl7gn1b6aLS1hLftgvWE8n-Z9liLRsNGgjYfyY_1N6TVDEHJTtctREIaCRDPEC-hePKBe7OS45JIAD6cl5AGU_dQlGd-3bBZeVfAPJFUnC910pwhDca2OXlf4LyB1KSofXaA4xDB6G7cHXRld_URCnol2LHQEGox0vBzaPz30AUB0ZhAatZgqhXy5qnroV3zbEZC3m4qLDSnG8QNEnw8Wv5GpYH_MxK9mgDPwoIObeDBnjtQonKzvItZ8jXwF-wEmcVAnhr6Dvq3rWdBY9616kXvQ7E3eEvGqMn9W_NZTAqlaanfaACfITkIJZkgsSoJGw5USCMC-vzAb1Ms0j0CAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBTELag1gS_F07Xj1us9l4ySYrHYYjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBABJx3Gb3LtjBZ4x70SioNIk8ap3qwt2DMEu9dXEhi28jFB87BBsTCkNeuhGlLzHm7Ykx6xpUjJp4F2_qmJKrQjDH4U0VYT_yc8Ow5mxrFJcewgTXzwmwqXOodok5WWOUVP4Mmdp_O_3je1dVgw4TrdrypIZImBn2jVDrXQ79fFXTR-Td0XMOtWPDwreoMRagD769QW4hlGtVaZCqOAzyomfSc8PhDzKhllbZQrmP-UgiLU14SDsxwq6AHG413ClcJIDGfEsEKwlUyIIAKHDwSdbO41Zs7ZQG5k_eBlGTkr-5Zye8vT7OeGf1_mGZSme6otyTUL_3-6gJ282qCPXoflc&s=V970lXNtSBjvY5oo3Z0rQ1W0rGO6QoQmJa3uagtPuWAvPm8obOBxyHYF1JrGx93VD3ujehpRlUu5so1ZVCu_7IhEvxo5FPjD_BqeuawWbQjgiLcUFPJFaD0AkJJavlIp1QN7iM21wEBbm0ipUb1S25zUSkGHVvbCphop0borvN0l6aaD8aFA0bWy46aP5jrZSIhCIr5AJaP7ig9_2xCG42CW2gyimQvcK_zf78Bb_zVf74tN6v6FfxOjvZ3ImK4a3INOs4sORSrA5cMpXxbzd384h4qii9Urj8Bh3kb5mktZcBFtUDbK23m-lIg-hP5hT9yiQxXohZlx9cqi8JHrwg&h=pkzfwRMLm38VBknQx7u9Ric_xhqajvbTKU-vmuKTnJc + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-writes: + - '199' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 78EAC9A38C0F496E964E7E7A5DF6B5BB Ref B: CO6AA3150218039 Ref C: 2024-10-01T17:31:13Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section create + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name --display-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_79df231a-88aa-484a-9c83-aa84e7b0f11b?api-version=2024-04-01&t=638634006746053276&c=MIIHhzCCBm-gAwIBAgITHgVxvH65_BmPrKxDIgAABXG8fjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjQwOTI1MTkzNzA4WhcNMjUwMzI0MTkzNzA4WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKlHcl7gn1b6aLS1hLftgvWE8n-Z9liLRsNGgjYfyY_1N6TVDEHJTtctREIaCRDPEC-hePKBe7OS45JIAD6cl5AGU_dQlGd-3bBZeVfAPJFUnC910pwhDca2OXlf4LyB1KSofXaA4xDB6G7cHXRld_URCnol2LHQEGox0vBzaPz30AUB0ZhAatZgqhXy5qnroV3zbEZC3m4qLDSnG8QNEnw8Wv5GpYH_MxK9mgDPwoIObeDBnjtQonKzvItZ8jXwF-wEmcVAnhr6Dvq3rWdBY9616kXvQ7E3eEvGqMn9W_NZTAqlaanfaACfITkIJZkgsSoJGw5USCMC-vzAb1Ms0j0CAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBTELag1gS_F07Xj1us9l4ySYrHYYjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBABJx3Gb3LtjBZ4x70SioNIk8ap3qwt2DMEu9dXEhi28jFB87BBsTCkNeuhGlLzHm7Ykx6xpUjJp4F2_qmJKrQjDH4U0VYT_yc8Ow5mxrFJcewgTXzwmwqXOodok5WWOUVP4Mmdp_O_3je1dVgw4TrdrypIZImBn2jVDrXQ79fFXTR-Td0XMOtWPDwreoMRagD769QW4hlGtVaZCqOAzyomfSc8PhDzKhllbZQrmP-UgiLU14SDsxwq6AHG413ClcJIDGfEsEKwlUyIIAKHDwSdbO41Zs7ZQG5k_eBlGTkr-5Zye8vT7OeGf1_mGZSme6otyTUL_3-6gJ282qCPXoflc&s=V970lXNtSBjvY5oo3Z0rQ1W0rGO6QoQmJa3uagtPuWAvPm8obOBxyHYF1JrGx93VD3ujehpRlUu5so1ZVCu_7IhEvxo5FPjD_BqeuawWbQjgiLcUFPJFaD0AkJJavlIp1QN7iM21wEBbm0ipUb1S25zUSkGHVvbCphop0borvN0l6aaD8aFA0bWy46aP5jrZSIhCIr5AJaP7ig9_2xCG42CW2gyimQvcK_zf78Bb_zVf74tN6v6FfxOjvZ3ImK4a3INOs4sORSrA5cMpXxbzd384h4qii9Urj8Bh3kb5mktZcBFtUDbK23m-lIg-hP5hT9yiQxXohZlx9cqi8JHrwg&h=pkzfwRMLm38VBknQx7u9Ric_xhqajvbTKU-vmuKTnJc + response: + body: + string: '' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '0' + date: + - Tue, 01 Oct 2024 17:31:14 GMT + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_79df231a-88aa-484a-9c83-aa84e7b0f11b?api-version=2024-04-01&t=638634006747161025&c=MIIHhzCCBm-gAwIBAgITHgVxvH65_BmPrKxDIgAABXG8fjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjQwOTI1MTkzNzA4WhcNMjUwMzI0MTkzNzA4WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKlHcl7gn1b6aLS1hLftgvWE8n-Z9liLRsNGgjYfyY_1N6TVDEHJTtctREIaCRDPEC-hePKBe7OS45JIAD6cl5AGU_dQlGd-3bBZeVfAPJFUnC910pwhDca2OXlf4LyB1KSofXaA4xDB6G7cHXRld_URCnol2LHQEGox0vBzaPz30AUB0ZhAatZgqhXy5qnroV3zbEZC3m4qLDSnG8QNEnw8Wv5GpYH_MxK9mgDPwoIObeDBnjtQonKzvItZ8jXwF-wEmcVAnhr6Dvq3rWdBY9616kXvQ7E3eEvGqMn9W_NZTAqlaanfaACfITkIJZkgsSoJGw5USCMC-vzAb1Ms0j0CAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBTELag1gS_F07Xj1us9l4ySYrHYYjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBABJx3Gb3LtjBZ4x70SioNIk8ap3qwt2DMEu9dXEhi28jFB87BBsTCkNeuhGlLzHm7Ykx6xpUjJp4F2_qmJKrQjDH4U0VYT_yc8Ow5mxrFJcewgTXzwmwqXOodok5WWOUVP4Mmdp_O_3je1dVgw4TrdrypIZImBn2jVDrXQ79fFXTR-Td0XMOtWPDwreoMRagD769QW4hlGtVaZCqOAzyomfSc8PhDzKhllbZQrmP-UgiLU14SDsxwq6AHG413ClcJIDGfEsEKwlUyIIAKHDwSdbO41Zs7ZQG5k_eBlGTkr-5Zye8vT7OeGf1_mGZSme6otyTUL_3-6gJ282qCPXoflc&s=E0mcxqiyy2cQWkJikU4iQA-kqsMhL_nCIBp6M2XJVCZvCz0Jv27jOJ2qoF2GldqKra-UfQKBjSU3CCFsz3A4NM4Jf75KDPu2yvHOv99_xkOfXLExnqL2uFLIvC5EPqRz6OOJrb2KouDz-3kq332IlHGBlP9m-mHIrpDjB5u7-TjnLWIrZfWeg3stt7usfcSHR2xb3gbJtIq6qY6pxoQsvZNst79VWCJGB7UANB8trVJ9p5Og3u-FJYMm6O1r5jMMxLKetcprQdeYEyALYscYnnznsXDhTPJEGopzluHRoXyBmU-e21pBG6dcdK101GTsG2-UK_1WT6mKAs3tze2AdA&h=tAR6bZWH40y_JusFrzBsIBW26Gt1MWcPkaXc5lf_tkQ + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 8BEA666A62134735B403880F656651DB Ref B: CO6AA3150218039 Ref C: 2024-10-01T17:31:14Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section create + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name --display-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_79df231a-88aa-484a-9c83-aa84e7b0f11b?api-version=2024-04-01&t=638634006747161025&c=MIIHhzCCBm-gAwIBAgITHgVxvH65_BmPrKxDIgAABXG8fjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjQwOTI1MTkzNzA4WhcNMjUwMzI0MTkzNzA4WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKlHcl7gn1b6aLS1hLftgvWE8n-Z9liLRsNGgjYfyY_1N6TVDEHJTtctREIaCRDPEC-hePKBe7OS45JIAD6cl5AGU_dQlGd-3bBZeVfAPJFUnC910pwhDca2OXlf4LyB1KSofXaA4xDB6G7cHXRld_URCnol2LHQEGox0vBzaPz30AUB0ZhAatZgqhXy5qnroV3zbEZC3m4qLDSnG8QNEnw8Wv5GpYH_MxK9mgDPwoIObeDBnjtQonKzvItZ8jXwF-wEmcVAnhr6Dvq3rWdBY9616kXvQ7E3eEvGqMn9W_NZTAqlaanfaACfITkIJZkgsSoJGw5USCMC-vzAb1Ms0j0CAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBTELag1gS_F07Xj1us9l4ySYrHYYjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBABJx3Gb3LtjBZ4x70SioNIk8ap3qwt2DMEu9dXEhi28jFB87BBsTCkNeuhGlLzHm7Ykx6xpUjJp4F2_qmJKrQjDH4U0VYT_yc8Ow5mxrFJcewgTXzwmwqXOodok5WWOUVP4Mmdp_O_3je1dVgw4TrdrypIZImBn2jVDrXQ79fFXTR-Td0XMOtWPDwreoMRagD769QW4hlGtVaZCqOAzyomfSc8PhDzKhllbZQrmP-UgiLU14SDsxwq6AHG413ClcJIDGfEsEKwlUyIIAKHDwSdbO41Zs7ZQG5k_eBlGTkr-5Zye8vT7OeGf1_mGZSme6otyTUL_3-6gJ282qCPXoflc&s=E0mcxqiyy2cQWkJikU4iQA-kqsMhL_nCIBp6M2XJVCZvCz0Jv27jOJ2qoF2GldqKra-UfQKBjSU3CCFsz3A4NM4Jf75KDPu2yvHOv99_xkOfXLExnqL2uFLIvC5EPqRz6OOJrb2KouDz-3kq332IlHGBlP9m-mHIrpDjB5u7-TjnLWIrZfWeg3stt7usfcSHR2xb3gbJtIq6qY6pxoQsvZNst79VWCJGB7UANB8trVJ9p5Og3u-FJYMm6O1r5jMMxLKetcprQdeYEyALYscYnnznsXDhTPJEGopzluHRoXyBmU-e21pBG6dcdK101GTsG2-UK_1WT6mKAs3tze2AdA&h=tAR6bZWH40y_JusFrzBsIBW26Gt1MWcPkaXc5lf_tkQ + response: + body: + string: '{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI","name":"InvoiceSectionViaCLI","properties":{"displayName":"Invoice + Section 1","state":"Active","systemId":"UGYN-BKDH-PJA-MAOR-SGB"},"type":"Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '421' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 01 Oct 2024 17:31:24 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 041B16DA99994F83B55D37219111AA5D Ref B: CO6AA3150218039 Ref C: 2024-10-01T17:31:24Z' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"displayName": "Invoice Section Updated"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section create + Connection: + - keep-alive + Content-Length: + - '58' + Content-Type: + - application/json + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name --display-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3A0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI?api-version=2024-04-01 + response: + body: + string: '' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '0' + date: + - Tue, 01 Oct 2024 17:31:25 GMT + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_171e11f7-de0e-48fe-9536-e7d5b17131b2?api-version=2024-04-01&t=638634006864260115&c=MIIHpTCCBo2gAwIBAgITOgM6dTLGpzYZpvPtgQAEAzp1MjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSU5GUkEgQ0EgMDEwHhcNMjQwNjI2MDEzMjIxWhcNMjUwNjIxMDEzMjIxWjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPPPKY5bDN03KptFFhiyLIyn86BlrXYFIZWYXA-hY7_WbLyWN0IxcLIUBW_I-9u-YsXOHk9WPMlUYHIFPgHW7A3FsSGfl9dd6YGapKoSSw0NkTpNXM58R54BBgLp7AhiWzK15D9T-XELNSU4Wq9sEeA5T24kazcgS2MUkzELH0I9dwu7g0dwJIuIJkoJjEzg1b1Q3Ie5HKHHNbjottJn7Q5LBS-9QtQyruuwaNTgSJpCoi4PBKVIOTBYL_Nv1wecmKmfWcT0mnhQE9zjhJTbcoN9hKSvAMqsDHtxWUFZosiw3JKIY0zb59CrVGSuOhfN3qaarwN9EAlXLqc4ZyKpsTkCAwEAAaOCBJIwggSOMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFggvX2K4Py0SACAWQCAQowggHaBggrBgEFBQcBAQSCAcwwggHIMGYGCCsGAQUFBzAChlpodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MFYGCCsGAQUFBzAChkpodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CWTJQS0lJTlRDQTAxLkFNRS5HQkxfQU1FJTIwSU5GUkElMjBDQSUyMDAxKDQpLmNydDBWBggrBgEFBQcwAoZKaHR0cDovL2NybDMuYW1lLmdibC9haWEvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MB0GA1UdDgQWBBRk_38CqdKjPVylWUR4uuqhbFGeHTAOBgNVHQ8BAf8EBAMCBaAwggE1BgNVHR8EggEsMIIBKDCCASSgggEgoIIBHIZCaHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEATAfBgNVHSMEGDAWgBTl2Ztn_PjsurvwwKidileIud8-YzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAFsx7FtYAzSo98T5ydNFa0ukjPZ6XCQc9zo7ldqy235P_zJAUkaNgCU4EGOzbZJDoMa8mAfhyukL_0GfPeApUaY2e44ZOzoYAkeEuDiwcs-9zoQ1fCyXhn0pCumGFXRilX9KjAPaYTzDvQMEllTy_ZViwTahuKaGtFVamZguBPdaeYC_0oybtTVNQCs8hGnffhNZOMASB-5pFs35MNxsDWTVIQksDee419jqpsbWLkh6rnanILO1O_ihwb-WpvRQByQ5NGpG1-z0MQ6nRpr9wWxUi-DsrVsD38NTMIPc2uei4Ivf6qnGRvOOj0fmsciWuTTEXMaD-5a81mGlzhZc09Q&s=7eo4raFYc33BmEupeagq2GNjtG5kom10retIZnQKhQ_VQdQ71fVeieydkWmpwOzWlAeElvcoDOxsyplOzondWezyR1WfLBj_F_UceKSNmqg1zRJzhbs-Z2D1-jn6aBDsrdl4GfqsI6KtseHpUsC-qxuQ1guU-vCVFylEFsyiscnyeTlJqCn-PzVcu7lTBhkMJCaDfrknY86lH7LKx_8VTCawYz1eGkUvihx_7XK1eNDQoCgG6Xy1wTad7fHNFzTAv2oq4N1VOd8y31o66EMShn7IxAMznUIMxzfkT0D1Oo_vHZMoA2ldBeft_C0xGonFzGvGpvD4MwOfakfyDCZqKg&h=AWAXpMNjJchOeL0gDKuq8Kp2p9m4rqcIEHvU8PVNqHw + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-writes: + - '199' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 5D4D633190C04B8EB21013151A0A7AC3 Ref B: CO6AA3150219047 Ref C: 2024-10-01T17:31:25Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section create + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name --display-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_171e11f7-de0e-48fe-9536-e7d5b17131b2?api-version=2024-04-01&t=638634006864260115&c=MIIHpTCCBo2gAwIBAgITOgM6dTLGpzYZpvPtgQAEAzp1MjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSU5GUkEgQ0EgMDEwHhcNMjQwNjI2MDEzMjIxWhcNMjUwNjIxMDEzMjIxWjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPPPKY5bDN03KptFFhiyLIyn86BlrXYFIZWYXA-hY7_WbLyWN0IxcLIUBW_I-9u-YsXOHk9WPMlUYHIFPgHW7A3FsSGfl9dd6YGapKoSSw0NkTpNXM58R54BBgLp7AhiWzK15D9T-XELNSU4Wq9sEeA5T24kazcgS2MUkzELH0I9dwu7g0dwJIuIJkoJjEzg1b1Q3Ie5HKHHNbjottJn7Q5LBS-9QtQyruuwaNTgSJpCoi4PBKVIOTBYL_Nv1wecmKmfWcT0mnhQE9zjhJTbcoN9hKSvAMqsDHtxWUFZosiw3JKIY0zb59CrVGSuOhfN3qaarwN9EAlXLqc4ZyKpsTkCAwEAAaOCBJIwggSOMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFggvX2K4Py0SACAWQCAQowggHaBggrBgEFBQcBAQSCAcwwggHIMGYGCCsGAQUFBzAChlpodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MFYGCCsGAQUFBzAChkpodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CWTJQS0lJTlRDQTAxLkFNRS5HQkxfQU1FJTIwSU5GUkElMjBDQSUyMDAxKDQpLmNydDBWBggrBgEFBQcwAoZKaHR0cDovL2NybDMuYW1lLmdibC9haWEvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MB0GA1UdDgQWBBRk_38CqdKjPVylWUR4uuqhbFGeHTAOBgNVHQ8BAf8EBAMCBaAwggE1BgNVHR8EggEsMIIBKDCCASSgggEgoIIBHIZCaHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEATAfBgNVHSMEGDAWgBTl2Ztn_PjsurvwwKidileIud8-YzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAFsx7FtYAzSo98T5ydNFa0ukjPZ6XCQc9zo7ldqy235P_zJAUkaNgCU4EGOzbZJDoMa8mAfhyukL_0GfPeApUaY2e44ZOzoYAkeEuDiwcs-9zoQ1fCyXhn0pCumGFXRilX9KjAPaYTzDvQMEllTy_ZViwTahuKaGtFVamZguBPdaeYC_0oybtTVNQCs8hGnffhNZOMASB-5pFs35MNxsDWTVIQksDee419jqpsbWLkh6rnanILO1O_ihwb-WpvRQByQ5NGpG1-z0MQ6nRpr9wWxUi-DsrVsD38NTMIPc2uei4Ivf6qnGRvOOj0fmsciWuTTEXMaD-5a81mGlzhZc09Q&s=7eo4raFYc33BmEupeagq2GNjtG5kom10retIZnQKhQ_VQdQ71fVeieydkWmpwOzWlAeElvcoDOxsyplOzondWezyR1WfLBj_F_UceKSNmqg1zRJzhbs-Z2D1-jn6aBDsrdl4GfqsI6KtseHpUsC-qxuQ1guU-vCVFylEFsyiscnyeTlJqCn-PzVcu7lTBhkMJCaDfrknY86lH7LKx_8VTCawYz1eGkUvihx_7XK1eNDQoCgG6Xy1wTad7fHNFzTAv2oq4N1VOd8y31o66EMShn7IxAMznUIMxzfkT0D1Oo_vHZMoA2ldBeft_C0xGonFzGvGpvD4MwOfakfyDCZqKg&h=AWAXpMNjJchOeL0gDKuq8Kp2p9m4rqcIEHvU8PVNqHw + response: + body: + string: '' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '0' + date: + - Tue, 01 Oct 2024 17:31:25 GMT + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_171e11f7-de0e-48fe-9536-e7d5b17131b2?api-version=2024-04-01&t=638634006865259863&c=MIIHpTCCBo2gAwIBAgITOgM6dTLGpzYZpvPtgQAEAzp1MjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSU5GUkEgQ0EgMDEwHhcNMjQwNjI2MDEzMjIxWhcNMjUwNjIxMDEzMjIxWjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPPPKY5bDN03KptFFhiyLIyn86BlrXYFIZWYXA-hY7_WbLyWN0IxcLIUBW_I-9u-YsXOHk9WPMlUYHIFPgHW7A3FsSGfl9dd6YGapKoSSw0NkTpNXM58R54BBgLp7AhiWzK15D9T-XELNSU4Wq9sEeA5T24kazcgS2MUkzELH0I9dwu7g0dwJIuIJkoJjEzg1b1Q3Ie5HKHHNbjottJn7Q5LBS-9QtQyruuwaNTgSJpCoi4PBKVIOTBYL_Nv1wecmKmfWcT0mnhQE9zjhJTbcoN9hKSvAMqsDHtxWUFZosiw3JKIY0zb59CrVGSuOhfN3qaarwN9EAlXLqc4ZyKpsTkCAwEAAaOCBJIwggSOMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFggvX2K4Py0SACAWQCAQowggHaBggrBgEFBQcBAQSCAcwwggHIMGYGCCsGAQUFBzAChlpodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MFYGCCsGAQUFBzAChkpodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CWTJQS0lJTlRDQTAxLkFNRS5HQkxfQU1FJTIwSU5GUkElMjBDQSUyMDAxKDQpLmNydDBWBggrBgEFBQcwAoZKaHR0cDovL2NybDMuYW1lLmdibC9haWEvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MB0GA1UdDgQWBBRk_38CqdKjPVylWUR4uuqhbFGeHTAOBgNVHQ8BAf8EBAMCBaAwggE1BgNVHR8EggEsMIIBKDCCASSgggEgoIIBHIZCaHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEATAfBgNVHSMEGDAWgBTl2Ztn_PjsurvwwKidileIud8-YzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAFsx7FtYAzSo98T5ydNFa0ukjPZ6XCQc9zo7ldqy235P_zJAUkaNgCU4EGOzbZJDoMa8mAfhyukL_0GfPeApUaY2e44ZOzoYAkeEuDiwcs-9zoQ1fCyXhn0pCumGFXRilX9KjAPaYTzDvQMEllTy_ZViwTahuKaGtFVamZguBPdaeYC_0oybtTVNQCs8hGnffhNZOMASB-5pFs35MNxsDWTVIQksDee419jqpsbWLkh6rnanILO1O_ihwb-WpvRQByQ5NGpG1-z0MQ6nRpr9wWxUi-DsrVsD38NTMIPc2uei4Ivf6qnGRvOOj0fmsciWuTTEXMaD-5a81mGlzhZc09Q&s=3XftmWABBpVqccTqDI8O_SFGMmvQKSmnRh7snNJQFMoYMIQ38n021PrzkaZWUx4Ga6nsU8JFY7A9r8RusYubmpmkowv2T-9sTarSDoN71yA0aygddsCVUu_2yrrfbhrvS73XwPoBvydx1Jh8J5CtX-X2A9su3YyQeQKraByTl5Y1UKR8NSbdoZG1IQpU1CVLRnqD-ANh4mAqwcNjMDTscRIo-rcwZ0mxdhFs33o4zjShWDdZcpBBtDiWs3JTKmAa9UiqZxU2IT_u7VMxN_ffB-09IOltq46bC9dMMYtVxnyCpZkDhpJu_npbMmIM99Isisbe3nujMpMlH_N_ojz5cA&h=Kk00pZ5UPga_bJl4t207B0aIvgIPst8a3q45IQTd-gQ + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 0CEA3FA9E05A49DE95FB291EFDC53BA3 Ref B: CO6AA3150219047 Ref C: 2024-10-01T17:31:26Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section create + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name --display-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/operationResults/putInvoiceSection_171e11f7-de0e-48fe-9536-e7d5b17131b2?api-version=2024-04-01&t=638634006865259863&c=MIIHpTCCBo2gAwIBAgITOgM6dTLGpzYZpvPtgQAEAzp1MjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSU5GUkEgQ0EgMDEwHhcNMjQwNjI2MDEzMjIxWhcNMjUwNjIxMDEzMjIxWjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPPPKY5bDN03KptFFhiyLIyn86BlrXYFIZWYXA-hY7_WbLyWN0IxcLIUBW_I-9u-YsXOHk9WPMlUYHIFPgHW7A3FsSGfl9dd6YGapKoSSw0NkTpNXM58R54BBgLp7AhiWzK15D9T-XELNSU4Wq9sEeA5T24kazcgS2MUkzELH0I9dwu7g0dwJIuIJkoJjEzg1b1Q3Ie5HKHHNbjottJn7Q5LBS-9QtQyruuwaNTgSJpCoi4PBKVIOTBYL_Nv1wecmKmfWcT0mnhQE9zjhJTbcoN9hKSvAMqsDHtxWUFZosiw3JKIY0zb59CrVGSuOhfN3qaarwN9EAlXLqc4ZyKpsTkCAwEAAaOCBJIwggSOMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFggvX2K4Py0SACAWQCAQowggHaBggrBgEFBQcBAQSCAcwwggHIMGYGCCsGAQUFBzAChlpodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MFYGCCsGAQUFBzAChkpodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CWTJQS0lJTlRDQTAxLkFNRS5HQkxfQU1FJTIwSU5GUkElMjBDQSUyMDAxKDQpLmNydDBWBggrBgEFBQcwAoZKaHR0cDovL2NybDMuYW1lLmdibC9haWEvQlkyUEtJSU5UQ0EwMS5BTUUuR0JMX0FNRSUyMElORlJBJTIwQ0ElMjAwMSg0KS5jcnQwVgYIKwYBBQUHMAKGSmh0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JZMlBLSUlOVENBMDEuQU1FLkdCTF9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3J0MB0GA1UdDgQWBBRk_38CqdKjPVylWUR4uuqhbFGeHTAOBgNVHQ8BAf8EBAMCBaAwggE1BgNVHR8EggEsMIIBKDCCASSgggEgoIIBHIZCaHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JshjRodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJTkZSQSUyMENBJTIwMDEoNCkuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwEwDAYKKwYBBAGCN3sEATAfBgNVHSMEGDAWgBTl2Ztn_PjsurvwwKidileIud8-YzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAFsx7FtYAzSo98T5ydNFa0ukjPZ6XCQc9zo7ldqy235P_zJAUkaNgCU4EGOzbZJDoMa8mAfhyukL_0GfPeApUaY2e44ZOzoYAkeEuDiwcs-9zoQ1fCyXhn0pCumGFXRilX9KjAPaYTzDvQMEllTy_ZViwTahuKaGtFVamZguBPdaeYC_0oybtTVNQCs8hGnffhNZOMASB-5pFs35MNxsDWTVIQksDee419jqpsbWLkh6rnanILO1O_ihwb-WpvRQByQ5NGpG1-z0MQ6nRpr9wWxUi-DsrVsD38NTMIPc2uei4Ivf6qnGRvOOj0fmsciWuTTEXMaD-5a81mGlzhZc09Q&s=3XftmWABBpVqccTqDI8O_SFGMmvQKSmnRh7snNJQFMoYMIQ38n021PrzkaZWUx4Ga6nsU8JFY7A9r8RusYubmpmkowv2T-9sTarSDoN71yA0aygddsCVUu_2yrrfbhrvS73XwPoBvydx1Jh8J5CtX-X2A9su3YyQeQKraByTl5Y1UKR8NSbdoZG1IQpU1CVLRnqD-ANh4mAqwcNjMDTscRIo-rcwZ0mxdhFs33o4zjShWDdZcpBBtDiWs3JTKmAa9UiqZxU2IT_u7VMxN_ffB-09IOltq46bC9dMMYtVxnyCpZkDhpJu_npbMmIM99Isisbe3nujMpMlH_N_ojz5cA&h=Kk00pZ5UPga_bJl4t207B0aIvgIPst8a3q45IQTd-gQ + response: + body: + string: '{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/InvoiceSectionViaCLI","name":"InvoiceSectionViaCLI","properties":{"displayName":"Invoice + Section Updated","state":"Active","systemId":"UGYN-BKDH-PJA-MAOR-SGB"},"type":"Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '427' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 01 Oct 2024 17:31:35 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 20E81F07D8024330B6E9A8B5770F5947 Ref B: CO6AA3150219047 Ref C: 2024-10-01T17:31:36Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/recordings/test_list_invoices.yaml b/src/billing/azext_billing/tests/latest/recordings/test_list_invoices.yaml new file mode 100644 index 00000000000..ce9b8bf88ea --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_list_invoices.yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section list-by-billing-profile + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name --include-deleted + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3A0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections?includeDeleted=true&api-version=2024-04-01 + response: + body: + string: '{"totalCount":1,"value":[{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/DVPC-HA6G-PJA-MAOR-SGB","name":"DVPC-HA6G-PJA-MAOR-SGB","properties":{"displayName":"Microsoft + (P10109641)","state":"Active","systemId":"DVPC-HA6G-PJA-MAOR-SGB"},"type":"Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections","tags":{"pcCode":"P10109641","serviceTreeId":"a9305e6b-3d6c-477c-b3cf-1a81498037be"}}]}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '541' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 01 Oct 2024 06:32:27 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-resource-requests: + - '99' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 8B676421F2354AF6A433FFE6F4ADAEB7 Ref B: CO6AA3150218009 Ref C: 2024-10-01T06:32:27Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing invoice-section get + Connection: + - keep-alive + ParameterSetName: + - --billing-account-name --billing-profile-name --invoice-section-name + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148%3A0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/DVPC-HA6G-PJA-MAOR-SGB?api-version=2024-04-01 + response: + body: + string: '{"id":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/DVPC-HA6G-PJA-MAOR-SGB","name":"DVPC-HA6G-PJA-MAOR-SGB","properties":{"displayName":"Microsoft + (P10109641)","state":"Active","systemId":"DVPC-HA6G-PJA-MAOR-SGB"},"type":"Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections","tags":{"pcCode":"P10109641","serviceTreeId":"a9305e6b-3d6c-477c-b3cf-1a81498037be"}}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '514' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 01 Oct 2024 06:32:28 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-tenant-resource-requests: + - '99' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 6B3EAE9FD3C84F9994D616D40DD5BDCD Ref B: CO6AA3150220029 Ref C: 2024-10-01T06:32:28Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/recordings/test_list_profiles.yaml b/src/billing/azext_billing/tests/latest/recordings/test_list_profiles.yaml new file mode 100644 index 00000000000..d875f2cdeee --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_list_profiles.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing billing-property get + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingProperty/default?includeBillingCountry=false&includeTransitionStatus=false&api-version=2024-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingProperty/default","name":"default","properties":{"billingAccountAgreementType":"MicrosoftCustomerAgreement","billingAccountDisplayName":"SMB + Account 1","billingAccountId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31","billingAccountStatus":"Active","billingAccountType":"Individual","billingAccountSubType":"Other","billingCurrency":"USD","billingProfileDisplayName":"Microsoft","billingProfileId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB","billingProfileSpendingLimit":"Off","billingProfileSpendingLimitDetails":[{"startDate":"2024-07-09T00:00:00.0000000Z","type":"Sandbox","status":"Active"}],"billingProfileStatus":"Active","billingProfilePaymentMethodFamily":"Other","billingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","invoiceSectionDisplayName":"Microsoft + (P10109641)","invoiceSectionId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/DVPC-HA6G-PJA-MAOR-SGB","invoiceSectionStatus":"Active","skuDescription":"Microsoft + Azure Plan","skuId":"0001","subscriptionBillingStatus":"Active","subscriptionBillingType":"Paid","subscriptionWorkloadType":"Production","productId":"DZH318Z0BPS6","productName":"Microsoft"},"type":"Microsoft.Billing/billingProperty"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-10-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '1612' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 18:55:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-subscription-global-reads: + - '3749' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 0F83ED9FA60246A3BF8DF416ABFF922A Ref B: CO6AA3150219045 Ref C: 2024-09-30T18:55:39Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/recordings/test_update_billing_prooperty.yaml b/src/billing/azext_billing/tests/latest/recordings/test_update_billing_prooperty.yaml new file mode 100644 index 00000000000..1312500b392 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/recordings/test_update_billing_prooperty.yaml @@ -0,0 +1,66 @@ +interactions: +- request: + body: '{"properties": {"costCenter": "P10109641"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - billing billing-property update + Connection: + - keep-alive + Content-Length: + - '43' + Content-Type: + - application/json + ParameterSetName: + - --cost-center + User-Agent: + - AZURECLI/2.65.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0) + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingProperty/default?api-version=2024-04-01 + response: + body: + string: '{"name":"default","properties":{"billingAccountAgreementType":"MicrosoftCustomerAgreement","billingAccountDisplayName":"SMB + Account 1","billingAccountId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31","billingAccountStatus":"Active","billingAccountType":"Individual","billingAccountSubType":"Other","billingCurrency":"USD","billingProfileDisplayName":"Microsoft","billingProfileId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB","billingProfileSpendingLimit":"Off","billingProfileSpendingLimitDetails":[{"startDate":"2024-07-09T00:00:00.0000000Z","type":"Sandbox","status":"Active"}],"billingProfileStatus":"Active","billingProfilePaymentMethodFamily":"Other","billingTenantId":"25190330-c2fa-4110-b63d-5cda77380ac6","costCenter":"P10109641","invoiceSectionDisplayName":"Microsoft + (P10109641)","invoiceSectionId":"/providers/Microsoft.Billing/billingAccounts/e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31/billingProfiles/B5LA-FLMV-BG7-M77W-SGB/invoiceSections/DVPC-HA6G-PJA-MAOR-SGB","invoiceSectionStatus":"Active","skuDescription":"Microsoft + Azure Plan","skuId":"0001","subscriptionBillingStatus":"Active","subscriptionBillingType":"Paid","subscriptionWorkloadType":"Production","productId":"DZH318Z0BPS6","productName":"Microsoft"},"type":"Microsoft.Billing/billingProperty"}' + headers: + api-supported-versions: + - 2018-11-01-preview, 2019-10-01-preview, 2020-05-01, 2020-10-01, 2020-11-01-privatepreview, + 2024-04-01, 2024-08-01-preview + cache-control: + - no-cache + content-length: + - '1526' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 30 Sep 2024 19:10:43 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-frame-options: + - DENY + x-ms-ratelimit-remaining-subscription-global-writes: + - '2999' + x-ms-ratelimit-remaining-subscription-writes: + - '199' + x-ms-service-version: + - 10.6.2811.738 + x-msedge-ref: + - 'Ref A: 1044160A20DF49C8A75368C4B2444665 Ref B: CO6AA3150219027 Ref C: 2024-09-30T19:10:42Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/billing/azext_billing/tests/latest/test_account_commands.py b/src/billing/azext_billing/tests/latest/test_account_commands.py new file mode 100644 index 00000000000..8f2498678cc --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_account_commands.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only + +class AzureBillingAccountsScenarioTest(ScenarioTest): + def _validate_account(self, account): + self.assertIsNotNone(account) + self.assertEqual(account['type'], 'Microsoft.Billing/accounts') + self.assertTrue(account['id'] and account['name']) + self.assertTrue(account['billingProfiles']) + self.assertTrue(account['enrollmentAccounts']) + self.assertTrue(account['billingProfileName']) + self.assertTrue(account['enrollmentAccountName']) + + def test_list_accounts(self): + # list + accounts_list = self.cmd('billing account list --include-all true').get_output_in_json() + self.assertTrue(accounts_list) + # get + account_name = accounts_list[0]['name'] + self.kwargs.update({ + 'account_name': account_name + }) + self.cmd('billing account get --billing-account-name {account_name}', checks=self.check('name', account_name)) + # Below api is resulting in InternalServerError + # invoiceSection_list = self.cmd('billing account list-invoice-sections-with-create-subscription-permission --billng-acount-name {account_name}').get_output_in_json() + # assert len(invoiceSection_list) > 0 + self.cmd('az billing account update ' + '--billing-account-name {account_name} ' + '--display-name "Account Name Updated Via CLI Test" ' + '--sold-to address-line1="1 Microsoft Way" city="Redmond" company-name="BillingRP CLI" country="US" ' + 'postal-code="98052" region="WA"', + checks=[ + self.check("name", "{account_name}", case_sensitive=False), + self.check("properties.displayName", "Account Name Updated Via CLI Test", case_sensitive=False), + self.check("properties.soldTo.addressLine1", "1 Microsoft Way", case_sensitive=False), + self.check("properties.soldTo.city", "Redmond", case_sensitive=False), + self.check("properties.soldTo.companyName", "BillingRP CLI", case_sensitive=False), + self.check("properties.soldTo.country", "US", case_sensitive=False), + self.check("properties.soldTo.postalCode", "98052", case_sensitive=False), + self.check("properties.soldTo.region", "WA", case_sensitive=False), + ]) \ No newline at end of file diff --git a/src/billing/azext_billing/tests/latest/test_address_commands.py b/src/billing/azext_billing/tests/latest/test_address_commands.py new file mode 100644 index 00000000000..327c9e8a96b --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_address_commands.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only + +class AzureAddressScenarioTest(ScenarioTest): + def test_address_validate(self): + validate_result = self.cmd('billing address validate --address-line1 "1 Microsoft Way" --city "Redmond" --country "US" --postal-code "98052" --region "wa"').get_output_in_json() + assert validate_result['status'] == 'Valid' \ No newline at end of file diff --git a/src/billing/azext_billing/tests/latest/test_agreement_commands.py b/src/billing/azext_billing/tests/latest/test_agreement_commands.py new file mode 100644 index 00000000000..803556b227a --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_agreement_commands.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only + +class AzureagreementScenarioTest(ScenarioTest): + def test_agreement_get_and_list(self): + # list account + accounts_list = self.cmd('billing account list --include-all true').get_output_in_json() + self.assertTrue(accounts_list) + # get account + account_name = accounts_list[0]['name'] + self.kwargs.update({ + 'account_name': account_name + }) + agreement_list = self.cmd('billing agreement list-by-billing-account --billing-account-name {account_name}').get_output_in_json() + self.assertTrue(agreement_list) + agreement_name = agreement_list[0]['name'] + self.kwargs.update({ + 'agreement_name': agreement_name + }) + self.cmd('billing agreement get --billing-account-name {account_name} --agreement-name {agreement_name}', checks=self.check('name', agreement_name)) \ No newline at end of file diff --git a/src/billing/azext_billing/tests/latest/test_billing.py b/src/billing/azext_billing/tests/latest/test_billing.py new file mode 100644 index 00000000000..eba98aee9dd --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_billing.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * + + +class BillingScenario(ScenarioTest): + # TODO: add tests here + pass diff --git a/src/billing/azext_billing/tests/latest/test_billing_property_commands.py b/src/billing/azext_billing/tests/latest/test_billing_property_commands.py new file mode 100644 index 00000000000..18cc83e22b3 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_billing_property_commands.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only + +class AzureBillingPropertyScenarioTest(ScenarioTest): + def test_get_billing_prooperty(self): + billing_property = self.cmd('billing billing-property get').get_output_in_json() + self.assertTrue(billing_property) + + def test_update_billing_prooperty(self): + self.cmd('billing billing-property update --cost-center "P10109641"', checks=self.check("properties.costCenter", "P10109641", case_sensitive=False)) \ No newline at end of file diff --git a/src/billing/azext_billing/tests/latest/test_invoice_commands.py b/src/billing/azext_billing/tests/latest/test_invoice_commands.py new file mode 100644 index 00000000000..04977dbbca5 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_invoice_commands.py @@ -0,0 +1,56 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only + +class AzureInvoiceScenarioTest(ScenarioTest): + def test_list_invoices(self): + self.kwargs.update({ + 'account_name': 'e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31', + 'billing_profile_id': 'B5LA-FLMV-BG7-M77W-SGB', + 'subscription_id': '5040c0e6-3e00-46e8-aee6-ab270d9365cf' + }) + invoices_list_by_billing_account = self.cmd('billing invoice list-by-billing-account ' + '--billing-account-name {account_name} --period-start-date 2024-01-01 --period-end-date 2024-09-30').get_output_in_json() + self.assertTrue(invoices_list_by_billing_account) + invoice = invoices_list_by_billing_account[0] + invoice_name = invoice['name'] + self.kwargs.update({ + 'invoice_name': invoice_name + }) + invoices_list_by_billing_profile = self.cmd('billing invoice list-by-billing-profile ' + '--billing-account-name {account_name} ' + '--billing-profile-name {billing_profile_id} --period-start-date 2024-01-01 --period-end-date 2024-09-30').get_output_in_json() + self.assertTrue(invoices_list_by_billing_profile) + invoices_list_by_billing_subscription = self.cmd('billing invoice list-by-billing-subscription ' + '--period-start-date 2024-01-01 --period-end-date 2024-09-30').get_output_in_json() + # No invoices for the modern subscription as they exist at billing profile scope + self.assertEqual(len(invoices_list_by_billing_subscription), 0) + # get by billing account name + self.cmd('billing invoice get-by-billing-account --billing-account-name {account_name} --invoice-name {invoice_name}', checks=self.check("name", invoice_name, case_sensitive=False)) + # get invoice by id + invoice = self.cmd('billing invoice get --invoice-name {invoice_name}').get_output_in_json() + self.assertEqual(invoice['name'], invoice_name) + properties = invoice['properties'] + documents = properties['documents'] + document = documents[0] + document_name = document['name'] + self.kwargs.update({ + 'document_name': document_name + }) + # download invoice by billing account + download_by_billing_account = self.cmd('billing invoice download-by-billing-account ' + '--billing-account-name {account_name} --invoice-name {invoice_name} --document-name {document_name}').get_output_in_json() + self.assertTrue(download_by_billing_account) + #download by billing subscription + # doc1 = '{document-name:"{document_name}",invoice-name:"{invoice_name}"}' + # parameters = '{}'.format(doc1) + # self.kwargs.update({ + # 'parameters': parameters + # }) + # multiple_download_by_billing_account = self.cmd('az billing invoice download-document-by-billing-account ' + # '--billing-account-name {account_name} ' + # '--parameters {parameters}') + # self.assertTrue(multiple_download_by_billing_account) \ No newline at end of file diff --git a/src/billing/azext_billing/tests/latest/test_invoice_sections_commands.py b/src/billing/azext_billing/tests/latest/test_invoice_sections_commands.py new file mode 100644 index 00000000000..ef9ec7943e5 --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_invoice_sections_commands.py @@ -0,0 +1,44 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only + +class AzureInvoiceSectionScenarioTest(ScenarioTest): + def test_list_invoice_sections(self): + self.kwargs.update({ + 'account_name': 'e261ef40-3517-515d-3680-8be4252ae148:0790f1fc-f274-4457-afc3-f3b0c90850ba_2019-05-31', + 'billing_profile_id': 'B5LA-FLMV-BG7-M77W-SGB' + }) + list_invoice_section = self.cmd('billing invoice-section list-by-billing-profile ' + '--billing-account-name {account_name} ' + '--billing-profile-name {billing_profile_id}').get_output_in_json() + self.assertTrue(list_invoice_section) + invoice_section = list_invoice_section[0] + invoice_section_name = invoice_section['name'] + self.kwargs.update({ + 'invoice_section_name': invoice_section_name + }) + invoice_section = self.cmd('billing invoice-section get ' + '--billing-account-name {account_name} --billing-profile-name {billing_profile_id} --invoice-section-name {invoice_section_name}').get_output_in_json() + self.assertEqual(invoice_section['name'], invoice_section_name) + validate_delete_eligibility = self.cmd('billing invoice-section validate-delete-eligibility ' + '--billing-account-name {account_name} --billing-profile-name {billing_profile_id} --invoice-section-name {invoice_section_name}').get_output_in_json() + self.assertTrue(validate_delete_eligibility) + self.kwargs.update({ + 'create_invoice_section_name': 'InvoiceSectionViaCLI' + }) + self.cmd('billing invoice-section create ' + '--billing-account-name {account_name} --billing-profile-name {billing_profile_id} ' + '--invoice-section-name {create_invoice_section_name} --display-name "Invoice Section 1"' + ,checks=self.check("name", "InvoiceSectionViaCLI", case_sensitive=False)) + + update = self.cmd('billing invoice-section create ' + '--billing-account-name {account_name} --billing-profile-name {billing_profile_id} ' + '--invoice-section-name {create_invoice_section_name} --display-name "Invoice Section Updated"').get_output_in_json() + properties = update['properties'] + self.assertEqual(properties['displayName'], 'Invoice Section Updated') + + # self.cmd('billing invoice-section delete ' + # '--billing-account-name {account_name} --billing-profile-name {billing_profile_id} --invoice-section-name {create_invoice_section_name}') \ No newline at end of file diff --git a/src/billing/azext_billing/tests/latest/test_profile_commands.py b/src/billing/azext_billing/tests/latest/test_profile_commands.py new file mode 100644 index 00000000000..4ee1c0f989e --- /dev/null +++ b/src/billing/azext_billing/tests/latest/test_profile_commands.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only + +class AzureBillingProfilessScenarioTest(ScenarioTest): + def test_list_profiles(self): + accounts_list = self.cmd('billing account list --include-all true').get_output_in_json() + self.assertTrue(accounts_list) + # get + account_name = accounts_list[0]['name'] + self.kwargs.update({ + 'account_name': account_name + }) + # list + profiles_list = self.cmd('billing profile list --account-name {account_name}').get_output_in_json() + self.assertTrue(profiles_list) + # get + profile_name = profiles_list[0]['name'] + self.kwargs.update({ + 'profile_name': profile_name + }) + self.cmd('billing profile get --billing-account-name {account_name} --billing-profile-name {profile_name}', checks=self.check('name', profile_name)) \ No newline at end of file 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..f21e912523b --- /dev/null +++ b/src/billing/setup.py @@ -0,0 +1,49 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# HISTORY.rst entry. +VERSION = '1.0.0b1' + +# 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.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +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 Billing Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/billing', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_billing': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +) diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..2217181c88b --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.AssemblyInfo.cs new file mode 100644 index 00000000000..6bcaa57b85d --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("NetCore8PreviewMvcApp")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("NetCore8PreviewMvcApp")] +[assembly: System.Reflection.AssemblyTitleAttribute("NetCore8PreviewMvcApp")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..8a0828ecec5 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +a10e1f880db14741f10cd9a293d76917f0270bcc986bc5f032337e4e0b55815c diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..786c7be7232 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net8.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = NetCore8PreviewMvcApp +build_property.RootNamespace = NetCore8PreviewMvcApp +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bookworm_buildpack_net8\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 8.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bookworm_buildpack_net8 +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Home/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcSG9tZVxJbmRleC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Home/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcSG9tZVxQcml2YWN5LmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Shared/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcU2hhcmVkXEVycm9yLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Debug/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..2217181c88b --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.AssemblyInfo.cs new file mode 100644 index 00000000000..282bd40be46 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("NetCore8PreviewMvcApp")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("NetCore8PreviewMvcApp")] +[assembly: System.Reflection.AssemblyTitleAttribute("NetCore8PreviewMvcApp")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..9b4fd1349dc --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +0f50eed0440f0b52d8f256029600d3ff8c951b6002bf9da8b32d777f091c0ef2 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..786c7be7232 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net8.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = NetCore8PreviewMvcApp +build_property.RootNamespace = NetCore8PreviewMvcApp +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bookworm_buildpack_net8\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 8.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bookworm_buildpack_net8 +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Home/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcSG9tZVxJbmRleC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Home/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcSG9tZVxQcml2YWN5LmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Shared/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcU2hhcmVkXEVycm9yLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/Views/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3NcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bookworm_buildpack_net8/obj/Release/net8.0/NetCore8PreviewMvcApp.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..4257f4bc63d --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.AssemblyInfo.cs new file mode 100644 index 00000000000..bbb1d31c57b --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyTitleAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..d7a639ceb0e --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +d207206a328add8d7596fa6fc0aecb8ad59a1b621509bcb073b16aa8a26e2b8a diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..10b7078e0a6 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net7.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = HelloWorldApp +build_property.RootNamespace = HelloWorldApp +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bullseye_buildpack_net7\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 7.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bullseye_buildpack_net7 +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcRXJyb3IuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcUHJpdmFjeS5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = b-6uzucmkwm6 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.GlobalUsings.g.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.GlobalUsings.g.cs new file mode 100644 index 00000000000..025530a2920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.GlobalUsings.g.cs @@ -0,0 +1,17 @@ +// +global using global::Microsoft.AspNetCore.Builder; +global using global::Microsoft.AspNetCore.Hosting; +global using global::Microsoft.AspNetCore.Http; +global using global::Microsoft.AspNetCore.Routing; +global using global::Microsoft.Extensions.Configuration; +global using global::Microsoft.Extensions.DependencyInjection; +global using global::Microsoft.Extensions.Hosting; +global using global::Microsoft.Extensions.Logging; +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Net.Http.Json; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..4257f4bc63d --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.AssemblyInfo.cs new file mode 100644 index 00000000000..d0de960c920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyTitleAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..471e6647fe1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +deef4eccade5a1ffaef6b70e1e34ac52c3bb98bdd927f991a714ddd597ca3e06 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..10b7078e0a6 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net7.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = HelloWorldApp +build_property.RootNamespace = HelloWorldApp +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bullseye_buildpack_net7\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 7.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_bullseye_buildpack_net7 +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcRXJyb3IuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcUHJpdmFjeS5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/Pages/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = b-6uzucmkwm6 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.GlobalUsings.g.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.GlobalUsings.g.cs new file mode 100644 index 00000000000..025530a2920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.GlobalUsings.g.cs @@ -0,0 +1,17 @@ +// +global using global::Microsoft.AspNetCore.Builder; +global using global::Microsoft.AspNetCore.Hosting; +global using global::Microsoft.AspNetCore.Http; +global using global::Microsoft.AspNetCore.Routing; +global using global::Microsoft.Extensions.Configuration; +global using global::Microsoft.Extensions.DependencyInjection; +global using global::Microsoft.Extensions.Hosting; +global using global::Microsoft.Extensions.Logging; +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Net.Http.Json; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_bullseye_buildpack_net7/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..ed9269506e3 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.AssemblyInfo.cs new file mode 100644 index 00000000000..9833036f639 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.AssemblyInfo.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute("546d15d2-b889-4cb2-8a29-5b0cea7e26a9")] +[assembly: System.Reflection.AssemblyCompanyAttribute("TestWebApp202305")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("TestWebApp202305")] +[assembly: System.Reflection.AssemblyTitleAttribute("TestWebApp202305")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..39ac5a8de6e --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +1a206cd89baef9e95556baccd7e3f0eca37c1c9fa6f5e3e4749375c46aae43f7 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..e07c9fe27a0 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net6.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = TestWebApp202305 +build_property.RootNamespace = TestWebApp202305 +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_dockerfile\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 6.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_dockerfile +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcRXJyb3IuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcUHJpdmFjeS5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = b-unn2llrut0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.GlobalUsings.g.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.GlobalUsings.g.cs new file mode 100644 index 00000000000..025530a2920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.GlobalUsings.g.cs @@ -0,0 +1,17 @@ +// +global using global::Microsoft.AspNetCore.Builder; +global using global::Microsoft.AspNetCore.Hosting; +global using global::Microsoft.AspNetCore.Http; +global using global::Microsoft.AspNetCore.Routing; +global using global::Microsoft.Extensions.Configuration; +global using global::Microsoft.Extensions.DependencyInjection; +global using global::Microsoft.Extensions.Hosting; +global using global::Microsoft.Extensions.Logging; +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Net.Http.Json; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Debug/net6.0/TestWebApp202305.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..ed9269506e3 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.AssemblyInfo.cs new file mode 100644 index 00000000000..01f3c5531f3 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.AssemblyInfo.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute("546d15d2-b889-4cb2-8a29-5b0cea7e26a9")] +[assembly: System.Reflection.AssemblyCompanyAttribute("TestWebApp202305")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("TestWebApp202305")] +[assembly: System.Reflection.AssemblyTitleAttribute("TestWebApp202305")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..b5e591a010f --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +43781e5968f998d40673584736db24db5662d7922721335dc6ce4668325f7ecc diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..e07c9fe27a0 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net6.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = TestWebApp202305 +build_property.RootNamespace = TestWebApp202305 +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_dockerfile\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 6.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_dockerfile +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcRXJyb3IuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcUHJpdmFjeS5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/Pages/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = b-unn2llrut0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.GlobalUsings.g.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.GlobalUsings.g.cs new file mode 100644 index 00000000000..025530a2920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.GlobalUsings.g.cs @@ -0,0 +1,17 @@ +// +global using global::Microsoft.AspNetCore.Builder; +global using global::Microsoft.AspNetCore.Hosting; +global using global::Microsoft.AspNetCore.Http; +global using global::Microsoft.AspNetCore.Routing; +global using global::Microsoft.Extensions.Configuration; +global using global::Microsoft.Extensions.DependencyInjection; +global using global::Microsoft.Extensions.Hosting; +global using global::Microsoft.Extensions.Logging; +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Net.Http.Json; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_dockerfile/obj/Release/net6.0/TestWebApp202305.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..4257f4bc63d --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.AssemblyInfo.cs new file mode 100644 index 00000000000..bbb1d31c57b --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyTitleAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..d7a639ceb0e --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +d207206a328add8d7596fa6fc0aecb8ad59a1b621509bcb073b16aa8a26e2b8a diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..1aa93ab4795 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net7.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = HelloWorldApp +build_property.RootNamespace = HelloWorldApp +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_source_to_cloud_dotnet\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 7.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_source_to_cloud_dotnet +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcRXJyb3IuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcUHJpdmFjeS5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = b-6uzucmkwm6 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.GlobalUsings.g.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.GlobalUsings.g.cs new file mode 100644 index 00000000000..025530a2920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.GlobalUsings.g.cs @@ -0,0 +1,17 @@ +// +global using global::Microsoft.AspNetCore.Builder; +global using global::Microsoft.AspNetCore.Hosting; +global using global::Microsoft.AspNetCore.Http; +global using global::Microsoft.AspNetCore.Routing; +global using global::Microsoft.Extensions.Configuration; +global using global::Microsoft.Extensions.DependencyInjection; +global using global::Microsoft.Extensions.Hosting; +global using global::Microsoft.Extensions.Logging; +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Net.Http.Json; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Debug/net7.0/HelloWorldApp.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs new file mode 100644 index 00000000000..4257f4bc63d --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.AssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.AssemblyInfo.cs new file mode 100644 index 00000000000..d0de960c920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd71980f86f46398deb31cd46ed188e4d5976dd")] +[assembly: System.Reflection.AssemblyProductAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyTitleAttribute("HelloWorldApp")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.AssemblyInfoInputs.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.AssemblyInfoInputs.cache new file mode 100644 index 00000000000..471e6647fe1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +deef4eccade5a1ffaef6b70e1e34ac52c3bb98bdd927f991a714ddd597ca3e06 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 00000000000..1aa93ab4795 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,47 @@ +is_global = true +build_property.TargetFramework = net7.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = true +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = HelloWorldApp +build_property.RootNamespace = HelloWorldApp +build_property.ProjectDir = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_source_to_cloud_dotnet\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.RazorLangVersion = 7.0 +build_property.SupportLocalizedComponentNames = +build_property.GenerateRazorMetadataSourceChecksumAttributes = +build_property.MSBuildProjectDirectory = C:\Users\umangshah\source\repos\us6193\azure-cli-extensions\src\containerapp\azext_containerapp\tests\latest\data\source_built_using_source_to_cloud_dotnet +build_property._RazorSourceGeneratorDebug = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Error.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcRXJyb3IuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Privacy.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcUHJpdmFjeS5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Shared/_ValidationScriptsPartial.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/_ViewImports.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdJbXBvcnRzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/_ViewStart.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcX1ZpZXdTdGFydC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[C:/Users/umangshah/source/repos/us6193/azure-cli-extensions/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/Pages/Shared/_Layout.cshtml] +build_metadata.AdditionalFiles.TargetPath = UGFnZXNcU2hhcmVkXF9MYXlvdXQuY3NodG1s +build_metadata.AdditionalFiles.CssScope = b-6uzucmkwm6 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.GlobalUsings.g.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.GlobalUsings.g.cs new file mode 100644 index 00000000000..025530a2920 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.GlobalUsings.g.cs @@ -0,0 +1,17 @@ +// +global using global::Microsoft.AspNetCore.Builder; +global using global::Microsoft.AspNetCore.Hosting; +global using global::Microsoft.AspNetCore.Http; +global using global::Microsoft.AspNetCore.Routing; +global using global::Microsoft.Extensions.Configuration; +global using global::Microsoft.Extensions.DependencyInjection; +global using global::Microsoft.Extensions.Hosting; +global using global::Microsoft.Extensions.Logging; +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Net.Http.Json; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cache b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cache new file mode 100644 index 00000000000..ecb9c9784c1 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cache @@ -0,0 +1 @@ +d5ac7ab69059af111e9d7125adeb7b174ca570725d4b64a544cca7bd11ac7ca0 diff --git a/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cs b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cs new file mode 100644 index 00000000000..cd3853c71f9 --- /dev/null +++ b/src/containerapp/azext_containerapp/tests/latest/data/source_built_using_source_to_cloud_dotnet/obj/Release/net7.0/HelloWorldApp.RazorAssemblyInfo.cs @@ -0,0 +1,18 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFact" + + "ory, Microsoft.AspNetCore.Mvc.Razor")] + +// Generated by the MSBuild WriteCodeFragment class. +