From b45e1083cf11d9c7a07c5f887622c6f644ee01ff Mon Sep 17 00:00:00 2001 From: huiquanjiang Date: Thu, 4 Jul 2024 18:04:31 +0800 Subject: [PATCH] refactor command group: acat report --- .../app_compliance_automation/__cmd_group.py | 2 +- .../app_compliance_automation/_onboard.py | 368 +++---- .../report/__cmd_group.py | 2 +- .../report/__init__.py | 36 +- .../report/_create.py | 934 +++++++++--------- .../report/_delete.py | 302 +++--- .../app_compliance_automation/report/_fix.py | 175 ---- .../app_compliance_automation/report/_list.py | 790 +++++++-------- .../app_compliance_automation/report/_show.py | 664 ++++++------- .../report/_update.py | 928 ++++++++--------- .../report/_verify.py | 175 ---- src/acat/azext_acat/commands.py | 16 +- src/acat/azext_acat/custom.py | 151 ++- 13 files changed, 2177 insertions(+), 2366 deletions(-) delete mode 100644 src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_fix.py delete mode 100644 src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_verify.py diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/__cmd_group.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/__cmd_group.py index d8ef61fa9b9..90f029795a5 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/__cmd_group.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/__cmd_group.py @@ -15,7 +15,7 @@ "app-compliance-automation", ) class __CMDGroup(AAZCommandGroup): - """ACAT command group + """ Manage App Compliance Automation Tool reports. """ pass diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/_onboard.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/_onboard.py index 5df59b7e9a5..1bdd5451ba6 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/_onboard.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/_onboard.py @@ -1,184 +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( - "app-compliance-automation onboard", -) -class Onboard(AAZCommand): - """Onboard given subscriptions to Microsoft.AppComplianceAutomation provider. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/onboard", "2024-06-27"], - ] - } - - 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 "Parameters" - - _args_schema = cls._args_schema - _args_schema.subscription_ids = AAZListArg( - options=["--subscription-ids"], - arg_group="Parameters", - help="List of subscription ids to be onboarded", - required=True, - ) - - subscription_ids = cls._args_schema.subscription_ids - subscription_ids.Element = AAZStrArg() - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.ProviderActionsOnboard(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 ProviderActionsOnboard(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.AppComplianceAutomation/onboard", - **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-06-27", - 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("subscriptionIds", AAZListType, ".subscription_ids", typ_kwargs={"flags": {"required": True}}) - - subscription_ids = _builder.get(".subscriptionIds") - if subscription_ids is not None: - subscription_ids.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.subscription_ids = AAZListType( - serialized_name="subscriptionIds", - ) - - subscription_ids = cls._schema_on_200.subscription_ids - subscription_ids.Element = AAZStrType() - - return cls._schema_on_200 - - -class _OnboardHelper: - """Helper class for Onboard""" - - -__all__ = ["Onboard"] +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "app-compliance-automation onboard", +) +class Onboard(AAZCommand): + """Onboard given subscriptions to Microsoft.AppComplianceAutomation provider. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/onboard", "2024-06-27"], + ] + } + + 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 "Parameters" + + _args_schema = cls._args_schema + _args_schema.subscription_ids = AAZListArg( + options=["--subscription-ids"], + arg_group="Parameters", + help="List of subscription ids to be onboarded", + required=True, + ) + + subscription_ids = cls._args_schema.subscription_ids + subscription_ids.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ProviderActionsOnboard(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 ProviderActionsOnboard(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.AppComplianceAutomation/onboard", + **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-06-27", + 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("subscriptionIds", AAZListType, ".subscription_ids", typ_kwargs={"flags": {"required": True}}) + + subscription_ids = _builder.get(".subscriptionIds") + if subscription_ids is not None: + subscription_ids.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.subscription_ids = AAZListType( + serialized_name="subscriptionIds", + ) + + subscription_ids = cls._schema_on_200.subscription_ids + subscription_ids.Element = AAZStrType() + + return cls._schema_on_200 + + +class _OnboardHelper: + """Helper class for Onboard""" + + +__all__ = ["Onboard"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__cmd_group.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__cmd_group.py index 6b8dfd97f01..63b4f83ef38 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__cmd_group.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__cmd_group.py @@ -15,7 +15,7 @@ "app-compliance-automation report", ) class __CMDGroup(AAZCommandGroup): - """manage ACAT reports + """ Manage App Compliance Automation Tool reports. """ pass diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__init__.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__init__.py index 6d71403839d..db73033039b 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__init__.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/__init__.py @@ -1,19 +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 ._fix import * -from ._list import * -from ._show import * -from ._update import * -from ._verify import * -from ._wait import * +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the 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 ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_create.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_create.py index 1206cf341bb..cdc0d252b0d 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_create.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_create.py @@ -1,467 +1,467 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report create", -) -class Create(AAZCommand): - """Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], - ] - } - - 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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.offer_guid = AAZStrArg( - options=["--offer-guid"], - arg_group="Properties", - help="A list of comma-separated offerGuids indicates a series of offerGuids that map to the report. For example, \"00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002\" and \"00000000-0000-0000-0000-000000000003\".", - ) - _args_schema.resources = AAZListArg( - options=["--resources"], - arg_group="Properties", - help="List of resource data.", - required=True, - ) - _args_schema.storage_info = AAZObjectArg( - options=["--storage-info"], - arg_group="Properties", - help="The information of 'bring your own storage' binding to the report", - ) - _args_schema.time_zone = AAZStrArg( - options=["--time-zone"], - arg_group="Properties", - help="Report collection trigger time's time zone, the available list can be obtained by executing \"Get-TimeZone -ListAvailable\" in PowerShell. An example of valid timezone id is \"Pacific Standard Time\".", - required=True, - ) - _args_schema.trigger_time = AAZDateTimeArg( - options=["--trigger-time"], - arg_group="Properties", - help="Report collection trigger time.", - required=True, - ) - - resources = cls._args_schema.resources - resources.Element = AAZObjectArg() - - _element = cls._args_schema.resources.Element - _element.account_id = AAZStrArg( - options=["account-id"], - help="Account Id. For example - the AWS account id.", - ) - _element.resource_id = AAZStrArg( - options=["resource-id"], - help="Resource Id - e.g. \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1\".", - required=True, - ) - _element.resource_kind = AAZStrArg( - options=["resource-kind"], - help="Resource kind.", - ) - _element.resource_origin = AAZStrArg( - options=["resource-origin"], - help="Resource Origin.", - enum={"AWS": "AWS", "Azure": "Azure", "GCP": "GCP"}, - ) - _element.resource_type = AAZStrArg( - options=["resource-type"], - help="Resource type. e.g. \"Microsoft.Compute/virtualMachines\"", - ) - - storage_info = cls._args_schema.storage_info - storage_info.account_name = AAZStrArg( - options=["account-name"], - help="'bring your own storage' account name", - ) - storage_info.location = AAZStrArg( - options=["location"], - help="The region of 'bring your own storage' account", - ) - storage_info.resource_group = AAZStrArg( - options=["resource-group"], - help="The resourceGroup which 'bring your own storage' account belongs to", - ) - storage_info.subscription_id = AAZStrArg( - options=["subscription-id"], - help="The subscription id which 'bring your own storage' account belongs to", - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.ReportCreateOrUpdate(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 ReportCreateOrUpdate(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.AppComplianceAutomation/reports/{reportName}", - **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( - "reportName", self.ctx.args.report_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-06-27", - 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": {"required": True, "client_flatten": True}}) - - properties = _builder.get(".properties") - if properties is not None: - properties.set_prop("offerGuid", AAZStrType, ".offer_guid") - properties.set_prop("resources", AAZListType, ".resources", typ_kwargs={"flags": {"required": True}}) - properties.set_prop("storageInfo", AAZObjectType, ".storage_info") - properties.set_prop("timeZone", AAZStrType, ".time_zone", typ_kwargs={"flags": {"required": True}}) - properties.set_prop("triggerTime", AAZStrType, ".trigger_time", typ_kwargs={"flags": {"required": True}}) - - resources = _builder.get(".properties.resources") - if resources is not None: - resources.set_elements(AAZObjectType, ".") - - _elements = _builder.get(".properties.resources[]") - if _elements is not None: - _elements.set_prop("accountId", AAZStrType, ".account_id") - _elements.set_prop("resourceId", AAZStrType, ".resource_id", typ_kwargs={"flags": {"required": True}}) - _elements.set_prop("resourceKind", AAZStrType, ".resource_kind") - _elements.set_prop("resourceOrigin", AAZStrType, ".resource_origin") - _elements.set_prop("resourceType", AAZStrType, ".resource_type") - - storage_info = _builder.get(".properties.storageInfo") - if storage_info is not None: - storage_info.set_prop("accountName", AAZStrType, ".account_name") - storage_info.set_prop("location", AAZStrType, ".location") - storage_info.set_prop("resourceGroup", AAZStrType, ".resource_group") - storage_info.set_prop("subscriptionId", AAZStrType, ".subscription_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={"required": True, "client_flatten": True}, - ) - _schema_on_200_201.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _schema_on_200_201.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200_201.properties - properties.cert_records = AAZListType( - serialized_name="certRecords", - flags={"read_only": True}, - ) - properties.compliance_status = AAZObjectType( - serialized_name="complianceStatus", - flags={"read_only": True}, - ) - properties.errors = AAZListType( - flags={"read_only": True}, - ) - properties.last_trigger_time = AAZStrType( - serialized_name="lastTriggerTime", - flags={"read_only": True}, - ) - properties.next_trigger_time = AAZStrType( - serialized_name="nextTriggerTime", - flags={"read_only": True}, - ) - properties.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.resources = AAZListType( - flags={"required": True}, - ) - properties.status = AAZStrType( - flags={"read_only": True}, - ) - properties.storage_info = AAZObjectType( - serialized_name="storageInfo", - ) - properties.subscriptions = AAZListType( - flags={"read_only": True}, - ) - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.time_zone = AAZStrType( - serialized_name="timeZone", - flags={"required": True}, - ) - properties.trigger_time = AAZStrType( - serialized_name="triggerTime", - flags={"required": True}, - ) - - cert_records = cls._schema_on_200_201.properties.cert_records - cert_records.Element = AAZObjectType() - - _element = cls._schema_on_200_201.properties.cert_records.Element - _element.certification_status = AAZStrType( - serialized_name="certificationStatus", - ) - _element.controls = AAZListType() - _element.ingestion_status = AAZStrType( - serialized_name="ingestionStatus", - ) - _element.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - - controls = cls._schema_on_200_201.properties.cert_records.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200_201.properties.cert_records.Element.controls.Element - _element.control_id = AAZStrType( - serialized_name="controlId", - ) - _element.control_status = AAZStrType( - serialized_name="controlStatus", - ) - - compliance_status = cls._schema_on_200_201.properties.compliance_status - compliance_status.m365 = AAZObjectType( - flags={"read_only": True}, - ) - - m365 = cls._schema_on_200_201.properties.compliance_status.m365 - m365.failed_count = AAZIntType( - serialized_name="failedCount", - flags={"read_only": True}, - ) - m365.manual_count = AAZIntType( - serialized_name="manualCount", - flags={"read_only": True}, - ) - m365.not_applicable_count = AAZIntType( - serialized_name="notApplicableCount", - flags={"read_only": True}, - ) - m365.passed_count = AAZIntType( - serialized_name="passedCount", - flags={"read_only": True}, - ) - m365.pending_count = AAZIntType( - serialized_name="pendingCount", - flags={"read_only": True}, - ) - - errors = cls._schema_on_200_201.properties.errors - errors.Element = AAZStrType() - - resources = cls._schema_on_200_201.properties.resources - resources.Element = AAZObjectType() - - _element = cls._schema_on_200_201.properties.resources.Element - _element.account_id = AAZStrType( - serialized_name="accountId", - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"required": True}, - ) - _element.resource_kind = AAZStrType( - serialized_name="resourceKind", - ) - _element.resource_origin = AAZStrType( - serialized_name="resourceOrigin", - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - ) - - storage_info = cls._schema_on_200_201.properties.storage_info - storage_info.account_name = AAZStrType( - serialized_name="accountName", - ) - storage_info.location = AAZStrType() - storage_info.resource_group = AAZStrType( - serialized_name="resourceGroup", - ) - storage_info.subscription_id = AAZStrType( - serialized_name="subscriptionId", - ) - - subscriptions = cls._schema_on_200_201.properties.subscriptions - subscriptions.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", - ) - - return cls._schema_on_200_201 - - -class _CreateHelper: - """Helper class for Create""" - - -__all__ = ["Create"] +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "app-compliance-automation report create", +) +class Create(AAZCommand): + """Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], + ] + } + + 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.report_name = AAZStrArg( + options=["--report-name"], + help="Report Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.offer_guid = AAZStrArg( + options=["--offer-guid"], + arg_group="Properties", + help="A list of comma-separated offerGuids indicates a series of offerGuids that map to the report. For example, \"00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002\" and \"00000000-0000-0000-0000-000000000003\".", + ) + _args_schema.resources = AAZListArg( + options=["--resources"], + arg_group="Properties", + help="List of resource data.", + required=True, + ) + _args_schema.storage_info = AAZObjectArg( + options=["--storage-info"], + arg_group="Properties", + help="The information of 'bring your own storage' binding to the report", + ) + _args_schema.time_zone = AAZStrArg( + options=["--time-zone-hidden"], + arg_group="Properties", + help="Report collection trigger time's time zone, the available list can be obtained by executing \"Get-TimeZone -ListAvailable\" in PowerShell. An example of valid timezone id is \"Pacific Standard Time\".", + required=True, + ) + _args_schema.trigger_time = AAZDateTimeArg( + options=["--trigger-time-hidden"], + arg_group="Properties", + help="Report collection trigger time.", + required=True, + ) + + resources = cls._args_schema.resources + resources.Element = AAZObjectArg() + + _element = cls._args_schema.resources.Element + _element.account_id = AAZStrArg( + options=["account-id"], + help="Account Id. For example - the AWS account id.", + ) + _element.resource_id = AAZStrArg( + options=["resource-id"], + help="Resource Id - e.g. \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1\".", + required=True, + ) + _element.resource_kind = AAZStrArg( + options=["resource-kind"], + help="Resource kind.", + ) + _element.resource_origin = AAZStrArg( + options=["resource-origin"], + help="Resource Origin.", + enum={"AWS": "AWS", "Azure": "Azure", "GCP": "GCP"}, + ) + _element.resource_type = AAZStrArg( + options=["resource-type"], + help="Resource type. e.g. \"Microsoft.Compute/virtualMachines\"", + ) + + storage_info = cls._args_schema.storage_info + storage_info.account_name = AAZStrArg( + options=["account-name"], + help="'bring your own storage' account name", + ) + storage_info.location = AAZStrArg( + options=["location"], + help="The region of 'bring your own storage' account", + ) + storage_info.resource_group = AAZStrArg( + options=["resource-group"], + help="The resourceGroup which 'bring your own storage' account belongs to", + ) + storage_info.subscription_id = AAZStrArg( + options=["subscription-id"], + help="The subscription id which 'bring your own storage' account belongs to", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ReportCreateOrUpdate(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 ReportCreateOrUpdate(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.AppComplianceAutomation/reports/{reportName}", + **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( + "reportName", self.ctx.args.report_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-06-27", + 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": {"required": True, "client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("offerGuid", AAZStrType, ".offer_guid") + properties.set_prop("resources", AAZListType, ".resources", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("storageInfo", AAZObjectType, ".storage_info") + properties.set_prop("timeZone", AAZStrType, ".time_zone", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("triggerTime", AAZStrType, ".trigger_time", typ_kwargs={"flags": {"required": True}}) + + resources = _builder.get(".properties.resources") + if resources is not None: + resources.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.resources[]") + if _elements is not None: + _elements.set_prop("accountId", AAZStrType, ".account_id") + _elements.set_prop("resourceId", AAZStrType, ".resource_id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("resourceKind", AAZStrType, ".resource_kind") + _elements.set_prop("resourceOrigin", AAZStrType, ".resource_origin") + _elements.set_prop("resourceType", AAZStrType, ".resource_type") + + storage_info = _builder.get(".properties.storageInfo") + if storage_info is not None: + storage_info.set_prop("accountName", AAZStrType, ".account_name") + storage_info.set_prop("location", AAZStrType, ".location") + storage_info.set_prop("resourceGroup", AAZStrType, ".resource_group") + storage_info.set_prop("subscriptionId", AAZStrType, ".subscription_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={"required": True, "client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.cert_records = AAZListType( + serialized_name="certRecords", + flags={"read_only": True}, + ) + properties.compliance_status = AAZObjectType( + serialized_name="complianceStatus", + flags={"read_only": True}, + ) + properties.errors = AAZListType( + flags={"read_only": True}, + ) + properties.last_trigger_time = AAZStrType( + serialized_name="lastTriggerTime", + flags={"read_only": True}, + ) + properties.next_trigger_time = AAZStrType( + serialized_name="nextTriggerTime", + flags={"read_only": True}, + ) + properties.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.resources = AAZListType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.storage_info = AAZObjectType( + serialized_name="storageInfo", + ) + properties.subscriptions = AAZListType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + properties.trigger_time = AAZStrType( + serialized_name="triggerTime", + flags={"required": True}, + ) + + cert_records = cls._schema_on_200_201.properties.cert_records + cert_records.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.cert_records.Element + _element.certification_status = AAZStrType( + serialized_name="certificationStatus", + ) + _element.controls = AAZListType() + _element.ingestion_status = AAZStrType( + serialized_name="ingestionStatus", + ) + _element.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + + controls = cls._schema_on_200_201.properties.cert_records.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.cert_records.Element.controls.Element + _element.control_id = AAZStrType( + serialized_name="controlId", + ) + _element.control_status = AAZStrType( + serialized_name="controlStatus", + ) + + compliance_status = cls._schema_on_200_201.properties.compliance_status + compliance_status.m365 = AAZObjectType( + flags={"read_only": True}, + ) + + m365 = cls._schema_on_200_201.properties.compliance_status.m365 + m365.failed_count = AAZIntType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + m365.manual_count = AAZIntType( + serialized_name="manualCount", + flags={"read_only": True}, + ) + m365.not_applicable_count = AAZIntType( + serialized_name="notApplicableCount", + flags={"read_only": True}, + ) + m365.passed_count = AAZIntType( + serialized_name="passedCount", + flags={"read_only": True}, + ) + m365.pending_count = AAZIntType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + + errors = cls._schema_on_200_201.properties.errors + errors.Element = AAZStrType() + + resources = cls._schema_on_200_201.properties.resources + resources.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.resources.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + _element.resource_kind = AAZStrType( + serialized_name="resourceKind", + ) + _element.resource_origin = AAZStrType( + serialized_name="resourceOrigin", + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + ) + + storage_info = cls._schema_on_200_201.properties.storage_info + storage_info.account_name = AAZStrType( + serialized_name="accountName", + ) + storage_info.location = AAZStrType() + storage_info.resource_group = AAZStrType( + serialized_name="resourceGroup", + ) + storage_info.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + subscriptions = cls._schema_on_200_201.properties.subscriptions + subscriptions.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", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_delete.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_delete.py index 21079b37bab..419ab76f357 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_delete.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_delete.py @@ -1,151 +1,151 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report delete", - confirmation="Are you sure you want to perform this operation?", -) -class Delete(AAZCommand): - """Delete an AppComplianceAutomation report. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], - ] - } - - 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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.ReportDelete(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class ReportDelete(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.AppComplianceAutomation/reports/{reportName}", - **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( - "reportName", self.ctx.args.report_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-06-27", - 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"] +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "app-compliance-automation report delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an AppComplianceAutomation report. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], + ] + } + + 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.report_name = AAZStrArg( + options=["--report-name"], + help="Report Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ReportDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ReportDelete(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 [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + 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.AppComplianceAutomation/reports/{reportName}", + **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( + "reportName", self.ctx.args.report_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-06-27", + 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/acat/azext_acat/aaz/latest/app_compliance_automation/report/_fix.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_fix.py deleted file mode 100644 index fbca7c50077..00000000000 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_fix.py +++ /dev/null @@ -1,175 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report fix", -) -class Fix(AAZCommand): - """Fix the AppComplianceAutomation report error. e.g: App Compliance Automation Tool service unregistered, automation removed. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/fix", "2024-06-27"], - ] - } - - 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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.ReportFix(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 ReportFix(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.AppComplianceAutomation/reports/{reportName}/fix", - **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( - "reportName", self.ctx.args.report_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-06-27", - 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.reason = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.result = AAZStrType( - flags={"read_only": True}, - ) - - return cls._schema_on_200 - - -class _FixHelper: - """Helper class for Fix""" - - -__all__ = ["Fix"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_list.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_list.py index d8be08ff2da..44309e9b6ae 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_list.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_list.py @@ -1,395 +1,395 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report list", -) -class List(AAZCommand): - """List the AppComplianceAutomation report list for the tenant. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports", "2024-06-27"], - ] - } - - 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="The filter to apply on the operation.", - fmt=AAZStrArgFormat( - min_length=1, - ), - ) - _args_schema.offer_guid = AAZStrArg( - options=["--offer-guid"], - help="The offerGuid which mapping to the reports.", - fmt=AAZStrArgFormat( - min_length=1, - ), - ) - _args_schema.orderby = AAZStrArg( - options=["--orderby"], - help="OData order by query option.", - fmt=AAZStrArgFormat( - min_length=1, - ), - ) - _args_schema.report_creator_tenant_id = AAZStrArg( - options=["--report-creator-tenant-id"], - help="The tenant id of the report creator.", - fmt=AAZStrArgFormat( - min_length=1, - ), - ) - _args_schema.select = AAZStrArg( - options=["--select"], - help="OData Select statement. Limits the properties on each entry to just those requested, e.g. ?$select=reportName,id.", - fmt=AAZStrArgFormat( - min_length=1, - ), - ) - _args_schema.skip_token = AAZStrArg( - options=["--skip-token"], - help="Skip over when retrieving results.", - ) - _args_schema.top = AAZIntArg( - options=["--top"], - help="Number of elements to return when retrieving results.", - fmt=AAZIntArgFormat( - maximum=100, - minimum=1, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.ReportList(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 ReportList(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.AppComplianceAutomation/reports", - **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( - "$filter", self.ctx.args.filter, - ), - **self.serialize_query_param( - "$orderby", self.ctx.args.orderby, - ), - **self.serialize_query_param( - "$select", self.ctx.args.select, - ), - **self.serialize_query_param( - "$skipToken", self.ctx.args.skip_token, - ), - **self.serialize_query_param( - "$top", self.ctx.args.top, - ), - **self.serialize_query_param( - "offerGuid", self.ctx.args.offer_guid, - ), - **self.serialize_query_param( - "reportCreatorTenantId", self.ctx.args.report_creator_tenant_id, - ), - **self.serialize_query_param( - "api-version", "2024-06-27", - 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( - flags={"required": 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={"required": True, "client_flatten": True}, - ) - _element.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.value.Element.properties - properties.cert_records = AAZListType( - serialized_name="certRecords", - flags={"read_only": True}, - ) - properties.compliance_status = AAZObjectType( - serialized_name="complianceStatus", - flags={"read_only": True}, - ) - properties.errors = AAZListType( - flags={"read_only": True}, - ) - properties.last_trigger_time = AAZStrType( - serialized_name="lastTriggerTime", - flags={"read_only": True}, - ) - properties.next_trigger_time = AAZStrType( - serialized_name="nextTriggerTime", - flags={"read_only": True}, - ) - properties.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.resources = AAZListType( - flags={"required": True}, - ) - properties.status = AAZStrType( - flags={"read_only": True}, - ) - properties.storage_info = AAZObjectType( - serialized_name="storageInfo", - ) - properties.subscriptions = AAZListType( - flags={"read_only": True}, - ) - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.time_zone = AAZStrType( - serialized_name="timeZone", - flags={"required": True}, - ) - properties.trigger_time = AAZStrType( - serialized_name="triggerTime", - flags={"required": True}, - ) - - cert_records = cls._schema_on_200.value.Element.properties.cert_records - cert_records.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.cert_records.Element - _element.certification_status = AAZStrType( - serialized_name="certificationStatus", - ) - _element.controls = AAZListType() - _element.ingestion_status = AAZStrType( - serialized_name="ingestionStatus", - ) - _element.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - - controls = cls._schema_on_200.value.Element.properties.cert_records.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.cert_records.Element.controls.Element - _element.control_id = AAZStrType( - serialized_name="controlId", - ) - _element.control_status = AAZStrType( - serialized_name="controlStatus", - ) - - compliance_status = cls._schema_on_200.value.Element.properties.compliance_status - compliance_status.m365 = AAZObjectType( - flags={"read_only": True}, - ) - - m365 = cls._schema_on_200.value.Element.properties.compliance_status.m365 - m365.failed_count = AAZIntType( - serialized_name="failedCount", - flags={"read_only": True}, - ) - m365.manual_count = AAZIntType( - serialized_name="manualCount", - flags={"read_only": True}, - ) - m365.not_applicable_count = AAZIntType( - serialized_name="notApplicableCount", - flags={"read_only": True}, - ) - m365.passed_count = AAZIntType( - serialized_name="passedCount", - flags={"read_only": True}, - ) - m365.pending_count = AAZIntType( - serialized_name="pendingCount", - flags={"read_only": True}, - ) - - errors = cls._schema_on_200.value.Element.properties.errors - errors.Element = AAZStrType() - - resources = cls._schema_on_200.value.Element.properties.resources - resources.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.resources.Element - _element.account_id = AAZStrType( - serialized_name="accountId", - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"required": True}, - ) - _element.resource_kind = AAZStrType( - serialized_name="resourceKind", - ) - _element.resource_origin = AAZStrType( - serialized_name="resourceOrigin", - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - ) - - storage_info = cls._schema_on_200.value.Element.properties.storage_info - storage_info.account_name = AAZStrType( - serialized_name="accountName", - ) - storage_info.location = AAZStrType() - storage_info.resource_group = AAZStrType( - serialized_name="resourceGroup", - ) - storage_info.subscription_id = AAZStrType( - serialized_name="subscriptionId", - ) - - subscriptions = cls._schema_on_200.value.Element.properties.subscriptions - subscriptions.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", - ) - - return cls._schema_on_200 - - -class _ListHelper: - """Helper class for List""" - - -__all__ = ["List"] +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "app-compliance-automation report list", +) +class List(AAZCommand): + """List the AppComplianceAutomation report list for the tenant. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports", "2024-06-27"], + ] + } + + 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="The filter to apply on the operation.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.offer_guid = AAZStrArg( + options=["--offer-guid"], + help="The offerGuid which mapping to the reports.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.orderby = AAZStrArg( + options=["--orderby"], + help="OData order by query option.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.report_creator_tenant_id = AAZStrArg( + options=["--report-creator-tenant-id"], + help="The tenant id of the report creator.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.select = AAZStrArg( + options=["--select"], + help="OData Select statement. Limits the properties on each entry to just those requested, e.g. ?$select=reportName,id.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.skip_token = AAZStrArg( + options=["--skip-token"], + help="Skip over when retrieving results.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="Number of elements to return when retrieving results.", + fmt=AAZIntArgFormat( + maximum=100, + minimum=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReportList(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 ReportList(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.AppComplianceAutomation/reports", + **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( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "$orderby", self.ctx.args.orderby, + ), + **self.serialize_query_param( + "$select", self.ctx.args.select, + ), + **self.serialize_query_param( + "$skipToken", self.ctx.args.skip_token, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "offerGuid", self.ctx.args.offer_guid, + ), + **self.serialize_query_param( + "reportCreatorTenantId", self.ctx.args.report_creator_tenant_id, + ), + **self.serialize_query_param( + "api-version", "2024-06-27", + 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( + flags={"required": 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={"required": True, "client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.cert_records = AAZListType( + serialized_name="certRecords", + flags={"read_only": True}, + ) + properties.compliance_status = AAZObjectType( + serialized_name="complianceStatus", + flags={"read_only": True}, + ) + properties.errors = AAZListType( + flags={"read_only": True}, + ) + properties.last_trigger_time = AAZStrType( + serialized_name="lastTriggerTime", + flags={"read_only": True}, + ) + properties.next_trigger_time = AAZStrType( + serialized_name="nextTriggerTime", + flags={"read_only": True}, + ) + properties.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.resources = AAZListType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.storage_info = AAZObjectType( + serialized_name="storageInfo", + ) + properties.subscriptions = AAZListType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + properties.trigger_time = AAZStrType( + serialized_name="triggerTime", + flags={"required": True}, + ) + + cert_records = cls._schema_on_200.value.Element.properties.cert_records + cert_records.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.cert_records.Element + _element.certification_status = AAZStrType( + serialized_name="certificationStatus", + ) + _element.controls = AAZListType() + _element.ingestion_status = AAZStrType( + serialized_name="ingestionStatus", + ) + _element.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + + controls = cls._schema_on_200.value.Element.properties.cert_records.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.cert_records.Element.controls.Element + _element.control_id = AAZStrType( + serialized_name="controlId", + ) + _element.control_status = AAZStrType( + serialized_name="controlStatus", + ) + + compliance_status = cls._schema_on_200.value.Element.properties.compliance_status + compliance_status.m365 = AAZObjectType( + flags={"read_only": True}, + ) + + m365 = cls._schema_on_200.value.Element.properties.compliance_status.m365 + m365.failed_count = AAZIntType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + m365.manual_count = AAZIntType( + serialized_name="manualCount", + flags={"read_only": True}, + ) + m365.not_applicable_count = AAZIntType( + serialized_name="notApplicableCount", + flags={"read_only": True}, + ) + m365.passed_count = AAZIntType( + serialized_name="passedCount", + flags={"read_only": True}, + ) + m365.pending_count = AAZIntType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + + errors = cls._schema_on_200.value.Element.properties.errors + errors.Element = AAZStrType() + + resources = cls._schema_on_200.value.Element.properties.resources + resources.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.resources.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + _element.resource_kind = AAZStrType( + serialized_name="resourceKind", + ) + _element.resource_origin = AAZStrType( + serialized_name="resourceOrigin", + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + ) + + storage_info = cls._schema_on_200.value.Element.properties.storage_info + storage_info.account_name = AAZStrType( + serialized_name="accountName", + ) + storage_info.location = AAZStrType() + storage_info.resource_group = AAZStrType( + serialized_name="resourceGroup", + ) + storage_info.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + subscriptions = cls._schema_on_200.value.Element.properties.subscriptions + subscriptions.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", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_show.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_show.py index 93954726b35..88a571f15c3 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_show.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_show.py @@ -1,332 +1,332 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report show", -) -class Show(AAZCommand): - """Get the AppComplianceAutomation report and its properties. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], - ] - } - - 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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.ReportGet(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 ReportGet(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.AppComplianceAutomation/reports/{reportName}", - **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( - "reportName", self.ctx.args.report_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-06-27", - 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={"required": True, "client_flatten": True}, - ) - _schema_on_200.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _schema_on_200.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.properties - properties.cert_records = AAZListType( - serialized_name="certRecords", - flags={"read_only": True}, - ) - properties.compliance_status = AAZObjectType( - serialized_name="complianceStatus", - flags={"read_only": True}, - ) - properties.errors = AAZListType( - flags={"read_only": True}, - ) - properties.last_trigger_time = AAZStrType( - serialized_name="lastTriggerTime", - flags={"read_only": True}, - ) - properties.next_trigger_time = AAZStrType( - serialized_name="nextTriggerTime", - flags={"read_only": True}, - ) - properties.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.resources = AAZListType( - flags={"required": True}, - ) - properties.status = AAZStrType( - flags={"read_only": True}, - ) - properties.storage_info = AAZObjectType( - serialized_name="storageInfo", - ) - properties.subscriptions = AAZListType( - flags={"read_only": True}, - ) - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.time_zone = AAZStrType( - serialized_name="timeZone", - flags={"required": True}, - ) - properties.trigger_time = AAZStrType( - serialized_name="triggerTime", - flags={"required": True}, - ) - - cert_records = cls._schema_on_200.properties.cert_records - cert_records.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.cert_records.Element - _element.certification_status = AAZStrType( - serialized_name="certificationStatus", - ) - _element.controls = AAZListType() - _element.ingestion_status = AAZStrType( - serialized_name="ingestionStatus", - ) - _element.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - - controls = cls._schema_on_200.properties.cert_records.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.cert_records.Element.controls.Element - _element.control_id = AAZStrType( - serialized_name="controlId", - ) - _element.control_status = AAZStrType( - serialized_name="controlStatus", - ) - - compliance_status = cls._schema_on_200.properties.compliance_status - compliance_status.m365 = AAZObjectType( - flags={"read_only": True}, - ) - - m365 = cls._schema_on_200.properties.compliance_status.m365 - m365.failed_count = AAZIntType( - serialized_name="failedCount", - flags={"read_only": True}, - ) - m365.manual_count = AAZIntType( - serialized_name="manualCount", - flags={"read_only": True}, - ) - m365.not_applicable_count = AAZIntType( - serialized_name="notApplicableCount", - flags={"read_only": True}, - ) - m365.passed_count = AAZIntType( - serialized_name="passedCount", - flags={"read_only": True}, - ) - m365.pending_count = AAZIntType( - serialized_name="pendingCount", - flags={"read_only": True}, - ) - - errors = cls._schema_on_200.properties.errors - errors.Element = AAZStrType() - - resources = cls._schema_on_200.properties.resources - resources.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.resources.Element - _element.account_id = AAZStrType( - serialized_name="accountId", - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"required": True}, - ) - _element.resource_kind = AAZStrType( - serialized_name="resourceKind", - ) - _element.resource_origin = AAZStrType( - serialized_name="resourceOrigin", - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - ) - - storage_info = cls._schema_on_200.properties.storage_info - storage_info.account_name = AAZStrType( - serialized_name="accountName", - ) - storage_info.location = AAZStrType() - storage_info.resource_group = AAZStrType( - serialized_name="resourceGroup", - ) - storage_info.subscription_id = AAZStrType( - serialized_name="subscriptionId", - ) - - subscriptions = cls._schema_on_200.properties.subscriptions - subscriptions.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", - ) - - return cls._schema_on_200 - - -class _ShowHelper: - """Helper class for Show""" - - -__all__ = ["Show"] +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "app-compliance-automation report show", +) +class Show(AAZCommand): + """Get the AppComplianceAutomation report and its properties. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], + ] + } + + 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.report_name = AAZStrArg( + options=["--report-name"], + help="Report Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ReportGet(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 ReportGet(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.AppComplianceAutomation/reports/{reportName}", + **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( + "reportName", self.ctx.args.report_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-06-27", + 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={"required": True, "client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.cert_records = AAZListType( + serialized_name="certRecords", + flags={"read_only": True}, + ) + properties.compliance_status = AAZObjectType( + serialized_name="complianceStatus", + flags={"read_only": True}, + ) + properties.errors = AAZListType( + flags={"read_only": True}, + ) + properties.last_trigger_time = AAZStrType( + serialized_name="lastTriggerTime", + flags={"read_only": True}, + ) + properties.next_trigger_time = AAZStrType( + serialized_name="nextTriggerTime", + flags={"read_only": True}, + ) + properties.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.resources = AAZListType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.storage_info = AAZObjectType( + serialized_name="storageInfo", + ) + properties.subscriptions = AAZListType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + properties.trigger_time = AAZStrType( + serialized_name="triggerTime", + flags={"required": True}, + ) + + cert_records = cls._schema_on_200.properties.cert_records + cert_records.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.cert_records.Element + _element.certification_status = AAZStrType( + serialized_name="certificationStatus", + ) + _element.controls = AAZListType() + _element.ingestion_status = AAZStrType( + serialized_name="ingestionStatus", + ) + _element.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + + controls = cls._schema_on_200.properties.cert_records.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.cert_records.Element.controls.Element + _element.control_id = AAZStrType( + serialized_name="controlId", + ) + _element.control_status = AAZStrType( + serialized_name="controlStatus", + ) + + compliance_status = cls._schema_on_200.properties.compliance_status + compliance_status.m365 = AAZObjectType( + flags={"read_only": True}, + ) + + m365 = cls._schema_on_200.properties.compliance_status.m365 + m365.failed_count = AAZIntType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + m365.manual_count = AAZIntType( + serialized_name="manualCount", + flags={"read_only": True}, + ) + m365.not_applicable_count = AAZIntType( + serialized_name="notApplicableCount", + flags={"read_only": True}, + ) + m365.passed_count = AAZIntType( + serialized_name="passedCount", + flags={"read_only": True}, + ) + m365.pending_count = AAZIntType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + + errors = cls._schema_on_200.properties.errors + errors.Element = AAZStrType() + + resources = cls._schema_on_200.properties.resources + resources.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.resources.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + _element.resource_kind = AAZStrType( + serialized_name="resourceKind", + ) + _element.resource_origin = AAZStrType( + serialized_name="resourceOrigin", + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + ) + + storage_info = cls._schema_on_200.properties.storage_info + storage_info.account_name = AAZStrType( + serialized_name="accountName", + ) + storage_info.location = AAZStrType() + storage_info.resource_group = AAZStrType( + serialized_name="resourceGroup", + ) + storage_info.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + subscriptions = cls._schema_on_200.properties.subscriptions + subscriptions.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", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_update.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_update.py index aa9459d53eb..eb164803a29 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_update.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_update.py @@ -1,464 +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( - "app-compliance-automation report update", -) -class Update(AAZCommand): - """Update an exiting AppComplianceAutomation report. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], - ] - } - - 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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.offer_guid = AAZStrArg( - options=["--offer-guid"], - arg_group="Properties", - help="A list of comma-separated offerGuids indicates a series of offerGuids that map to the report. For example, \"00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002\" and \"00000000-0000-0000-0000-000000000003\".", - ) - _args_schema.resources = AAZListArg( - options=["--resources"], - arg_group="Properties", - help="List of resource data.", - ) - _args_schema.storage_info = AAZObjectArg( - options=["--storage-info"], - arg_group="Properties", - help="The information of 'bring your own storage' binding to the report", - ) - _args_schema.time_zone = AAZStrArg( - options=["--time-zone"], - arg_group="Properties", - help="Report collection trigger time's time zone, the available list can be obtained by executing \"Get-TimeZone -ListAvailable\" in PowerShell. An example of valid timezone id is \"Pacific Standard Time\".", - ) - _args_schema.trigger_time = AAZDateTimeArg( - options=["--trigger-time"], - arg_group="Properties", - help="Report collection trigger time.", - ) - - resources = cls._args_schema.resources - resources.Element = AAZObjectArg() - - _element = cls._args_schema.resources.Element - _element.account_id = AAZStrArg( - options=["account-id"], - help="Account Id. For example - the AWS account id.", - ) - _element.resource_id = AAZStrArg( - options=["resource-id"], - help="Resource Id - e.g. \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1\".", - required=True, - ) - _element.resource_kind = AAZStrArg( - options=["resource-kind"], - help="Resource kind.", - ) - _element.resource_origin = AAZStrArg( - options=["resource-origin"], - help="Resource Origin.", - enum={"AWS": "AWS", "Azure": "Azure", "GCP": "GCP"}, - ) - _element.resource_type = AAZStrArg( - options=["resource-type"], - help="Resource type. e.g. \"Microsoft.Compute/virtualMachines\"", - ) - - storage_info = cls._args_schema.storage_info - storage_info.account_name = AAZStrArg( - options=["account-name"], - help="'bring your own storage' account name", - ) - storage_info.location = AAZStrArg( - options=["location"], - help="The region of 'bring your own storage' account", - ) - storage_info.resource_group = AAZStrArg( - options=["resource-group"], - help="The resourceGroup which 'bring your own storage' account belongs to", - ) - storage_info.subscription_id = AAZStrArg( - options=["subscription-id"], - help="The subscription id which 'bring your own storage' account belongs to", - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.ReportUpdate(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 ReportUpdate(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.AppComplianceAutomation/reports/{reportName}", - **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( - "reportName", self.ctx.args.report_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-06-27", - 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) - - properties = _builder.get(".properties") - if properties is not None: - properties.set_prop("offerGuid", AAZStrType, ".offer_guid") - properties.set_prop("resources", AAZListType, ".resources") - properties.set_prop("storageInfo", AAZObjectType, ".storage_info") - properties.set_prop("timeZone", AAZStrType, ".time_zone") - properties.set_prop("triggerTime", AAZStrType, ".trigger_time") - - resources = _builder.get(".properties.resources") - if resources is not None: - resources.set_elements(AAZObjectType, ".") - - _elements = _builder.get(".properties.resources[]") - if _elements is not None: - _elements.set_prop("accountId", AAZStrType, ".account_id") - _elements.set_prop("resourceId", AAZStrType, ".resource_id", typ_kwargs={"flags": {"required": True}}) - _elements.set_prop("resourceKind", AAZStrType, ".resource_kind") - _elements.set_prop("resourceOrigin", AAZStrType, ".resource_origin") - _elements.set_prop("resourceType", AAZStrType, ".resource_type") - - storage_info = _builder.get(".properties.storageInfo") - if storage_info is not None: - storage_info.set_prop("accountName", AAZStrType, ".account_name") - storage_info.set_prop("location", AAZStrType, ".location") - storage_info.set_prop("resourceGroup", AAZStrType, ".resource_group") - storage_info.set_prop("subscriptionId", AAZStrType, ".subscription_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={"required": True, "client_flatten": True}, - ) - _schema_on_200.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _schema_on_200.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.properties - properties.cert_records = AAZListType( - serialized_name="certRecords", - flags={"read_only": True}, - ) - properties.compliance_status = AAZObjectType( - serialized_name="complianceStatus", - flags={"read_only": True}, - ) - properties.errors = AAZListType( - flags={"read_only": True}, - ) - properties.last_trigger_time = AAZStrType( - serialized_name="lastTriggerTime", - flags={"read_only": True}, - ) - properties.next_trigger_time = AAZStrType( - serialized_name="nextTriggerTime", - flags={"read_only": True}, - ) - properties.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.resources = AAZListType( - flags={"required": True}, - ) - properties.status = AAZStrType( - flags={"read_only": True}, - ) - properties.storage_info = AAZObjectType( - serialized_name="storageInfo", - ) - properties.subscriptions = AAZListType( - flags={"read_only": True}, - ) - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.time_zone = AAZStrType( - serialized_name="timeZone", - flags={"required": True}, - ) - properties.trigger_time = AAZStrType( - serialized_name="triggerTime", - flags={"required": True}, - ) - - cert_records = cls._schema_on_200.properties.cert_records - cert_records.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.cert_records.Element - _element.certification_status = AAZStrType( - serialized_name="certificationStatus", - ) - _element.controls = AAZListType() - _element.ingestion_status = AAZStrType( - serialized_name="ingestionStatus", - ) - _element.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - - controls = cls._schema_on_200.properties.cert_records.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.cert_records.Element.controls.Element - _element.control_id = AAZStrType( - serialized_name="controlId", - ) - _element.control_status = AAZStrType( - serialized_name="controlStatus", - ) - - compliance_status = cls._schema_on_200.properties.compliance_status - compliance_status.m365 = AAZObjectType( - flags={"read_only": True}, - ) - - m365 = cls._schema_on_200.properties.compliance_status.m365 - m365.failed_count = AAZIntType( - serialized_name="failedCount", - flags={"read_only": True}, - ) - m365.manual_count = AAZIntType( - serialized_name="manualCount", - flags={"read_only": True}, - ) - m365.not_applicable_count = AAZIntType( - serialized_name="notApplicableCount", - flags={"read_only": True}, - ) - m365.passed_count = AAZIntType( - serialized_name="passedCount", - flags={"read_only": True}, - ) - m365.pending_count = AAZIntType( - serialized_name="pendingCount", - flags={"read_only": True}, - ) - - errors = cls._schema_on_200.properties.errors - errors.Element = AAZStrType() - - resources = cls._schema_on_200.properties.resources - resources.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.resources.Element - _element.account_id = AAZStrType( - serialized_name="accountId", - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"required": True}, - ) - _element.resource_kind = AAZStrType( - serialized_name="resourceKind", - ) - _element.resource_origin = AAZStrType( - serialized_name="resourceOrigin", - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - ) - - storage_info = cls._schema_on_200.properties.storage_info - storage_info.account_name = AAZStrType( - serialized_name="accountName", - ) - storage_info.location = AAZStrType() - storage_info.resource_group = AAZStrType( - serialized_name="resourceGroup", - ) - storage_info.subscription_id = AAZStrType( - serialized_name="subscriptionId", - ) - - subscriptions = cls._schema_on_200.properties.subscriptions - subscriptions.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", - ) - - return cls._schema_on_200 - - -class _UpdateHelper: - """Helper class for Update""" - - -__all__ = ["Update"] +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "app-compliance-automation report update", +) +class Update(AAZCommand): + """Update a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}", "2024-06-27"], + ] + } + + 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.report_name = AAZStrArg( + options=["--report-name"], + help="Report Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.offer_guid = AAZStrArg( + options=["--offer-guid"], + arg_group="Properties", + help="A list of comma-separated offerGuids indicates a series of offerGuids that map to the report. For example, \"00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002\" and \"00000000-0000-0000-0000-000000000003\".", + ) + _args_schema.resources = AAZListArg( + options=["--resources"], + arg_group="Properties", + help="List of resource data.", + ) + _args_schema.storage_info = AAZObjectArg( + options=["--storage-info"], + arg_group="Properties", + help="The information of 'bring your own storage' binding to the report", + ) + _args_schema.time_zone = AAZStrArg( + options=["--time-zone"], + arg_group="Properties", + help="Report collection trigger time's time zone, the available list can be obtained by executing \"Get-TimeZone -ListAvailable\" in PowerShell. An example of valid timezone id is \"Pacific Standard Time\".", + ) + _args_schema.trigger_time = AAZDateTimeArg( + options=["--trigger-time"], + arg_group="Properties", + help="Report collection trigger time.", + ) + + resources = cls._args_schema.resources + resources.Element = AAZObjectArg() + + _element = cls._args_schema.resources.Element + _element.account_id = AAZStrArg( + options=["account-id"], + help="Account Id. For example - the AWS account id.", + ) + _element.resource_id = AAZStrArg( + options=["resource-id"], + help="Resource Id - e.g. \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1\".", + required=True, + ) + _element.resource_kind = AAZStrArg( + options=["resource-kind"], + help="Resource kind.", + ) + _element.resource_origin = AAZStrArg( + options=["resource-origin"], + help="Resource Origin.", + enum={"AWS": "AWS", "Azure": "Azure", "GCP": "GCP"}, + ) + _element.resource_type = AAZStrArg( + options=["resource-type"], + help="Resource type. e.g. \"Microsoft.Compute/virtualMachines\"", + ) + + storage_info = cls._args_schema.storage_info + storage_info.account_name = AAZStrArg( + options=["account-name"], + help="'bring your own storage' account name", + ) + storage_info.location = AAZStrArg( + options=["location"], + help="The region of 'bring your own storage' account", + ) + storage_info.resource_group = AAZStrArg( + options=["resource-group"], + help="The resourceGroup which 'bring your own storage' account belongs to", + ) + storage_info.subscription_id = AAZStrArg( + options=["subscription-id"], + help="The subscription id which 'bring your own storage' account belongs to", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ReportUpdate(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 ReportUpdate(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.AppComplianceAutomation/reports/{reportName}", + **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( + "reportName", self.ctx.args.report_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-06-27", + 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) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("offerGuid", AAZStrType, ".offer_guid") + properties.set_prop("resources", AAZListType, ".resources") + properties.set_prop("storageInfo", AAZObjectType, ".storage_info") + properties.set_prop("timeZone", AAZStrType, ".time_zone") + properties.set_prop("triggerTime", AAZStrType, ".trigger_time") + + resources = _builder.get(".properties.resources") + if resources is not None: + resources.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.resources[]") + if _elements is not None: + _elements.set_prop("accountId", AAZStrType, ".account_id") + _elements.set_prop("resourceId", AAZStrType, ".resource_id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("resourceKind", AAZStrType, ".resource_kind") + _elements.set_prop("resourceOrigin", AAZStrType, ".resource_origin") + _elements.set_prop("resourceType", AAZStrType, ".resource_type") + + storage_info = _builder.get(".properties.storageInfo") + if storage_info is not None: + storage_info.set_prop("accountName", AAZStrType, ".account_name") + storage_info.set_prop("location", AAZStrType, ".location") + storage_info.set_prop("resourceGroup", AAZStrType, ".resource_group") + storage_info.set_prop("subscriptionId", AAZStrType, ".subscription_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={"required": True, "client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.cert_records = AAZListType( + serialized_name="certRecords", + flags={"read_only": True}, + ) + properties.compliance_status = AAZObjectType( + serialized_name="complianceStatus", + flags={"read_only": True}, + ) + properties.errors = AAZListType( + flags={"read_only": True}, + ) + properties.last_trigger_time = AAZStrType( + serialized_name="lastTriggerTime", + flags={"read_only": True}, + ) + properties.next_trigger_time = AAZStrType( + serialized_name="nextTriggerTime", + flags={"read_only": True}, + ) + properties.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.resources = AAZListType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.storage_info = AAZObjectType( + serialized_name="storageInfo", + ) + properties.subscriptions = AAZListType( + flags={"read_only": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + properties.trigger_time = AAZStrType( + serialized_name="triggerTime", + flags={"required": True}, + ) + + cert_records = cls._schema_on_200.properties.cert_records + cert_records.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.cert_records.Element + _element.certification_status = AAZStrType( + serialized_name="certificationStatus", + ) + _element.controls = AAZListType() + _element.ingestion_status = AAZStrType( + serialized_name="ingestionStatus", + ) + _element.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + + controls = cls._schema_on_200.properties.cert_records.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.cert_records.Element.controls.Element + _element.control_id = AAZStrType( + serialized_name="controlId", + ) + _element.control_status = AAZStrType( + serialized_name="controlStatus", + ) + + compliance_status = cls._schema_on_200.properties.compliance_status + compliance_status.m365 = AAZObjectType( + flags={"read_only": True}, + ) + + m365 = cls._schema_on_200.properties.compliance_status.m365 + m365.failed_count = AAZIntType( + serialized_name="failedCount", + flags={"read_only": True}, + ) + m365.manual_count = AAZIntType( + serialized_name="manualCount", + flags={"read_only": True}, + ) + m365.not_applicable_count = AAZIntType( + serialized_name="notApplicableCount", + flags={"read_only": True}, + ) + m365.passed_count = AAZIntType( + serialized_name="passedCount", + flags={"read_only": True}, + ) + m365.pending_count = AAZIntType( + serialized_name="pendingCount", + flags={"read_only": True}, + ) + + errors = cls._schema_on_200.properties.errors + errors.Element = AAZStrType() + + resources = cls._schema_on_200.properties.resources + resources.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.resources.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + _element.resource_kind = AAZStrType( + serialized_name="resourceKind", + ) + _element.resource_origin = AAZStrType( + serialized_name="resourceOrigin", + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + ) + + storage_info = cls._schema_on_200.properties.storage_info + storage_info.account_name = AAZStrType( + serialized_name="accountName", + ) + storage_info.location = AAZStrType() + storage_info.resource_group = AAZStrType( + serialized_name="resourceGroup", + ) + storage_info.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + + subscriptions = cls._schema_on_200.properties.subscriptions + subscriptions.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", + ) + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_verify.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_verify.py deleted file mode 100644 index 7a8eba9a819..00000000000 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/_verify.py +++ /dev/null @@ -1,175 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report verify", -) -class Verify(AAZCommand): - """Verify the AppComplianceAutomation report health status. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/verify", "2024-06-27"], - ] - } - - 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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.ReportVerify(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 ReportVerify(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.AppComplianceAutomation/reports/{reportName}/verify", - **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( - "reportName", self.ctx.args.report_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-06-27", - 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.reason = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.result = AAZStrType( - flags={"read_only": True}, - ) - - return cls._schema_on_200 - - -class _VerifyHelper: - """Helper class for Verify""" - - -__all__ = ["Verify"] diff --git a/src/acat/azext_acat/commands.py b/src/acat/azext_acat/commands.py index 4c8525771b6..7aa7e2344f8 100644 --- a/src/acat/azext_acat/commands.py +++ b/src/acat/azext_acat/commands.py @@ -12,4 +12,18 @@ def load_command_table(self, _): # pylint: disable=unused-argument - pass + with self.command_group('acat report') as g: + from .custom import OnboardAcat + self.command_table["acat onboard"]=OnboardAcat(loader=self) + + from .custom import CreateAcatReport + self.command_table["acat report create"]=CreateAcatReport(loader=self) + + from .custom import ListAcatReport + self.command_table["acat report list"]=ListAcatReport(loader=self) + + from .custom import ShowAcatReport + self.command_table["acat report show"]=ShowAcatReport(loader=self) + + from .custom import DeleteAcatReport + self.command_table["acat report delete"]=DeleteAcatReport(loader=self) diff --git a/src/acat/azext_acat/custom.py b/src/acat/azext_acat/custom.py index 5bfa59e5329..1429219cd1f 100644 --- a/src/acat/azext_acat/custom.py +++ b/src/acat/azext_acat/custom.py @@ -9,6 +9,155 @@ # pylint: disable=too-many-statements from knack.log import get_logger - +import datetime +from azure.cli.core._profile import Profile +from azure.cli.core.aaz._client import AAZMgmtClient +from .aaz.latest.app_compliance_automation import Onboard as _AcatOnboard +from .aaz.latest.app_compliance_automation.report import Create as _AcatCreateReport +from .aaz.latest.app_compliance_automation.report import List as _AcatListReport +from .aaz.latest.app_compliance_automation.report import Show as _AcatShowReport +from .aaz.latest.app_compliance_automation.report import Delete as _AcatDeleteReport +from azure.cli.core.aaz import register_client,AAZClientConfiguration +from azure.cli.core.commands import LongRunningOperation logger = get_logger(__name__) + +@register_client("DupAadTokenClient") +class AAZDupAadTokenClient(AAZMgmtClient): + @classmethod + def _build_configuration(cls, ctx, credential, **kwargs): + from azure.cli.core.auth.util import resource_to_scopes + from azure.core.pipeline.policies import HeadersPolicy + + token="Bearer "+credential.get_token().token + headers_policy=HeadersPolicy(**kwargs) + headers_policy.add_header("x-ms-aad-user-token",token) + kwargs["headers_policy"]=headers_policy + + return AAZClientConfiguration( + credential=credential, + credential_scopes=resource_to_scopes(ctx.cli_ctx.cloud.endpoints.active_directory_resource_id), + **kwargs + ) + +class OnboardAcat(_AcatOnboard): + class OnboardAcatWithDupAadToken(_AcatOnboard.ProviderActionsOnboard): + CLIENT_TYPE = "DupAadTokenClient" + + def _execute_operations(self): + self.pre_operations() + yield self.OnboardAcatWithDupAadToken(ctx=self.ctx)() + self.post_operations() + + +class CreateAcatReport(_AcatCreateReport): + class CreateAcatReportWithDupAadToken(_AcatCreateReport.ReportCreateOrUpdate): + CLIENT_TYPE = "DupAadTokenClient" + + def _execute_operations(self): + self.pre_operations() + yield self.CreateAcatReportWithDupAadToken(ctx=self.ctx)() + self.post_operations() + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + from azure.cli.core.aaz import AAZDateTimeArg, AAZStrArg + + args_schema.time_zone._required=False + args_schema.time_zone._registered=False + args_schema.time_zone_with_default= AAZStrArg( + options=["--time-zone"], + arg_group="Properties", + help="Report collection trigger time's time zone, the available list can be obtained by executing \"Get-TimeZone -ListAvailable\" in PowerShell. An example of valid timezone id is \"Pacific Standard Time\".", + default=GetLocalTimeZone() + ) + args_schema.trigger_time._required=False + args_schema.trigger_time._registered=False + args_schema.trigger_time_with_default = AAZDateTimeArg( + options=["--trigger-time"], + arg_group="Properties", + help="Report collection trigger time.", + default=GetClosestFullHour() + ) + return args_schema + + def pre_operations(self): + cmd=OnboardAcat(cli_ctx=self.cli_ctx) + + poller=cmd._handler({ + "cmd": cmd, + "subscription_ids": ParseSubsFromResources(self.ctx.args.resources) + }) + LongRunningOperation( + cmd.cli_ctx, 'Starting {}'.format(cmd.name))(poller) + + args = self.ctx.args + args.time_zone=args.nullable_time_zone_with_default + args.trigger_time=args.trigger_time_with_default + + +class ListAcatReport(_AcatListReport): + class ListAcatReportWithDupAadToken(_AcatListReport.ReportList): + CLIENT_TYPE = "DupAadTokenClient" + + def _execute_operations(self): + self.pre_operations() + self.ListAcatReportWithDupAadToken(ctx=self.ctx)() + self.post_operations() + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema= super()._build_arguments_schema(*args, **kwargs) + + from azure.cli.core.aaz import AAZStrArg,AAZStrArgFormat + args_schema.report_creator_tenant_id._registered = False + args_schema.tenant_id = AAZStrArg( + options=["--tenant"], + help="The tenant id of the report creator.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + return args_schema + + def pre_operations(self): + args = self.ctx.args + args.report_creator_tenant_id=args.tenant_id + + +class ShowAcatReport(_AcatShowReport): + class ShowAcatReportWithDupAadToken(_AcatShowReport.ReportGet): + CLIENT_TYPE = "DupAadTokenClient" + + def _execute_operations(self): + self.pre_operations() + self.ShowAcatReportWithDupAadToken(ctx=self.ctx)() + self.post_operations() +class DeleteAcatReport(_AcatDeleteReport): + class DeleteAcatReportWithDupAadToken(_AcatDeleteReport.ReportDelete): + CLIENT_TYPE = "DupAadTokenClient" + + def _execute_operations(self): + self.pre_operations() + yield self.DeleteAcatReportWithDupAadToken(ctx=self.ctx)() + self.post_operations() + + +# utils +def ParseSubsFromResources(resourceList): + """Parse subscriptions from resources""" + subs = set() + for resource in resourceList: + sub = resource.resource_id._data.split("/")[2] + subs.add(sub) + return list(subs) + +def GetLocalTimeZone(): + """Get local time zone""" + return str(datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo) + +def GetClosestFullHour(): + """Get closest full hour""" + now = datetime.datetime.now() + return str(now.replace(minute=0, second=0, microsecond=0) + datetime.timedelta(hours=1))