From 5d046625fa751c54013b993b2a20530d9a0b66cd Mon Sep 17 00:00:00 2001 From: huiquanjiang Date: Thu, 4 Jul 2024 18:16:07 +0800 Subject: [PATCH] to be refactored --- .../app_compliance_automation/__init__.py | 25 +- .../_trigger_evaluation.py | 235 +++ .../app_compliance_automation/polling.py | 100 ++ .../report/snapshot/__cmd_group.py | 3 - .../report/snapshot/_download.py | 693 +++++---- .../report/snapshot/_list.py | 1352 +++++++++-------- .../report/snapshot/_show.py | 1250 +++++++-------- .../report/webhook/_create.py | 688 +++++---- .../report/webhook/_delete.py | 278 ++-- .../report/webhook/_list.py | 639 ++++---- .../report/webhook/_show.py | 501 +++--- .../report/webhook/_update.py | 668 ++++---- 12 files changed, 3457 insertions(+), 2975 deletions(-) create mode 100644 src/acat/azext_acat/aaz/latest/app_compliance_automation/_trigger_evaluation.py create mode 100644 src/acat/azext_acat/aaz/latest/app_compliance_automation/polling.py diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/__init__.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/__init__.py index d9e083b082b..e69c06e6bd2 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/__init__.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/__init__.py @@ -1,12 +1,13 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from .__cmd_group import * -from ._onboard 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 ._onboard import * +from ._trigger_evaluation import * diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/_trigger_evaluation.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/_trigger_evaluation.py new file mode 100644 index 00000000000..f0bbe9a0961 --- /dev/null +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/_trigger_evaluation.py @@ -0,0 +1,235 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * +from azure.cli.core._profile import Profile + + +@register_command( + "acat quick-evaluation", +) +class TriggerEvaluation(AAZCommand): + """Trigger an evaluation for a list of resources. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/triggerevaluation", "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 "Body" + + _args_schema = cls._args_schema + _args_schema.resource_ids = AAZListArg( + options=["--resource-ids"], + arg_group="Body", + help="List of resource ids to be evaluated", + required=True, + ) + + resource_ids = cls._args_schema.resource_ids + resource_ids.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + profile = Profile(cli_ctx=self.cli_ctx) + creds,_,_=profile.get_raw_token(); + self.pre_operations() + yield self.ProviderActionsTriggerEvaluation(ctx=self.ctx)(creds[1]) + 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 ProviderActionsTriggerEvaluation(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + self.token="Bearer "+args[0] + 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/triggerEvaluation", + **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", + ), + **self.serialize_header_param( + "x-ms-aad-user-token", self.token, + ), + } + 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("resourceIds", AAZListType, ".resource_ids", typ_kwargs={"flags": {"required": True}}) + + resource_ids = _builder.get(".resourceIds") + if resource_ids is not None: + resource_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.properties = AAZObjectType() + + properties = cls._schema_on_200.properties + properties.evaluation_end_time = AAZStrType( + serialized_name="evaluationEndTime", + flags={"read_only": True}, + ) + properties.quick_assessments = AAZListType( + serialized_name="quickAssessments", + ) + properties.resource_ids = AAZListType( + serialized_name="resourceIds", + ) + properties.trigger_time = AAZStrType( + serialized_name="triggerTime", + flags={"read_only": True}, + ) + + quick_assessments = cls._schema_on_200.properties.quick_assessments + quick_assessments.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.quick_assessments.Element + _element.description = AAZStrType( + flags={"read_only": True}, + ) + _element.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + _element.remediation_link = AAZStrType( + serialized_name="remediationLink", + flags={"read_only": True}, + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"read_only": True}, + ) + _element.resource_status = AAZStrType( + serialized_name="resourceStatus", + ) + _element.responsibility_id = AAZStrType( + serialized_name="responsibilityId", + flags={"read_only": True}, + ) + _element.timestamp = AAZStrType( + flags={"read_only": True}, + ) + + resource_ids = cls._schema_on_200.properties.resource_ids + resource_ids.Element = AAZStrType() + + return cls._schema_on_200 + + +class _TriggerEvaluationHelper: + """Helper class for TriggerEvaluation""" + + +__all__ = ["TriggerEvaluation"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/polling.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/polling.py new file mode 100644 index 00000000000..7a9362de73d --- /dev/null +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/polling.py @@ -0,0 +1,100 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +from azure.core.pipeline._tools import is_rest +from azure.core.polling import NoPolling +from azure.core.polling.base_polling import (LocationPolling, LROBasePolling, + StatusCheckPolling) + + +class AAZNoPolling(NoPolling): + pass + + +class MyBasePolling(LROBasePolling): + def __init__(self, *args, **kwargs): + self.token = kwargs.pop("token", None) + super().__init__(*args, **kwargs) + + def request_status(self, status_link): + if self._path_format_arguments: + status_link = self._client.format_url(status_link, **self._path_format_arguments) + # Re-inject 'x-ms-client-request-id' while polling + if "request_id" not in self._operation_config: + self._operation_config["request_id"] = self._get_request_id() + if is_rest(self._initial_response.http_response): + # if I am a azure.core.rest.HttpResponse + # want to keep making azure.core.rest calls + from azure.core.rest import HttpRequest as RestHttpRequest + request = RestHttpRequest("GET", status_link, headers={"x-ms-aad-user-token": self.token}) + return self._client.send_request( + request, _return_pipeline_response=True, **self._operation_config + ) + # if I am a azure.core.pipeline.transport.HttpResponse + request = self._client.get(status_link, headers={"x-ms-aad-user-token": self.token}) + return self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **self._operation_config + ) + + +class AAZBasePolling(MyBasePolling): + + def __init__(self, *args, http_response_error_callback=None, **kwargs): + super().__init__(*args, **kwargs) + self._http_response_error_callback = http_response_error_callback + + def initialize(self, client, initial_response, deserialization_callback): + try: + super().initialize(client, initial_response, deserialization_callback) + except HttpResponseError as err: + if self._http_response_error_callback: + # the HttpResponseError raise by LROBasePolling missing detailed error message + # _http_response_error_callback will build HttpResponseError with detailed error message + self._http_response_error_callback(err.response) + else: + raise err + + def run(self): + try: + super().run() + except HttpResponseError as err: + if self._http_response_error_callback: + # the HttpResponseError raise by LROBasePolling missing detailed message + # _http_response_error_callback will build HttpResponseError with detailed error message + self._http_response_error_callback(err.response) + else: + raise err + + +def PollOperationResult(client, no_wait, initial_session, deserialization_callback, error_callback, lro_options=None, path_format_arguments=None, user_token=None): + from azure.mgmt.core.polling.arm_polling import ( + AzureAsyncOperationPolling, BodyContentPolling) + + # from azure.cli.core._poller import AAZNoPolling, AAZBasePolling + if no_wait == True: # noqa: E712, pylint: disable=singleton-comparison + polling = AAZNoPolling() + else: + polling = AAZBasePolling( + lro_options=lro_options, + lro_algorithms=[ + AzureAsyncOperationPolling(lro_options=lro_options), + LocationPolling(), + BodyContentPolling(), + StatusCheckPolling(), + ], + path_format_arguments=path_format_arguments, + http_response_error_callback=error_callback, + token=user_token, + ) + + polling.initialize( + client, + initial_response=initial_session, + deserialization_callback=deserialization_callback + ) + return polling diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/__cmd_group.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/__cmd_group.py index 2603b41e7f7..e1f41715464 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/__cmd_group.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/__cmd_group.py @@ -11,9 +11,6 @@ from azure.cli.core.aaz import * -@register_command_group( - "app-compliance-automation report snapshot", -) class __CMDGroup(AAZCommandGroup): """manage ACAT report snapshots """ diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_download.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_download.py index 247a439ee3d..0d589286bee 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_download.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_download.py @@ -1,323 +1,370 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the 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 snapshot download", -) -class Download(AAZCommand): - """Download compliance needs from snapshot, like: Compliance Report, Resource List. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/snapshots/{}/download", "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}$", - ), - ) - _args_schema.snapshot_name = AAZStrArg( - options=["--snapshot-name"], - help="Snapshot Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9-_]{1,64}$", - ), - ) - - # define Arg Group "Parameters" - - _args_schema = cls._args_schema - _args_schema.download_type = AAZStrArg( - options=["--download-type"], - arg_group="Parameters", - help="Indicates the download type.", - required=True, - enum={"ComplianceDetailedPdfReport": "ComplianceDetailedPdfReport", "CompliancePdfReport": "CompliancePdfReport", "ComplianceReport": "ComplianceReport", "ResourceList": "ResourceList"}, - ) - _args_schema.offer_guid = AAZStrArg( - options=["--offer-guid"], - arg_group="Parameters", - help="The offerGuid which mapping to the reports.", - fmt=AAZStrArgFormat( - min_length=1, - ), - ) - _args_schema.report_creator_tenant_id = AAZStrArg( - options=["--report-creator-tenant-id"], - arg_group="Parameters", - help="Tenant id.", - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.SnapshotDownload(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 SnapshotDownload(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}/snapshots/{snapshotName}/download", - **self.url_parameters - ) - - @property - def method(self): - return "POST" - - @property - def error_format(self): - return "MgmtErrorFormat" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "reportName", self.ctx.args.report_name, - required=True, - ), - **self.serialize_url_param( - "snapshotName", self.ctx.args.snapshot_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("downloadType", AAZStrType, ".download_type", typ_kwargs={"flags": {"required": True}}) - _builder.set_prop("offerGuid", AAZStrType, ".offer_guid") - _builder.set_prop("reportCreatorTenantId", AAZStrType, ".report_creator_tenant_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.compliance_detailed_pdf_report = AAZObjectType( - serialized_name="complianceDetailedPdfReport", - flags={"read_only": True}, - ) - _schema_on_200.compliance_pdf_report = AAZObjectType( - serialized_name="compliancePdfReport", - flags={"read_only": True}, - ) - _schema_on_200.compliance_report = AAZListType( - serialized_name="complianceReport", - flags={"read_only": True}, - ) - _schema_on_200.resource_list = AAZListType( - serialized_name="resourceList", - flags={"read_only": True}, - ) - - compliance_detailed_pdf_report = cls._schema_on_200.compliance_detailed_pdf_report - compliance_detailed_pdf_report.sas_uri = AAZStrType( - serialized_name="sasUri", - flags={"read_only": True}, - ) - - compliance_pdf_report = cls._schema_on_200.compliance_pdf_report - compliance_pdf_report.sas_uri = AAZStrType( - serialized_name="sasUri", - flags={"read_only": True}, - ) - - compliance_report = cls._schema_on_200.compliance_report - compliance_report.Element = AAZObjectType() - - _element = cls._schema_on_200.compliance_report.Element - _element.category_name = AAZStrType( - serialized_name="categoryName", - flags={"read_only": True}, - ) - _element.control_family_name = AAZStrType( - serialized_name="controlFamilyName", - flags={"read_only": True}, - ) - _element.control_id = AAZStrType( - serialized_name="controlId", - flags={"read_only": True}, - ) - _element.control_name = AAZStrType( - serialized_name="controlName", - flags={"read_only": True}, - ) - _element.control_status = AAZStrType( - serialized_name="controlStatus", - flags={"read_only": True}, - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"read_only": True}, - ) - _element.resource_origin = AAZStrType( - serialized_name="resourceOrigin", - flags={"read_only": True}, - ) - _element.resource_status = AAZStrType( - serialized_name="resourceStatus", - flags={"read_only": True}, - ) - _element.resource_status_change_date = AAZStrType( - serialized_name="resourceStatusChangeDate", - flags={"read_only": True}, - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - flags={"read_only": True}, - ) - _element.responsibility_description = AAZStrType( - serialized_name="responsibilityDescription", - flags={"read_only": True}, - ) - _element.responsibility_title = AAZStrType( - serialized_name="responsibilityTitle", - flags={"read_only": True}, - ) - - resource_list = cls._schema_on_200.resource_list - resource_list.Element = AAZObjectType() - - _element = cls._schema_on_200.resource_list.Element - _element.resource_group = AAZStrType( - serialized_name="resourceGroup", - flags={"read_only": True}, - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"read_only": True}, - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - flags={"read_only": True}, - ) - _element.subscription_id = AAZStrType( - serialized_name="subscriptionId", - flags={"read_only": True}, - ) - - return cls._schema_on_200 - - -class _DownloadHelper: - """Helper class for Download""" - - -__all__ = ["Download"] +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * +from azure.cli.core._profile import Profile +from .snapshot import List +import os + +@register_command( + "acat report download", +) +class Download(AAZCommand): + """Download compliance needs from snapshot, like: Compliance Report, Resource List. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/snapshots/{}/download", "2024-06-27"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + profile = Profile(cli_ctx=self.cli_ctx) + creds,_,_=profile.get_raw_token(); + snapshotName=self.pre_operations() + if snapshotName is None: + return "No snapshot found for report {}".format(self.ctx.args.report_name) + self.SnapshotDownload(ctx=self.ctx)(creds[1],snapshotName) + self.post_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}$", + ), + ) + _args_schema.snapshot_name = AAZStrArg( + options=["--snapshot-name"], + help="Snapshot Name.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-_]{1,64}$", + ), + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.download_type = AAZStrArg( + options=["--download-type"], + arg_group="Parameters", + help="Indicates the download type.", + required=True, + enum={"ComplianceDetailedPdfReport": "ComplianceDetailedPdfReport", "CompliancePdfReport": "CompliancePdfReport", "ComplianceReport": "ComplianceReport", "ResourceList": "ResourceList"}, + ) + _args_schema.path=AAZStrArg( + options=["--path"], + arg_group="Parameters", + help="Path to the downloaded file", + required=False, + ) + _args_schema.name=AAZStrArg( + options=["--name"], + arg_group="Parameters", + help="Name of the downloaded file without postfix", + required=False, + ) + _args_schema.offer_guid = AAZStrArg( + options=["--offer-guid"], + arg_group="Parameters", + help="The offerGuid which mapping to the reports.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.report_creator_tenant_id = AAZStrArg( + options=["--report-creator-tenant-id","--tenant"], + arg_group="Parameters", + help="Tenant id.", + ) + return cls._args_schema + + def _execute_operations(self): + profile = Profile(cli_ctx=self.cli_ctx) + creds,_,_=profile.get_raw_token(); + self.pre_operations() + yield self.SnapshotDownload(ctx=self.ctx)(creds[1]) + self.post_operations() + + @register_callback + def pre_operations(self): + cmd=List(cli_ctx=self.cli_ctx) + result=cmd._handler({ + "cmd":cmd, + "report_name":self.ctx.args.report_name + }) + return result["properties"]["snapshotName"] if result is not None else None + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + + downloadType=str(self.ctx.args["downloadType"]) + path=self.ctx.args["path"] or os.getcwd() + fname=self.ctx.args["name"] or downloadType + fullpath=os.path.join(path,fname)+ (".pdf" if downloadType=="CompliancePdfReport" else ".csv") + + if(downloadType=="CompliancePdfReport"): + import urllib.request + urllib.request.urlretrieve(result["compliancePdfReport"]["sasUri"], fullpath) + elif(downloadType=="ComplianceReport"): + saveArrayAsCsv(result["complianceReport"],fullpath) + elif(downloadType=="ResourceList"): + saveArrayAsCsv(result["resourceList"],fullpath) + else: + raise NameError("Unsupported download type {}".format(downloadType)) + return "File downloaded at {0}".format(fullpath) + + class SnapshotDownload(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + self.token="Bearer "+args[0] + self.snapshot_name=args[1] + 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.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/snapshots/{snapshotName}/download", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "reportName", self.ctx.args.report_name, + required=True, + ), + **self.serialize_url_param( + "snapshotName", self.snapshot_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", + ), + **self.serialize_header_param( + "x-ms-aad-user-token", self.token, + ), + } + 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("downloadType", AAZStrType, ".download_type", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("offerGuid", AAZStrType, ".offer_guid") + _builder.set_prop("reportCreatorTenantId", AAZStrType, ".report_creator_tenant_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.compliance_detailed_pdf_report = AAZObjectType( + serialized_name="complianceDetailedPdfReport", + flags={"read_only": True}, + ) + _schema_on_200.compliance_pdf_report = AAZObjectType( + serialized_name="compliancePdfReport", + flags={"read_only": True}, + ) + _schema_on_200.compliance_report = AAZListType( + serialized_name="complianceReport", + flags={"read_only": True}, + ) + _schema_on_200.resource_list = AAZListType( + serialized_name="resourceList", + flags={"read_only": True}, + ) + + compliance_detailed_pdf_report = cls._schema_on_200.compliance_detailed_pdf_report + compliance_detailed_pdf_report.sas_uri = AAZStrType( + serialized_name="sasUri", + flags={"read_only": True}, + ) + + compliance_pdf_report = cls._schema_on_200.compliance_pdf_report + compliance_pdf_report.sas_uri = AAZStrType( + serialized_name="sasUri", + flags={"read_only": True}, + ) + + compliance_report = cls._schema_on_200.compliance_report + compliance_report.Element = AAZObjectType() + + _element = cls._schema_on_200.compliance_report.Element + _element.category_name = AAZStrType( + serialized_name="categoryName", + flags={"read_only": True}, + ) + _element.control_family_name = AAZStrType( + serialized_name="controlFamilyName", + flags={"read_only": True}, + ) + _element.control_id = AAZStrType( + serialized_name="controlId", + flags={"read_only": True}, + ) + _element.control_name = AAZStrType( + serialized_name="controlName", + flags={"read_only": True}, + ) + _element.control_status = AAZStrType( + serialized_name="controlStatus", + flags={"read_only": True}, + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"read_only": True}, + ) + _element.resource_origin = AAZStrType( + serialized_name="resourceOrigin", + flags={"read_only": True}, + ) + _element.resource_status = AAZStrType( + serialized_name="resourceStatus", + flags={"read_only": True}, + ) + _element.resource_status_change_date = AAZStrType( + serialized_name="resourceStatusChangeDate", + flags={"read_only": True}, + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + flags={"read_only": True}, + ) + _element.responsibility_description = AAZStrType( + serialized_name="responsibilityDescription", + flags={"read_only": True}, + ) + _element.responsibility_title = AAZStrType( + serialized_name="responsibilityTitle", + flags={"read_only": True}, + ) + + resource_list = cls._schema_on_200.resource_list + resource_list.Element = AAZObjectType() + + _element = cls._schema_on_200.resource_list.Element + _element.resource_group = AAZStrType( + serialized_name="resourceGroup", + flags={"read_only": True}, + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"read_only": True}, + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + flags={"read_only": True}, + ) + _element.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _DownloadHelper: + """Helper class for Download""" + +def saveArrayAsCsv(arr,fullpath): + import csv + with open(fullpath,"w") as out: + csv_writer=csv.writer(out,lineterminator="\n") + csv_writer.writerow(arr[0].keys()) + for obj in arr: + csv_writer.writerow(obj.values()) + +__all__ = ["Download"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_list.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_list.py index eaad61a48ad..c4642161741 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_list.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_list.py @@ -1,670 +1,682 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the 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 snapshot list", -) -class List(AAZCommand): - """List the AppComplianceAutomation snapshot list. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/snapshots", "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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - _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.SnapshotList(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 SnapshotList(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}/snapshots", - **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( - "$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={"client_flatten": True}, - ) - _element.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _ListHelper._build_schema_system_data_read(_element.system_data) - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.value.Element.properties - properties.compliance_results = AAZListType( - serialized_name="complianceResults", - flags={"read_only": True}, - ) - properties.created_at = AAZStrType( - serialized_name="createdAt", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.report_properties = AAZObjectType( - serialized_name="reportProperties", - flags={"read_only": True}, - ) - properties.report_system_data = AAZObjectType( - serialized_name="reportSystemData", - flags={"read_only": True}, - ) - _ListHelper._build_schema_system_data_read(properties.report_system_data) - properties.snapshot_name = AAZStrType( - serialized_name="snapshotName", - flags={"read_only": True}, - ) - - compliance_results = cls._schema_on_200.value.Element.properties.compliance_results - compliance_results.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element - _element.categories = AAZListType( - flags={"read_only": True}, - ) - _element.compliance_name = AAZStrType( - serialized_name="complianceName", - flags={"read_only": True}, - ) - - categories = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories - categories.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element - _element.category_name = AAZStrType( - serialized_name="categoryName", - flags={"read_only": True}, - ) - _element.category_status = AAZStrType( - serialized_name="categoryStatus", - flags={"read_only": True}, - ) - _element.control_families = AAZListType( - serialized_name="controlFamilies", - flags={"read_only": True}, - ) - - control_families = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families - control_families.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element - _element.control_family_name = AAZStrType( - serialized_name="controlFamilyName", - flags={"read_only": True}, - ) - _element.control_family_status = AAZStrType( - serialized_name="controlFamilyStatus", - flags={"read_only": True}, - ) - _element.controls = AAZListType( - flags={"read_only": True}, - ) - - controls = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element - _element.control_description = AAZStrType( - serialized_name="controlDescription", - flags={"read_only": True}, - ) - _element.control_description_hyper_link = AAZStrType( - serialized_name="controlDescriptionHyperLink", - flags={"read_only": True}, - ) - _element.control_full_name = AAZStrType( - serialized_name="controlFullName", - flags={"read_only": True}, - ) - _element.control_id = AAZStrType( - serialized_name="controlId", - flags={"read_only": True}, - ) - _element.control_name = AAZStrType( - serialized_name="controlName", - flags={"read_only": True}, - ) - _element.control_status = AAZStrType( - serialized_name="controlStatus", - flags={"read_only": True}, - ) - _element.responsibilities = AAZListType( - flags={"read_only": True}, - ) - - responsibilities = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities - responsibilities.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element - _element.evidence_files = AAZListType( - serialized_name="evidenceFiles", - ) - _element.failed_resource_count = AAZIntType( - serialized_name="failedResourceCount", - ) - _element.guidance = AAZStrType( - flags={"read_only": True}, - ) - _element.justification = AAZStrType( - flags={"read_only": True}, - ) - _element.recommendation_list = AAZListType( - serialized_name="recommendationList", - flags={"read_only": True}, - ) - _element.resource_list = AAZListType( - serialized_name="resourceList", - flags={"read_only": True}, - ) - _element.responsibility_description = AAZStrType( - serialized_name="responsibilityDescription", - flags={"read_only": True}, - ) - _element.responsibility_environment = AAZStrType( - serialized_name="responsibilityEnvironment", - flags={"read_only": True}, - ) - _element.responsibility_id = AAZStrType( - serialized_name="responsibilityId", - flags={"read_only": True}, - ) - _element.responsibility_severity = AAZStrType( - serialized_name="responsibilitySeverity", - flags={"read_only": True}, - ) - _element.responsibility_status = AAZStrType( - serialized_name="responsibilityStatus", - flags={"read_only": True}, - ) - _element.responsibility_title = AAZStrType( - serialized_name="responsibilityTitle", - flags={"read_only": True}, - ) - _element.responsibility_type = AAZStrType( - serialized_name="responsibilityType", - flags={"read_only": True}, - ) - _element.total_resource_count = AAZIntType( - serialized_name="totalResourceCount", - ) - - evidence_files = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.evidence_files - evidence_files.Element = AAZStrType() - - recommendation_list = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list - recommendation_list.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element - _element.recommendation_id = AAZStrType( - serialized_name="recommendationId", - flags={"read_only": True}, - ) - _element.recommendation_short_name = AAZStrType( - serialized_name="recommendationShortName", - flags={"read_only": True}, - ) - _element.recommendation_solutions = AAZListType( - serialized_name="recommendationSolutions", - flags={"read_only": True}, - ) - - recommendation_solutions = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions - recommendation_solutions.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions.Element - _element.is_recommend_solution = AAZStrType( - serialized_name="isRecommendSolution", - flags={"read_only": True}, - ) - _element.recommendation_solution_content = AAZStrType( - serialized_name="recommendationSolutionContent", - flags={"read_only": True}, - ) - _element.recommendation_solution_index = AAZStrType( - serialized_name="recommendationSolutionIndex", - flags={"read_only": True}, - ) - - resource_list = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list - resource_list.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element - _element.account_id = AAZStrType( - serialized_name="accountId", - flags={"read_only": True}, - ) - _element.recommendation_ids = AAZListType( - serialized_name="recommendationIds", - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"read_only": True}, - ) - _element.resource_origin = AAZStrType( - serialized_name="resourceOrigin", - flags={"read_only": True}, - ) - _element.resource_status = AAZStrType( - serialized_name="resourceStatus", - flags={"read_only": True}, - ) - _element.resource_status_change_date = AAZStrType( - serialized_name="resourceStatusChangeDate", - flags={"read_only": True}, - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - flags={"read_only": True}, - ) - - recommendation_ids = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element.recommendation_ids - recommendation_ids.Element = AAZStrType() - - report_properties = cls._schema_on_200.value.Element.properties.report_properties - report_properties.cert_records = AAZListType( - serialized_name="certRecords", - flags={"read_only": True}, - ) - report_properties.compliance_status = AAZObjectType( - serialized_name="complianceStatus", - flags={"read_only": True}, - ) - report_properties.errors = AAZListType( - flags={"read_only": True}, - ) - report_properties.last_trigger_time = AAZStrType( - serialized_name="lastTriggerTime", - flags={"read_only": True}, - ) - report_properties.next_trigger_time = AAZStrType( - serialized_name="nextTriggerTime", - flags={"read_only": True}, - ) - report_properties.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - report_properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - report_properties.resources = AAZListType( - flags={"required": True}, - ) - report_properties.status = AAZStrType( - flags={"read_only": True}, - ) - report_properties.storage_info = AAZObjectType( - serialized_name="storageInfo", - ) - report_properties.subscriptions = AAZListType( - flags={"read_only": True}, - ) - report_properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - report_properties.time_zone = AAZStrType( - serialized_name="timeZone", - flags={"required": True}, - ) - report_properties.trigger_time = AAZStrType( - serialized_name="triggerTime", - flags={"required": True}, - ) - - cert_records = cls._schema_on_200.value.Element.properties.report_properties.cert_records - cert_records.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.report_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.report_properties.cert_records.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.report_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.report_properties.compliance_status - compliance_status.m365 = AAZObjectType( - flags={"read_only": True}, - ) - - m365 = cls._schema_on_200.value.Element.properties.report_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.report_properties.errors - errors.Element = AAZStrType() - - resources = cls._schema_on_200.value.Element.properties.report_properties.resources - resources.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.report_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.report_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.report_properties.subscriptions - subscriptions.Element = AAZStrType() - - return cls._schema_on_200 - - -class _ListHelper: - """Helper class for List""" - - _schema_system_data_read = None - - @classmethod - def _build_schema_system_data_read(cls, _schema): - if cls._schema_system_data_read is not None: - _schema.created_at = cls._schema_system_data_read.created_at - _schema.created_by = cls._schema_system_data_read.created_by - _schema.created_by_type = cls._schema_system_data_read.created_by_type - _schema.last_modified_at = cls._schema_system_data_read.last_modified_at - _schema.last_modified_by = cls._schema_system_data_read.last_modified_by - _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type - return - - cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( - flags={"read_only": True} - ) - - system_data_read = _schema_system_data_read - system_data_read.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data_read.created_by = AAZStrType( - serialized_name="createdBy", - ) - system_data_read.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data_read.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data_read.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - ) - system_data_read.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - _schema.created_at = cls._schema_system_data_read.created_at - _schema.created_by = cls._schema_system_data_read.created_by - _schema.created_by_type = cls._schema_system_data_read.created_by_type - _schema.last_modified_at = cls._schema_system_data_read.last_modified_at - _schema.last_modified_by = cls._schema_system_data_read.last_modified_by - _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type - - -__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 * +from azure.cli.core._profile import Profile + + +class List(AAZCommand): + """List the AppComplianceAutomation snapshot list. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/snapshots", "2024-06-27"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + # 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.report_name = AAZStrArg( + options=["--report-name"], + help="Report Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + _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","--tenant"], + 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): + profile = Profile(cli_ctx=self.cli_ctx) + creds,_,_=profile.get_raw_token(); + self.pre_operations() + self.SnapshotList(ctx=self.ctx)(creds[1]) + 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[0] if len(result)>0 else None #, next_link + + class SnapshotList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + self.token="Bearer "+args[0] + 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}/snapshots", + **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( + "$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", 0, + ), + **self.serialize_query_param( + "$top", 1, + ), + **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", + ), + **self.serialize_header_param( + "x-ms-aad-user-token", self.token, + ), + } + 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( ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.compliance_results = AAZListType( + serialized_name="complianceResults", + flags={"read_only": True}, + ) + properties.created_at = AAZStrType( + serialized_name="createdAt", + flags={"read_only": True}, + ) + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.report_properties = AAZObjectType( + serialized_name="reportProperties", + flags={"read_only": True}, + ) + properties.report_system_data = AAZObjectType( + serialized_name="reportSystemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(properties.report_system_data) + properties.snapshot_name = AAZStrType( + serialized_name="snapshotName", + flags={"read_only": True}, + ) + + compliance_results = cls._schema_on_200.value.Element.properties.compliance_results + compliance_results.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element + _element.categories = AAZListType( + flags={"read_only": True}, + ) + _element.compliance_name = AAZStrType( + serialized_name="complianceName", + flags={"read_only": True}, + ) + + categories = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories + categories.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element + _element.category_name = AAZStrType( + serialized_name="categoryName", + flags={"read_only": True}, + ) + _element.category_status = AAZStrType( + serialized_name="categoryStatus", + flags={"read_only": True}, + ) + _element.control_families = AAZListType( + serialized_name="controlFamilies", + flags={"read_only": True}, + ) + + control_families = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families + control_families.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element + _element.control_family_name = AAZStrType( + serialized_name="controlFamilyName", + flags={"read_only": True}, + ) + _element.control_family_status = AAZStrType( + serialized_name="controlFamilyStatus", + flags={"read_only": True}, + ) + _element.controls = AAZListType( + flags={"read_only": True}, + ) + + controls = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element + _element.control_description = AAZStrType( + serialized_name="controlDescription", + flags={"read_only": True}, + ) + _element.control_description_hyper_link = AAZStrType( + serialized_name="controlDescriptionHyperLink", + flags={"read_only": True}, + ) + _element.control_full_name = AAZStrType( + serialized_name="controlFullName", + flags={"read_only": True}, + ) + _element.control_id = AAZStrType( + serialized_name="controlId", + flags={"read_only": True}, + ) + _element.control_name = AAZStrType( + serialized_name="controlName", + flags={"read_only": True}, + ) + _element.control_status = AAZStrType( + serialized_name="controlStatus", + flags={"read_only": True}, + ) + _element.responsibilities = AAZListType( + flags={"read_only": True}, + ) + + responsibilities = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities + responsibilities.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element + _element.evidence_files = AAZListType( + serialized_name="evidenceFiles", + ) + _element.failed_resource_count = AAZIntType( + serialized_name="failedResourceCount", + ) + _element.guidance = AAZStrType( + flags={"read_only": True}, + ) + _element.justification = AAZStrType( + flags={"read_only": True}, + ) + _element.recommendation_list = AAZListType( + serialized_name="recommendationList", + flags={"read_only": True}, + ) + _element.resource_list = AAZListType( + serialized_name="resourceList", + flags={"read_only": True}, + ) + _element.responsibility_description = AAZStrType( + serialized_name="responsibilityDescription", + flags={"read_only": True}, + ) + _element.responsibility_environment = AAZStrType( + serialized_name="responsibilityEnvironment", + flags={"read_only": True}, + ) + _element.responsibility_id = AAZStrType( + serialized_name="responsibilityId", + flags={"read_only": True}, + ) + _element.responsibility_severity = AAZStrType( + serialized_name="responsibilitySeverity", + flags={"read_only": True}, + ) + _element.responsibility_status = AAZStrType( + serialized_name="responsibilityStatus", + flags={"read_only": True}, + ) + _element.responsibility_title = AAZStrType( + serialized_name="responsibilityTitle", + flags={"read_only": True}, + ) + _element.responsibility_type = AAZStrType( + serialized_name="responsibilityType", + flags={"read_only": True}, + ) + _element.total_resource_count = AAZIntType( + serialized_name="totalResourceCount", + ) + + evidence_files = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.evidence_files + evidence_files.Element = AAZStrType() + + recommendation_list = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list + recommendation_list.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element + _element.recommendation_id = AAZStrType( + serialized_name="recommendationId", + flags={"read_only": True}, + ) + _element.recommendation_short_name = AAZStrType( + serialized_name="recommendationShortName", + flags={"read_only": True}, + ) + _element.recommendation_solutions = AAZListType( + serialized_name="recommendationSolutions", + flags={"read_only": True}, + ) + + recommendation_solutions = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions + recommendation_solutions.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions.Element + _element.is_recommend_solution = AAZStrType( + serialized_name="isRecommendSolution", + flags={"read_only": True}, + ) + _element.recommendation_solution_content = AAZStrType( + serialized_name="recommendationSolutionContent", + flags={"read_only": True}, + ) + _element.recommendation_solution_index = AAZStrType( + serialized_name="recommendationSolutionIndex", + flags={"read_only": True}, + ) + + resource_list = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list + resource_list.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.recommendation_ids = AAZListType( + serialized_name="recommendationIds", + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"read_only": True}, + ) + _element.resource_origin = AAZStrType( + serialized_name="resourceOrigin", + flags={"read_only": True}, + ) + _element.resource_status = AAZStrType( + serialized_name="resourceStatus", + flags={"read_only": True}, + ) + _element.resource_status_change_date = AAZStrType( + serialized_name="resourceStatusChangeDate", + flags={"read_only": True}, + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + flags={"read_only": True}, + ) + + recommendation_ids = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element.recommendation_ids + recommendation_ids.Element = AAZStrType() + + report_properties = cls._schema_on_200.value.Element.properties.report_properties + report_properties.cert_records = AAZListType( + serialized_name="certRecords", + flags={"read_only": True}, + ) + report_properties.compliance_status = AAZObjectType( + serialized_name="complianceStatus", + flags={"read_only": True}, + ) + report_properties.errors = AAZListType( + flags={"read_only": True}, + ) + report_properties.last_trigger_time = AAZStrType( + serialized_name="lastTriggerTime", + flags={"read_only": True}, + ) + report_properties.next_trigger_time = AAZStrType( + serialized_name="nextTriggerTime", + flags={"read_only": True}, + ) + report_properties.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + report_properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + report_properties.report_name = AAZStrType( + serialized_name="reportName", + flags={"read_only": True}, + ) + report_properties.resources = AAZListType( + flags={"required": True}, + ) + report_properties.status = AAZStrType( + flags={"read_only": True}, + ) + report_properties.storage_info = AAZObjectType( + serialized_name="storageInfo", + ) + report_properties.subscriptions = AAZListType( + flags={"read_only": True}, + ) + report_properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + report_properties.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + report_properties.trigger_time = AAZStrType( + serialized_name="triggerTime", + flags={"required": True}, + ) + + cert_records = cls._schema_on_200.value.Element.properties.report_properties.cert_records + cert_records.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.report_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.report_properties.cert_records.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.report_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.report_properties.compliance_status + compliance_status.m365 = AAZObjectType( + flags={"read_only": True}, + ) + + m365 = cls._schema_on_200.value.Element.properties.report_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.report_properties.errors + errors.Element = AAZStrType() + + resources = cls._schema_on_200.value.Element.properties.report_properties.resources + resources.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.report_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.report_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.report_properties.subscriptions + subscriptions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["List"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_show.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_show.py index 3bf1944c65e..ed1696ce6d4 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_show.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/snapshot/_show.py @@ -1,601 +1,649 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the 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 snapshot show", -) -class Show(AAZCommand): - """Get the AppComplianceAutomation snapshot and its properties. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/snapshots/{}", "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}$", - ), - ) - _args_schema.snapshot_name = AAZStrArg( - options=["--snapshot-name"], - help="Snapshot Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9-_]{1,64}$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.SnapshotGet(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 SnapshotGet(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}/snapshots/{snapshotName}", - **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, - ), - **self.serialize_url_param( - "snapshotName", self.ctx.args.snapshot_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={"client_flatten": True}, - ) - _schema_on_200.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _ShowHelper._build_schema_system_data_read(_schema_on_200.system_data) - _schema_on_200.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.properties - properties.compliance_results = AAZListType( - serialized_name="complianceResults", - flags={"read_only": True}, - ) - properties.created_at = AAZStrType( - serialized_name="createdAt", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.report_properties = AAZObjectType( - serialized_name="reportProperties", - flags={"read_only": True}, - ) - properties.report_system_data = AAZObjectType( - serialized_name="reportSystemData", - flags={"read_only": True}, - ) - _ShowHelper._build_schema_system_data_read(properties.report_system_data) - properties.snapshot_name = AAZStrType( - serialized_name="snapshotName", - flags={"read_only": True}, - ) - - compliance_results = cls._schema_on_200.properties.compliance_results - compliance_results.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element - _element.categories = AAZListType( - flags={"read_only": True}, - ) - _element.compliance_name = AAZStrType( - serialized_name="complianceName", - flags={"read_only": True}, - ) - - categories = cls._schema_on_200.properties.compliance_results.Element.categories - categories.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element.categories.Element - _element.category_name = AAZStrType( - serialized_name="categoryName", - flags={"read_only": True}, - ) - _element.category_status = AAZStrType( - serialized_name="categoryStatus", - flags={"read_only": True}, - ) - _element.control_families = AAZListType( - serialized_name="controlFamilies", - flags={"read_only": True}, - ) - - control_families = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families - control_families.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element - _element.control_family_name = AAZStrType( - serialized_name="controlFamilyName", - flags={"read_only": True}, - ) - _element.control_family_status = AAZStrType( - serialized_name="controlFamilyStatus", - flags={"read_only": True}, - ) - _element.controls = AAZListType( - flags={"read_only": True}, - ) - - controls = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element - _element.control_description = AAZStrType( - serialized_name="controlDescription", - flags={"read_only": True}, - ) - _element.control_description_hyper_link = AAZStrType( - serialized_name="controlDescriptionHyperLink", - flags={"read_only": True}, - ) - _element.control_full_name = AAZStrType( - serialized_name="controlFullName", - flags={"read_only": True}, - ) - _element.control_id = AAZStrType( - serialized_name="controlId", - flags={"read_only": True}, - ) - _element.control_name = AAZStrType( - serialized_name="controlName", - flags={"read_only": True}, - ) - _element.control_status = AAZStrType( - serialized_name="controlStatus", - flags={"read_only": True}, - ) - _element.responsibilities = AAZListType( - flags={"read_only": True}, - ) - - responsibilities = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities - responsibilities.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element - _element.evidence_files = AAZListType( - serialized_name="evidenceFiles", - ) - _element.failed_resource_count = AAZIntType( - serialized_name="failedResourceCount", - ) - _element.guidance = AAZStrType( - flags={"read_only": True}, - ) - _element.justification = AAZStrType( - flags={"read_only": True}, - ) - _element.recommendation_list = AAZListType( - serialized_name="recommendationList", - flags={"read_only": True}, - ) - _element.resource_list = AAZListType( - serialized_name="resourceList", - flags={"read_only": True}, - ) - _element.responsibility_description = AAZStrType( - serialized_name="responsibilityDescription", - flags={"read_only": True}, - ) - _element.responsibility_environment = AAZStrType( - serialized_name="responsibilityEnvironment", - flags={"read_only": True}, - ) - _element.responsibility_id = AAZStrType( - serialized_name="responsibilityId", - flags={"read_only": True}, - ) - _element.responsibility_severity = AAZStrType( - serialized_name="responsibilitySeverity", - flags={"read_only": True}, - ) - _element.responsibility_status = AAZStrType( - serialized_name="responsibilityStatus", - flags={"read_only": True}, - ) - _element.responsibility_title = AAZStrType( - serialized_name="responsibilityTitle", - flags={"read_only": True}, - ) - _element.responsibility_type = AAZStrType( - serialized_name="responsibilityType", - flags={"read_only": True}, - ) - _element.total_resource_count = AAZIntType( - serialized_name="totalResourceCount", - ) - - evidence_files = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.evidence_files - evidence_files.Element = AAZStrType() - - recommendation_list = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list - recommendation_list.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element - _element.recommendation_id = AAZStrType( - serialized_name="recommendationId", - flags={"read_only": True}, - ) - _element.recommendation_short_name = AAZStrType( - serialized_name="recommendationShortName", - flags={"read_only": True}, - ) - _element.recommendation_solutions = AAZListType( - serialized_name="recommendationSolutions", - flags={"read_only": True}, - ) - - recommendation_solutions = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions - recommendation_solutions.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions.Element - _element.is_recommend_solution = AAZStrType( - serialized_name="isRecommendSolution", - flags={"read_only": True}, - ) - _element.recommendation_solution_content = AAZStrType( - serialized_name="recommendationSolutionContent", - flags={"read_only": True}, - ) - _element.recommendation_solution_index = AAZStrType( - serialized_name="recommendationSolutionIndex", - flags={"read_only": True}, - ) - - resource_list = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list - resource_list.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element - _element.account_id = AAZStrType( - serialized_name="accountId", - flags={"read_only": True}, - ) - _element.recommendation_ids = AAZListType( - serialized_name="recommendationIds", - ) - _element.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"read_only": True}, - ) - _element.resource_origin = AAZStrType( - serialized_name="resourceOrigin", - flags={"read_only": True}, - ) - _element.resource_status = AAZStrType( - serialized_name="resourceStatus", - flags={"read_only": True}, - ) - _element.resource_status_change_date = AAZStrType( - serialized_name="resourceStatusChangeDate", - flags={"read_only": True}, - ) - _element.resource_type = AAZStrType( - serialized_name="resourceType", - flags={"read_only": True}, - ) - - recommendation_ids = cls._schema_on_200.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element.recommendation_ids - recommendation_ids.Element = AAZStrType() - - report_properties = cls._schema_on_200.properties.report_properties - report_properties.cert_records = AAZListType( - serialized_name="certRecords", - flags={"read_only": True}, - ) - report_properties.compliance_status = AAZObjectType( - serialized_name="complianceStatus", - flags={"read_only": True}, - ) - report_properties.errors = AAZListType( - flags={"read_only": True}, - ) - report_properties.last_trigger_time = AAZStrType( - serialized_name="lastTriggerTime", - flags={"read_only": True}, - ) - report_properties.next_trigger_time = AAZStrType( - serialized_name="nextTriggerTime", - flags={"read_only": True}, - ) - report_properties.offer_guid = AAZStrType( - serialized_name="offerGuid", - ) - report_properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - report_properties.resources = AAZListType( - flags={"required": True}, - ) - report_properties.status = AAZStrType( - flags={"read_only": True}, - ) - report_properties.storage_info = AAZObjectType( - serialized_name="storageInfo", - ) - report_properties.subscriptions = AAZListType( - flags={"read_only": True}, - ) - report_properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - report_properties.time_zone = AAZStrType( - serialized_name="timeZone", - flags={"required": True}, - ) - report_properties.trigger_time = AAZStrType( - serialized_name="triggerTime", - flags={"required": True}, - ) - - cert_records = cls._schema_on_200.properties.report_properties.cert_records - cert_records.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.report_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.report_properties.cert_records.Element.controls - controls.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.report_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.report_properties.compliance_status - compliance_status.m365 = AAZObjectType( - flags={"read_only": True}, - ) - - m365 = cls._schema_on_200.properties.report_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.report_properties.errors - errors.Element = AAZStrType() - - resources = cls._schema_on_200.properties.report_properties.resources - resources.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.report_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.report_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.report_properties.subscriptions - subscriptions.Element = AAZStrType() - - return cls._schema_on_200 - - -class _ShowHelper: - """Helper class for Show""" - - _schema_system_data_read = None - - @classmethod - def _build_schema_system_data_read(cls, _schema): - if cls._schema_system_data_read is not None: - _schema.created_at = cls._schema_system_data_read.created_at - _schema.created_by = cls._schema_system_data_read.created_by - _schema.created_by_type = cls._schema_system_data_read.created_by_type - _schema.last_modified_at = cls._schema_system_data_read.last_modified_at - _schema.last_modified_by = cls._schema_system_data_read.last_modified_by - _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type - return - - cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( - flags={"read_only": True} - ) - - system_data_read = _schema_system_data_read - system_data_read.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data_read.created_by = AAZStrType( - serialized_name="createdBy", - ) - system_data_read.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data_read.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data_read.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - ) - system_data_read.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - _schema.created_at = cls._schema_system_data_read.created_at - _schema.created_by = cls._schema_system_data_read.created_by - _schema.created_by_type = cls._schema_system_data_read.created_by_type - _schema.last_modified_at = cls._schema_system_data_read.last_modified_at - _schema.last_modified_by = cls._schema_system_data_read.last_modified_by - _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type - - -__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 * +from azure.cli.core._profile import Profile + + +@register_command( + "acat report get-control-assessments", +) +class ShowSnapshot(AAZCommand): + """Get the AppComplianceAutomation snapshot and its properties. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/snapshots", "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}$", + ), + ) + _args_schema.compliance_status = AAZStrArg( + options=["--compliance-status"], + help="Compliance status.", + enum={"failed": "Failed", "succeeded": "Passed", + "na": "Not Applicable"}, + default="all", + ) + _args_schema.report_creator_tenant_id = AAZStrArg( + options=["--report-creator-tenant-id","--tenant"], + help="The tenant id of the report creator.", + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + profile = Profile(cli_ctx=self.cli_ctx) + creds,_,_=profile.get_raw_token(); + self.pre_operations() + self.SnapshotGet(ctx=self.ctx)(creds[1]) + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + snapshots = self.deserialize_output( + self.ctx.vars.instance.value, client_flatten=True) + if len(snapshots) == 0: + return "No snapshot found" + latestSnapshot=snapshots[0]["properties"]["complianceResults"][0]["categories"] + if self.ctx.args.compliance_status == "all": + return latestSnapshot + return [{ + "categoryName": category["categoryName"], + "categoryStatus":category["categoryStatus"], + "controlFamilies":[{ + "controlFamilyName": controlFamily["controlFamilyName"], + "controlFamilyStatus":controlFamily["controlFamilyStatus"], + "controls":[control for control in controlFamily["controls"] if control["controlStatus"] == self.ctx.args.compliance_status]} + for controlFamily in category["controlFamilies"]]} + for category in latestSnapshot] + + class SnapshotGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + self.token="Bearer "+args[0] + 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}/snapshots", + **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( + "$skipToken", 0, + ), + **self.serialize_query_param( + "$top", 1, + ), + **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", + ), + **self.serialize_header_param( + "x-ms-aad-user-token", self.token, + ), + } + 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( ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ShowHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.compliance_results = AAZListType( + serialized_name="complianceResults", + flags={"read_only": True}, + ) + properties.created_at = AAZStrType( + serialized_name="createdAt", + flags={"read_only": True}, + ) + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.report_properties = AAZObjectType( + serialized_name="reportProperties", + flags={"read_only": True}, + ) + properties.report_system_data = AAZObjectType( + serialized_name="reportSystemData", + flags={"read_only": True}, + ) + _ShowHelper._build_schema_system_data_read(properties.report_system_data) + properties.snapshot_name = AAZStrType( + serialized_name="snapshotName", + flags={"read_only": True}, + ) + + compliance_results = cls._schema_on_200.value.Element.properties.compliance_results + compliance_results.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element + _element.categories = AAZListType( + flags={"read_only": True}, + ) + _element.compliance_name = AAZStrType( + serialized_name="complianceName", + flags={"read_only": True}, + ) + + categories = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories + categories.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element + _element.category_name = AAZStrType( + serialized_name="categoryName", + flags={"read_only": True}, + ) + _element.category_status = AAZStrType( + serialized_name="categoryStatus", + flags={"read_only": True}, + ) + _element.control_families = AAZListType( + serialized_name="controlFamilies", + flags={"read_only": True}, + ) + + control_families = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families + control_families.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element + _element.control_family_name = AAZStrType( + serialized_name="controlFamilyName", + flags={"read_only": True}, + ) + _element.control_family_status = AAZStrType( + serialized_name="controlFamilyStatus", + flags={"read_only": True}, + ) + _element.controls = AAZListType( + flags={"read_only": True}, + ) + + controls = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element + _element.control_description = AAZStrType( + serialized_name="controlDescription", + flags={"read_only": True}, + ) + _element.control_description_hyper_link = AAZStrType( + serialized_name="controlDescriptionHyperLink", + flags={"read_only": True}, + ) + _element.control_full_name = AAZStrType( + serialized_name="controlFullName", + flags={"read_only": True}, + ) + _element.control_id = AAZStrType( + serialized_name="controlId", + flags={"read_only": True}, + ) + _element.control_name = AAZStrType( + serialized_name="controlName", + flags={"read_only": True}, + ) + _element.control_status = AAZStrType( + serialized_name="controlStatus", + flags={"read_only": True}, + ) + _element.responsibilities = AAZListType( + flags={"read_only": True}, + ) + + responsibilities = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities + responsibilities.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element + _element.evidence_files = AAZListType( + serialized_name="evidenceFiles", + ) + _element.failed_resource_count = AAZIntType( + serialized_name="failedResourceCount", + ) + _element.guidance = AAZStrType( + flags={"read_only": True}, + ) + _element.justification = AAZStrType( + flags={"read_only": True}, + ) + _element.recommendation_list = AAZListType( + serialized_name="recommendationList", + flags={"read_only": True}, + ) + _element.resource_list = AAZListType( + serialized_name="resourceList", + flags={"read_only": True}, + ) + _element.responsibility_description = AAZStrType( + serialized_name="responsibilityDescription", + flags={"read_only": True}, + ) + _element.responsibility_environment = AAZStrType( + serialized_name="responsibilityEnvironment", + flags={"read_only": True}, + ) + _element.responsibility_id = AAZStrType( + serialized_name="responsibilityId", + flags={"read_only": True}, + ) + _element.responsibility_severity = AAZStrType( + serialized_name="responsibilitySeverity", + flags={"read_only": True}, + ) + _element.responsibility_status = AAZStrType( + serialized_name="responsibilityStatus", + flags={"read_only": True}, + ) + _element.responsibility_title = AAZStrType( + serialized_name="responsibilityTitle", + flags={"read_only": True}, + ) + _element.responsibility_type = AAZStrType( + serialized_name="responsibilityType", + flags={"read_only": True}, + ) + _element.total_resource_count = AAZIntType( + serialized_name="totalResourceCount", + ) + + evidence_files = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.evidence_files + evidence_files.Element = AAZStrType() + + recommendation_list = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list + recommendation_list.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element + _element.recommendation_id = AAZStrType( + serialized_name="recommendationId", + flags={"read_only": True}, + ) + _element.recommendation_short_name = AAZStrType( + serialized_name="recommendationShortName", + flags={"read_only": True}, + ) + _element.recommendation_solutions = AAZListType( + serialized_name="recommendationSolutions", + flags={"read_only": True}, + ) + + recommendation_solutions = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions + recommendation_solutions.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.recommendation_list.Element.recommendation_solutions.Element + _element.is_recommend_solution = AAZStrType( + serialized_name="isRecommendSolution", + flags={"read_only": True}, + ) + _element.recommendation_solution_content = AAZStrType( + serialized_name="recommendationSolutionContent", + flags={"read_only": True}, + ) + _element.recommendation_solution_index = AAZStrType( + serialized_name="recommendationSolutionIndex", + flags={"read_only": True}, + ) + + resource_list = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list + resource_list.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.recommendation_ids = AAZListType( + serialized_name="recommendationIds", + ) + _element.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"read_only": True}, + ) + _element.resource_origin = AAZStrType( + serialized_name="resourceOrigin", + flags={"read_only": True}, + ) + _element.resource_status = AAZStrType( + serialized_name="resourceStatus", + flags={"read_only": True}, + ) + _element.resource_status_change_date = AAZStrType( + serialized_name="resourceStatusChangeDate", + flags={"read_only": True}, + ) + _element.resource_type = AAZStrType( + serialized_name="resourceType", + flags={"read_only": True}, + ) + + recommendation_ids = cls._schema_on_200.value.Element.properties.compliance_results.Element.categories.Element.control_families.Element.controls.Element.responsibilities.Element.resource_list.Element.recommendation_ids + recommendation_ids.Element = AAZStrType() + + report_properties = cls._schema_on_200.value.Element.properties.report_properties + report_properties.cert_records = AAZListType( + serialized_name="certRecords", + flags={"read_only": True}, + ) + report_properties.compliance_status = AAZObjectType( + serialized_name="complianceStatus", + flags={"read_only": True}, + ) + report_properties.errors = AAZListType( + flags={"read_only": True}, + ) + report_properties.last_trigger_time = AAZStrType( + serialized_name="lastTriggerTime", + flags={"read_only": True}, + ) + report_properties.next_trigger_time = AAZStrType( + serialized_name="nextTriggerTime", + flags={"read_only": True}, + ) + report_properties.offer_guid = AAZStrType( + serialized_name="offerGuid", + ) + report_properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + report_properties.report_name = AAZStrType( + serialized_name="reportName", + flags={"read_only": True}, + ) + report_properties.resources = AAZListType( + flags={"required": True}, + ) + report_properties.status = AAZStrType( + flags={"read_only": True}, + ) + report_properties.storage_info = AAZObjectType( + serialized_name="storageInfo", + ) + report_properties.subscriptions = AAZListType( + flags={"read_only": True}, + ) + report_properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + report_properties.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + report_properties.trigger_time = AAZStrType( + serialized_name="triggerTime", + flags={"required": True}, + ) + + cert_records = cls._schema_on_200.value.Element.properties.report_properties.cert_records + cert_records.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.report_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.report_properties.cert_records.Element.controls + controls.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.report_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.report_properties.compliance_status + compliance_status.m365 = AAZObjectType( + flags={"read_only": True}, + ) + + m365 = cls._schema_on_200.value.Element.properties.report_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.report_properties.errors + errors.Element = AAZStrType() + + resources = cls._schema_on_200.value.Element.properties.report_properties.resources + resources.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.report_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.report_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.report_properties.subscriptions + subscriptions.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["ShowSnapshot"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_create.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_create.py index bf7414cdf38..3f3adaaf510 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_create.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_create.py @@ -1,334 +1,354 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report webhook create", -) -class Create(AAZCommand): - """Create a new AppComplianceAutomation webhook or update an exiting AppComplianceAutomation webhook. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "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}$", - ), - ) - _args_schema.webhook_name = AAZStrArg( - options=["--webhook-name"], - help="Webhook Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.content_type = AAZStrArg( - options=["--content-type"], - arg_group="Properties", - help="content type", - enum={"application/json": "application/json"}, - ) - _args_schema.enable_ssl_verification = AAZStrArg( - options=["--enable-ssl-verification"], - arg_group="Properties", - help="whether to enable ssl verification", - enum={"false": "false", "true": "true"}, - ) - _args_schema.events = AAZListArg( - options=["--events"], - arg_group="Properties", - help="under which event notification should be sent.", - ) - _args_schema.payload_url = AAZStrArg( - options=["--payload-url"], - arg_group="Properties", - help="webhook payload url", - fmt=AAZStrArgFormat( - pattern="^(http(s)?://)[\S]{0,64994}$", - ), - ) - _args_schema.send_all_events = AAZStrArg( - options=["--send-all-events"], - arg_group="Properties", - help="whether to send notification under any event.", - enum={"false": "false", "true": "true"}, - ) - _args_schema.status = AAZStrArg( - options=["--status"], - arg_group="Properties", - help="Webhook status.", - enum={"Disabled": "Disabled", "Enabled": "Enabled"}, - ) - _args_schema.update_webhook_key = AAZStrArg( - options=["--update-webhook-key"], - arg_group="Properties", - help="whether to update webhookKey.", - enum={"false": "false", "true": "true"}, - ) - _args_schema.webhook_key = AAZStrArg( - options=["--webhook-key"], - arg_group="Properties", - help="webhook secret token. If not set, this field value is null; otherwise, please set a string value.", - fmt=AAZStrArgFormat( - pattern="^.{0,2048}$", - ), - ) - - events = cls._args_schema.events - events.Element = AAZStrArg( - enum={"assessment_failure": "assessment_failure", "generate_snapshot_failed": "generate_snapshot_failed", "generate_snapshot_success": "generate_snapshot_success", "report_configuration_changes": "report_configuration_changes", "report_deletion": "report_deletion"}, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.WebhookCreateOrUpdate(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 WebhookCreateOrUpdate(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200, 201]: - return self.on_200_201(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}", - **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, - ), - **self.serialize_url_param( - "webhookName", self.ctx.args.webhook_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("contentType", AAZStrType, ".content_type") - properties.set_prop("enableSslVerification", AAZStrType, ".enable_ssl_verification") - properties.set_prop("events", AAZListType, ".events") - properties.set_prop("payloadUrl", AAZStrType, ".payload_url") - properties.set_prop("sendAllEvents", AAZStrType, ".send_all_events") - properties.set_prop("status", AAZStrType, ".status") - properties.set_prop("updateWebhookKey", AAZStrType, ".update_webhook_key") - properties.set_prop("webhookKey", AAZStrType, ".webhook_key") - - events = _builder.get(".properties.events") - if events is not None: - events.set_elements(AAZStrType, ".") - - return self.serialize_content(_content_value) - - def on_200_201(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200_201 - ) - - _schema_on_200_201 = None - - @classmethod - def _build_schema_on_200_201(cls): - if cls._schema_on_200_201 is not None: - return cls._schema_on_200_201 - - cls._schema_on_200_201 = AAZObjectType() - - _schema_on_200_201 = cls._schema_on_200_201 - _schema_on_200_201.id = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200_201.name = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200_201.properties = AAZObjectType( - flags={"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.content_type = AAZStrType( - serialized_name="contentType", - ) - properties.delivery_status = AAZStrType( - serialized_name="deliveryStatus", - flags={"read_only": True}, - ) - properties.enable_ssl_verification = AAZStrType( - serialized_name="enableSslVerification", - ) - properties.events = AAZListType() - properties.payload_url = AAZStrType( - serialized_name="payloadUrl", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.send_all_events = AAZStrType( - serialized_name="sendAllEvents", - ) - properties.status = AAZStrType() - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.update_webhook_key = AAZStrType( - serialized_name="updateWebhookKey", - ) - properties.webhook_id = AAZStrType( - serialized_name="webhookId", - flags={"read_only": True}, - ) - properties.webhook_key = AAZStrType( - serialized_name="webhookKey", - ) - properties.webhook_key_enabled = AAZStrType( - serialized_name="webhookKeyEnabled", - flags={"read_only": True}, - ) - - events = cls._schema_on_200_201.properties.events - events.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 webhook create", +) +class Create(AAZCommand): + """Create a new AppComplianceAutomation webhook or update an exiting AppComplianceAutomation webhook. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "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}$", + ), + ) + _args_schema.webhook_name = AAZStrArg( + options=["--webhook-name"], + help="Webhook Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.content_type = AAZStrArg( + options=["--content-type"], + arg_group="Properties", + help="content type", + required=False, + enum={"application/json": "application/json"}, + default="application/json" + ) + _args_schema.enable_ssl_verification = AAZStrArg( + options=["--enable-ssl"], + arg_group="Properties", + help="whether to enable ssl verification", + enum={"false": "false", "true": "true"}, + default="true" + ) + _args_schema.events = AAZListArg( + options=["--events"], + arg_group="Properties", + help="under which event notification should be sent.", + required=False, + default=[] + ) + _args_schema.payload_url = AAZStrArg( + options=["--payload-url"], + arg_group="Properties", + help="webhook payload url", + required=True, + fmt=AAZStrArgFormat( + pattern="^(http(s)?://)[\S]{0,64994}$", + ), + ) + _args_schema.trigger_mode = AAZStrArg( + options=["--trigger-mode"], + arg_group="Properties", + help="whether to send notification under any event.", + default="all", + enum={"all": "true", "customize": "false"}, + ) + + _args_schema.status = AAZStrArg( + options=["--disable"], + arg_group="Properties", + help="Webhook status.", + enum={"false": "enable", "true": "disable"}, + default="enalbe", + blank="disable" + ) + _args_schema.webhook_key = AAZStrArg( + options=["--secret"], + arg_group="Properties", + help="webhook secret token. If not set, this field value is null; otherwise, please set a string value.", + default="", + blank="", + fmt=AAZStrArgFormat( + pattern="^.{0,2048}$", + ), + ) + + events = cls._args_schema.events + events.Element = AAZStrArg( + enum={"assessment_failure": "assessment_failure", "generate_snapshot_failed": "generate_snapshot_failed", "generate_snapshot_success": "generate_snapshot_success", "report_configuration_changes": "report_configuration_changes", "report_deletion": "report_deletion"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WebhookCreateOrUpdate(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 WebhookCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}", + **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, + ), + **self.serialize_url_param( + "webhookName", self.ctx.args.webhook_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("contentType", AAZStrType, ".content_type", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("events", AAZListType, ".events", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("payloadUrl", AAZStrType, ".payload_url", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("sendAllEvents", AAZStrType, ".trigger_mode", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("enableSslVerification", AAZStrType, ".enable_ssl_verification", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("status", AAZStrType, ".status", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("webhookKey", AAZStrType, ".webhook_key") + + wKey=self.ctx.args.webhook_key.__str__() + hasValidWebhookKey=wKey!="Undefined" and wKey.__len__()>0 + properties.set_const("updateWebhookKey","true" if hasValidWebhookKey else "false", AAZStrType) + + events = _builder.get(".properties.events") + if events is not None: + events.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"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.content_type = AAZStrType( + serialized_name="contentType", + flags={"required": True}, + ) + properties.delivery_status = AAZStrType( + serialized_name="deliveryStatus", + flags={"read_only": True}, + ) + properties.enable_webhook_key = AAZStrType( + serialized_name="enableWebhookKey", + ) + properties.events = AAZListType( + flags={"required": True}, + ) + properties.payload_url = AAZStrType( + serialized_name="payloadUrl", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.send_all_events = AAZStrType( + serialized_name="sendAllEvents", + flags={"required": True}, + ) + properties.ssl_verified = AAZStrType( + serialized_name="sslVerified", + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"required": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.webhook_id = AAZStrType( + serialized_name="webhookId", + flags={"read_only": True}, + ) + properties.webhook_key = AAZStrType( + serialized_name="webhookKey", + ) + properties.webhook_key_enabled = AAZStrType( + serialized_name="webhookKeyEnabled", + flags={"read_only": True}, + ) + properties.webhook_name = AAZStrType( + serialized_name="webhookName", + ) + + events = cls._schema_on_200_201.properties.events + events.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/webhook/_delete.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_delete.py index 4d6ffe71007..d7a6cc6d37b 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_delete.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_delete.py @@ -1,139 +1,139 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the 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 webhook delete", - confirmation="Are you sure you want to perform this operation?", -) -class Delete(AAZCommand): - """Delete an AppComplianceAutomation webhook. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "2024-06-27"], - ] - } - - def _handler(self, command_args): - super()._handler(command_args) - self._execute_operations() - return None - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - _args_schema.webhook_name = AAZStrArg( - options=["--webhook-name"], - help="Webhook Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.WebhookDelete(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class WebhookDelete(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200]: - return self.on_200(session) - if session.http_response.status_code in [204]: - return self.on_204(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}", - **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, - ), - **self.serialize_url_param( - "webhookName", self.ctx.args.webhook_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_200(self, session): - pass - - def on_204(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 webhook delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an AppComplianceAutomation webhook. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "2024-06-27"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.report_name = AAZStrArg( + options=["--report-name"], + help="Report Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + _args_schema.webhook_name = AAZStrArg( + options=["--webhook-name"], + help="Webhook Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WebhookDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class WebhookDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}", + **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, + ), + **self.serialize_url_param( + "webhookName", self.ctx.args.webhook_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_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_list.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_list.py index e4d6b243d4c..d0b00c2d3ff 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_list.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_list.py @@ -1,314 +1,325 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report webhook list", -) -class List(AAZCommand): - """List the AppComplianceAutomation webhook list. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks", "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.report_name = AAZStrArg( - options=["--report-name"], - help="Report Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - _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.WebhookList(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 WebhookList(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}/webhooks", - **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( - "$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.content_type = AAZStrType( - serialized_name="contentType", - ) - properties.delivery_status = AAZStrType( - serialized_name="deliveryStatus", - flags={"read_only": True}, - ) - properties.enable_ssl_verification = AAZStrType( - serialized_name="enableSslVerification", - ) - properties.events = AAZListType() - properties.payload_url = AAZStrType( - serialized_name="payloadUrl", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.send_all_events = AAZStrType( - serialized_name="sendAllEvents", - ) - properties.status = AAZStrType() - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.update_webhook_key = AAZStrType( - serialized_name="updateWebhookKey", - ) - properties.webhook_id = AAZStrType( - serialized_name="webhookId", - flags={"read_only": True}, - ) - properties.webhook_key = AAZStrType( - serialized_name="webhookKey", - ) - properties.webhook_key_enabled = AAZStrType( - serialized_name="webhookKeyEnabled", - flags={"read_only": True}, - ) - - events = cls._schema_on_200.value.Element.properties.events - events.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 webhook list", +) +class List(AAZCommand): + """List the AppComplianceAutomation webhook list. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks", "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.report_name = AAZStrArg( + options=["--report-name"], + help="Report Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + _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","--tenant"], + 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.WebhookList(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 WebhookList(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}/webhooks", + **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( + "$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.content_type = AAZStrType( + serialized_name="contentType", + flags={"required": True}, + ) + properties.delivery_status = AAZStrType( + serialized_name="deliveryStatus", + flags={"read_only": True}, + ) + properties.enable_webhook_key = AAZStrType( + serialized_name="enableWebhookKey", + ) + properties.events = AAZListType( + flags={"required": True}, + ) + properties.payload_url = AAZStrType( + serialized_name="payloadUrl", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.send_all_events = AAZStrType( + serialized_name="sendAllEvents", + flags={"required": True}, + ) + properties.ssl_verified = AAZStrType( + serialized_name="sslVerified", + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"required": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.webhook_id = AAZStrType( + serialized_name="webhookId", + flags={"read_only": True}, + ) + properties.webhook_key = AAZStrType( + serialized_name="webhookKey", + ) + properties.webhook_key_enabled = AAZStrType( + serialized_name="webhookKeyEnabled", + flags={"read_only": True}, + ) + properties.webhook_name = AAZStrType( + serialized_name="webhookName", + ) + + events = cls._schema_on_200.value.Element.properties.events + events.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/webhook/_show.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_show.py index f121ce7c4f8..c4b5ab8eb59 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_show.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_show.py @@ -1,245 +1,256 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report webhook show", -) -class Show(AAZCommand): - """Get the AppComplianceAutomation webhook and its properties. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "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}$", - ), - ) - _args_schema.webhook_name = AAZStrArg( - options=["--webhook-name"], - help="Webhook Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.WebhookGet(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 WebhookGet(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}/webhooks/{webhookName}", - **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, - ), - **self.serialize_url_param( - "webhookName", self.ctx.args.webhook_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.content_type = AAZStrType( - serialized_name="contentType", - ) - properties.delivery_status = AAZStrType( - serialized_name="deliveryStatus", - flags={"read_only": True}, - ) - properties.enable_ssl_verification = AAZStrType( - serialized_name="enableSslVerification", - ) - properties.events = AAZListType() - properties.payload_url = AAZStrType( - serialized_name="payloadUrl", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.send_all_events = AAZStrType( - serialized_name="sendAllEvents", - ) - properties.status = AAZStrType() - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.update_webhook_key = AAZStrType( - serialized_name="updateWebhookKey", - ) - properties.webhook_id = AAZStrType( - serialized_name="webhookId", - flags={"read_only": True}, - ) - properties.webhook_key = AAZStrType( - serialized_name="webhookKey", - ) - properties.webhook_key_enabled = AAZStrType( - serialized_name="webhookKeyEnabled", - flags={"read_only": True}, - ) - - events = cls._schema_on_200.properties.events - events.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 webhook show", +) +class Show(AAZCommand): + """Get the AppComplianceAutomation webhook and its properties. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "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}$", + ), + ) + _args_schema.webhook_name = AAZStrArg( + options=["--webhook-name"], + help="Webhook Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WebhookGet(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 WebhookGet(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}/webhooks/{webhookName}", + **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, + ), + **self.serialize_url_param( + "webhookName", self.ctx.args.webhook_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.content_type = AAZStrType( + serialized_name="contentType", + flags={"required": True}, + ) + properties.delivery_status = AAZStrType( + serialized_name="deliveryStatus", + flags={"read_only": True}, + ) + properties.enable_webhook_key = AAZStrType( + serialized_name="enableWebhookKey", + ) + properties.events = AAZListType( + flags={"required": True}, + ) + properties.payload_url = AAZStrType( + serialized_name="payloadUrl", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.send_all_events = AAZStrType( + serialized_name="sendAllEvents", + flags={"required": True}, + ) + properties.ssl_verified = AAZStrType( + serialized_name="sslVerified", + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"required": True}, + ) + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.webhook_id = AAZStrType( + serialized_name="webhookId", + flags={"read_only": True}, + ) + properties.webhook_key = AAZStrType( + serialized_name="webhookKey", + ) + properties.webhook_key_enabled = AAZStrType( + serialized_name="webhookKeyEnabled", + flags={"read_only": True}, + ) + properties.webhook_name = AAZStrType( + serialized_name="webhookName", + ) + + events = cls._schema_on_200.properties.events + events.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/webhook/_update.py b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_update.py index 3dff8107cee..31fc854e1f0 100644 --- a/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_update.py +++ b/src/acat/azext_acat/aaz/latest/app_compliance_automation/report/webhook/_update.py @@ -1,334 +1,334 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "app-compliance-automation report webhook update", -) -class Update(AAZCommand): - """Update an exiting AppComplianceAutomation webhook. - """ - - _aaz_info = { - "version": "2024-06-27", - "resources": [ - ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "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}$", - ), - ) - _args_schema.webhook_name = AAZStrArg( - options=["--webhook-name"], - help="Webhook Name.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[-a-zA-Z0-9_]{1,50}$", - ), - ) - - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.content_type = AAZStrArg( - options=["--content-type"], - arg_group="Properties", - help="content type", - enum={"application/json": "application/json"}, - ) - _args_schema.enable_ssl_verification = AAZStrArg( - options=["--enable-ssl-verification"], - arg_group="Properties", - help="whether to enable ssl verification", - enum={"false": "false", "true": "true"}, - ) - _args_schema.events = AAZListArg( - options=["--events"], - arg_group="Properties", - help="under which event notification should be sent.", - ) - _args_schema.payload_url = AAZStrArg( - options=["--payload-url"], - arg_group="Properties", - help="webhook payload url", - fmt=AAZStrArgFormat( - pattern="^(http(s)?://)[\S]{0,64994}$", - ), - ) - _args_schema.send_all_events = AAZStrArg( - options=["--send-all-events"], - arg_group="Properties", - help="whether to send notification under any event.", - enum={"false": "false", "true": "true"}, - ) - _args_schema.status = AAZStrArg( - options=["--status"], - arg_group="Properties", - help="Webhook status.", - enum={"Disabled": "Disabled", "Enabled": "Enabled"}, - ) - _args_schema.update_webhook_key = AAZStrArg( - options=["--update-webhook-key"], - arg_group="Properties", - help="whether to update webhookKey.", - enum={"false": "false", "true": "true"}, - ) - _args_schema.webhook_key = AAZStrArg( - options=["--webhook-key"], - arg_group="Properties", - help="webhook secret token. If not set, this field value is null; otherwise, please set a string value.", - fmt=AAZStrArgFormat( - pattern="^.{0,2048}$", - ), - ) - - events = cls._args_schema.events - events.Element = AAZStrArg( - enum={"assessment_failure": "assessment_failure", "generate_snapshot_failed": "generate_snapshot_failed", "generate_snapshot_success": "generate_snapshot_success", "report_configuration_changes": "report_configuration_changes", "report_deletion": "report_deletion"}, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.WebhookUpdate(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 WebhookUpdate(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}/webhooks/{webhookName}", - **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, - ), - **self.serialize_url_param( - "webhookName", self.ctx.args.webhook_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("contentType", AAZStrType, ".content_type") - properties.set_prop("enableSslVerification", AAZStrType, ".enable_ssl_verification") - properties.set_prop("events", AAZListType, ".events") - properties.set_prop("payloadUrl", AAZStrType, ".payload_url") - properties.set_prop("sendAllEvents", AAZStrType, ".send_all_events") - properties.set_prop("status", AAZStrType, ".status") - properties.set_prop("updateWebhookKey", AAZStrType, ".update_webhook_key") - properties.set_prop("webhookKey", AAZStrType, ".webhook_key") - - events = _builder.get(".properties.events") - if events is not None: - events.set_elements(AAZStrType, ".") - - return self.serialize_content(_content_value) - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.id = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.name = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.properties = AAZObjectType( - flags={"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.content_type = AAZStrType( - serialized_name="contentType", - ) - properties.delivery_status = AAZStrType( - serialized_name="deliveryStatus", - flags={"read_only": True}, - ) - properties.enable_ssl_verification = AAZStrType( - serialized_name="enableSslVerification", - ) - properties.events = AAZListType() - properties.payload_url = AAZStrType( - serialized_name="payloadUrl", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.send_all_events = AAZStrType( - serialized_name="sendAllEvents", - ) - properties.status = AAZStrType() - properties.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - properties.update_webhook_key = AAZStrType( - serialized_name="updateWebhookKey", - ) - properties.webhook_id = AAZStrType( - serialized_name="webhookId", - flags={"read_only": True}, - ) - properties.webhook_key = AAZStrType( - serialized_name="webhookKey", - ) - properties.webhook_key_enabled = AAZStrType( - serialized_name="webhookKeyEnabled", - flags={"read_only": True}, - ) - - events = cls._schema_on_200.properties.events - events.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 webhook update", +) +class Update(AAZCommand): + """Update an exiting AppComplianceAutomation webhook. + """ + + _aaz_info = { + "version": "2024-06-27", + "resources": [ + ["mgmt-plane", "/providers/microsoft.appcomplianceautomation/reports/{}/webhooks/{}", "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}$", + ), + ) + _args_schema.webhook_name = AAZStrArg( + options=["--webhook-name"], + help="Webhook Name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[-a-zA-Z0-9_]{1,50}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.content_type = AAZStrArg( + options=["--content-type"], + arg_group="Properties", + help="content type", + enum={"application/json": "application/json"}, + ) + _args_schema.enable_ssl_verification = AAZStrArg( + options=["--enable-ssl"], + arg_group="Properties", + help="whether to enable ssl verification", + nullable=True, + enum={"false": "false", "true": "true"}, + ) + _args_schema.events = AAZListArg( + options=["--events"], + arg_group="Properties", + help="under which event notification should be sent.", + nullable=True, + ) + _args_schema.payload_url = AAZStrArg( + options=["--payload-url"], + arg_group="Properties", + help="webhook payload url", + nullable=True, + fmt=AAZStrArgFormat( + pattern="^(http(s)?://)[\S]{0,64994}$", + ), + ) + _args_schema.send_all_events = AAZStrArg( + options=["--trigger-mode"], + arg_group="Properties", + help="whether to send notification under any event.", + enum={"customize": "false", "all": "true"}, + ) + _args_schema.status = AAZStrArg( + options=["--status"], + arg_group="Properties", + help="Webhook status.", + nullable=True, + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + _args_schema.webhook_key = AAZStrArg( + options=["--secret"], + arg_group="Properties", + help="webhook secret token. If not set, this field value is null; otherwise, please set a string value.", + nullable=True, + fmt=AAZStrArgFormat( + pattern="^.{0,2048}$", + ), + ) + + events = cls._args_schema.events + events.Element = AAZStrArg( + nullable=True, + enum={"assessment_failure": "assessment_failure", "generate_snapshot_failed": "generate_snapshot_failed", "generate_snapshot_success": "generate_snapshot_success", "report_configuration_changes": "report_configuration_changes", "report_deletion": "report_deletion"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WebhookUpdate(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 WebhookUpdate(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}/webhooks/{webhookName}", + **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, + ), + **self.serialize_url_param( + "webhookName", self.ctx.args.webhook_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("contentType", AAZStrType, ".content_type") + properties.set_prop("enableSslVerification", AAZStrType, ".enable_ssl_verification") + properties.set_prop("events", AAZListType, ".events") + properties.set_prop("payloadUrl", AAZStrType, ".payload_url") + properties.set_prop("sendAllEvents", AAZStrType, ".send_all_events") + properties.set_prop("status", AAZStrType, ".status") + properties.set_prop("updateWebhookKey", AAZStrType, ".update_webhook_key") + properties.set_prop("webhookKey", AAZStrType, ".webhook_key") + + events = _builder.get(".properties.events") + if events is not None: + events.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"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.content_type = AAZStrType( + serialized_name="contentType", + ) + properties.delivery_status = AAZStrType( + serialized_name="deliveryStatus", + flags={"read_only": True}, + ) + properties.enable_ssl_verification = AAZStrType( + serialized_name="enableSslVerification", + ) + properties.events = AAZListType() + properties.payload_url = AAZStrType( + serialized_name="payloadUrl", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.send_all_events = AAZStrType( + serialized_name="sendAllEvents", + ) + properties.status = AAZStrType() + properties.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + properties.update_webhook_key = AAZStrType( + serialized_name="updateWebhookKey", + ) + properties.webhook_id = AAZStrType( + serialized_name="webhookId", + flags={"read_only": True}, + ) + properties.webhook_key = AAZStrType( + serialized_name="webhookKey", + ) + properties.webhook_key_enabled = AAZStrType( + serialized_name="webhookKeyEnabled", + flags={"read_only": True}, + ) + + events = cls._schema_on_200.properties.events + events.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"]