diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/__init__.py index f6acc11aa4e..6439dd20eb7 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/__init__.py @@ -8,3 +8,4 @@ # pylint: skip-file # flake8: noqa +from ._clients import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/_clients.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/_clients.py new file mode 100644 index 00000000000..3326c946f53 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/_clients.py @@ -0,0 +1,81 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_client("AAZMicrosoftInsightsDataPlaneClient_monitor") +class AAZMicrosoftInsightsDataPlaneClient(AAZBaseClient): + _CLOUD_HOST_TEMPLATES = { + CloudNameEnum.AzureChinaCloud: "https://api.applicationinsights.azure.cn", + CloudNameEnum.AzureCloud: "https://api.applicationinsights.io", + CloudNameEnum.AzureUSGovernment: "https://api.applicationinsights.us", + } + _CLOUD_HOST_METADATA_INDEX = "appInsightsResourceId" + + _AAD_CREDENTIAL_SCOPES = [ + "https://api.applicationinsights.io/.default", + ] + + @classmethod + def _build_base_url(cls, ctx, **kwargs): + endpoint = cls.get_cloud_endpoint(ctx, cls._CLOUD_HOST_METADATA_INDEX) + if not endpoint: + endpoint = cls._CLOUD_HOST_TEMPLATES.get(ctx.cli_ctx.cloud.name, None) + return endpoint + + @classmethod + def _build_configuration(cls, ctx, credential, **kwargs): + return AAZClientConfiguration( + credential=credential, + credential_scopes=cls._AAD_CREDENTIAL_SCOPES, + **kwargs + ) + + +class _AAZMicrosoftInsightsDataPlaneClientHelper: + """Helper class for AAZMicrosoftInsightsDataPlaneClient""" + + +@register_client("AAZMicrosoftOperationalinsightsDataPlaneClient_monitor") +class AAZMicrosoftOperationalinsightsDataPlaneClient(AAZBaseClient): + _CLOUD_HOST_TEMPLATES = { + CloudNameEnum.AzureCloud: "https://api.loganalytics.io", + } + _CLOUD_HOST_METADATA_INDEX = "logAnalyticslogAnalyticsResourceId" + + _AAD_CREDENTIAL_SCOPES = [ + "https://api.loganalytics.io/.default", + ] + + @classmethod + def _build_base_url(cls, ctx, **kwargs): + endpoint = cls.get_cloud_endpoint(ctx, cls._CLOUD_HOST_METADATA_INDEX) + if not endpoint: + endpoint = cls._CLOUD_HOST_TEMPLATES.get(ctx.cli_ctx.cloud.name, None) + return endpoint + + @classmethod + def _build_configuration(cls, ctx, credential, **kwargs): + return AAZClientConfiguration( + credential=credential, + credential_scopes=cls._AAD_CREDENTIAL_SCOPES, + **kwargs + ) + + +class _AAZMicrosoftOperationalinsightsDataPlaneClientHelper: + """Helper class for AAZMicrosoftOperationalinsightsDataPlaneClient""" + + +__all__ = [ + "AAZMicrosoftInsightsDataPlaneClient", + "AAZMicrosoftOperationalinsightsDataPlaneClient", +] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py index cbd304052e8..9d63cb17901 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py @@ -29,6 +29,8 @@ class List(AAZCommand): ] } + AZ_SUPPORT_PAGINATION = True + def _handler(self, command_args): super()._handler(command_args) return self.build_paging(self._execute_operations, self._output) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_assign.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_assign.py index 5457f7361d9..0e3b799cfe1 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_assign.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_assign.py @@ -83,9 +83,9 @@ def _build_arguments_schema(cls, *args, **kwargs): def _execute_operations(self): self.pre_operations() self.ActionGroupsGet(ctx=self.ctx)() - self.pre_instance_update(self.ctx.selectors.subresource.required()) + self.pre_instance_update(self.ctx.selectors.subresource.get()) self.InstanceUpdateByJson(ctx=self.ctx)() - self.post_instance_update(self.ctx.selectors.subresource.required()) + self.post_instance_update(self.ctx.selectors.subresource.get()) self.ActionGroupsCreateOrUpdate(ctx=self.ctx)() self.post_operations() @@ -106,7 +106,7 @@ def post_instance_update(self, instance): pass def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.selectors.subresource.required(), client_flatten=True) + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) return result class SubresourceSelector(AAZJsonSelector): @@ -301,7 +301,7 @@ def _build_schema_on_200_201(cls): class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): def __call__(self, *args, **kwargs): - self._update_instance(self.ctx.selectors.subresource.required()) + self._update_instance(self.ctx.selectors.subresource.get()) def _update_instance(self, instance): _instance_value, _builder = self.new_content_builder( diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_remove.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_remove.py index 30456e529b9..f7a5ade14c1 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_remove.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/action_group/identity/_remove.py @@ -84,9 +84,9 @@ def _build_arguments_schema(cls, *args, **kwargs): def _execute_operations(self): self.pre_operations() self.ActionGroupsGet(ctx=self.ctx)() - self.pre_instance_update(self.ctx.selectors.subresource.required()) + self.pre_instance_update(self.ctx.selectors.subresource.get()) self.InstanceUpdateByJson(ctx=self.ctx)() - self.post_instance_update(self.ctx.selectors.subresource.required()) + self.post_instance_update(self.ctx.selectors.subresource.get()) self.ActionGroupsCreateOrUpdate(ctx=self.ctx)() self.post_operations() @@ -107,7 +107,7 @@ def post_instance_update(self, instance): pass def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.selectors.subresource.required(), client_flatten=True) + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) return result class SubresourceSelector(AAZJsonSelector): @@ -302,7 +302,7 @@ def _build_schema_on_200_201(cls): class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): def __call__(self, *args, **kwargs): - self._update_instance(self.ctx.selectors.subresource.required()) + self._update_instance(self.ctx.selectors.subresource.get()) def _update_instance(self, instance): _instance_value, _builder = self.new_content_builder( diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/activity_log/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/activity_log/_list.py index 13598fba3d7..9a3d162f620 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/activity_log/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/activity_log/_list.py @@ -175,7 +175,9 @@ def _build_schema_on_200(cls): _element.caller = AAZStrType( flags={"read_only": True}, ) - _element.category = AAZObjectType() + _element.category = AAZObjectType( + flags={"read_only": True}, + ) _ListHelper._build_schema_localizable_string_read(_element.category) _element.claims = AAZDictType( flags={"read_only": True}, @@ -214,6 +216,7 @@ def _build_schema_on_200(cls): ) _element.operation_name = AAZObjectType( serialized_name="operationName", + flags={"read_only": True}, ) _ListHelper._build_schema_localizable_string_read(_element.operation_name) _element.properties = AAZDictType( @@ -233,10 +236,13 @@ def _build_schema_on_200(cls): _element.resource_type = AAZObjectType( serialized_name="resourceType", ) - _element.status = AAZObjectType() + _element.status = AAZObjectType( + flags={"read_only": True}, + ) _ListHelper._build_schema_localizable_string_read(_element.status) _element.sub_status = AAZObjectType( serialized_name="subStatus", + flags={"read_only": True}, ) _ListHelper._build_schema_localizable_string_read(_element.sub_status) _element.submission_timestamp = AAZStrType( diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/__cmd_group.py new file mode 100644 index 00000000000..c39e6cc3aea --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights", +) +class __CMDGroup(AAZCommandGroup): + """Commands for querying data in Application Insights applications. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/__init__.py new file mode 100644 index 00000000000..caa40985d1c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/__init__.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._migrate_to_new_pricing_model import * +from ._query_execute import * +from ._query_show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_migrate_to_new_pricing_model.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_migrate_to_new_pricing_model.py new file mode 100644 index 00000000000..cee9a757b30 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_migrate_to_new_pricing_model.py @@ -0,0 +1,114 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights migrate-to-new-pricing-model", +) +class MigrateToNewPricingModel(AAZCommand): + """Enterprise Agreement Customer opted to use new pricing model. + + :example: Migrate to new pricing model + az monitor app-insights migrate-to-new-pricing-model + """ + + _aaz_info = { + "version": "2017-10-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/migratetonewpricingmodel", "2017-10-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EASubscriptionMigrateToNewPricingModelPost(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class EASubscriptionMigrateToNewPricingModelPost(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + 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( + "/subscriptions/{subscriptionId}/providers/microsoft.insights/migrateToNewPricingModel", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2017-10-01", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + +class _MigrateToNewPricingModelHelper: + """Helper class for MigrateToNewPricingModel""" + + +__all__ = ["MigrateToNewPricingModel"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_query_execute.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_query_execute.py new file mode 100644 index 00000000000..102fb3053f5 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_query_execute.py @@ -0,0 +1,212 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights query-execute", +) +class QueryExecute(AAZCommand): + """Executes an Analytics query for data. Doc https://dev.applicationinsights.io/documentation/Using-the-API/Query is an example for using POST with an Analytics query. + """ + + _aaz_info = { + "version": "v1", + "resources": [ + ["data-plane:microsoft.insights", "/apps/{}/query", "v1"], + ] + } + + 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.app_id = AAZStrArg( + options=["--app-id"], + help="ID of the application. This is Application ID from the API Access settings blade in the Azure portal.", + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.applications = AAZListArg( + options=["--applications"], + arg_group="Body", + help="A list of Application IDs for cross-application queries.", + ) + _args_schema.query = AAZStrArg( + options=["--query"], + arg_group="Body", + help="The query to execute.", + required=True, + ) + _args_schema.timespan = AAZStrArg( + options=["--timespan"], + arg_group="Body", + help="Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression.", + ) + + applications = cls._args_schema.applications + applications.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.QueryExecute(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 QueryExecute(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftInsightsDataPlaneClient_monitor" + + def __call__(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( + "/v1/apps/{appId}/query", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "appId", self.ctx.args.app_id, + 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("applications", AAZListType, ".applications") + _builder.set_prop("query", AAZStrType, ".query", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("timespan", AAZStrType, ".timespan") + + applications = _builder.get(".applications") + if applications is not None: + applications.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.tables = AAZListType( + flags={"required": True}, + ) + + tables = cls._schema_on_200.tables + tables.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element + _element.columns = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.rows = AAZListType( + flags={"required": True}, + ) + + columns = cls._schema_on_200.tables.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + rows = cls._schema_on_200.tables.Element.rows + rows.Element = AAZListType() + + _element = cls._schema_on_200.tables.Element.rows.Element + _element.Element = AAZAnyType() + + return cls._schema_on_200 + + +class _QueryExecuteHelper: + """Helper class for QueryExecute""" + + +__all__ = ["QueryExecute"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_query_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_query_show.py new file mode 100644 index 00000000000..1cad386851b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/_query_show.py @@ -0,0 +1,191 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights query-show", +) +class QueryShow(AAZCommand): + """Get an Analytics query for data + """ + + _aaz_info = { + "version": "v1", + "resources": [ + ["data-plane:microsoft.insights", "/apps/{}/query", "v1"], + ] + } + + 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.app_id = AAZStrArg( + options=["--app-id"], + help="ID of the application. This is Application ID from the API Access settings blade in the Azure portal.", + required=True, + ) + _args_schema.query = AAZStrArg( + options=["--query"], + help="The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/)", + required=True, + ) + _args_schema.timespan = AAZStrArg( + options=["--timespan"], + help="Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.QueryGet(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 QueryGet(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftInsightsDataPlaneClient_monitor" + + def __call__(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( + "/v1/apps/{appId}/query", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "appId", self.ctx.args.app_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "query", self.ctx.args.query, + required=True, + ), + **self.serialize_query_param( + "timespan", self.ctx.args.timespan, + ), + } + 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.tables = AAZListType( + flags={"required": True}, + ) + + tables = cls._schema_on_200.tables + tables.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element + _element.columns = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.rows = AAZListType( + flags={"required": True}, + ) + + columns = cls._schema_on_200.tables.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + rows = cls._schema_on_200.tables.Element.rows + rows.Element = AAZListType() + + _element = cls._schema_on_200.tables.Element.rows.Element + _element.Element = AAZAnyType() + + return cls._schema_on_200 + + +class _QueryShowHelper: + """Helper class for QueryShow""" + + +__all__ = ["QueryShow"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/__cmd_group.py new file mode 100644 index 00000000000..bbb06088cc8 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights api-key", +) +class __CMDGroup(AAZCommandGroup): + """Operations on API keys associated with an Application Insights component. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/__init__.py new file mode 100644 index 00000000000..efc3964e3fb --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_create.py new file mode 100644 index 00000000000..423c8bc79ba --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_create.py @@ -0,0 +1,231 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights api-key create", +) +class Create(AAZCommand): + """Create an API Key of an Application Insights component. + + :example: Create a component with kind web and location. + az monitor app-insights api-key create --api-key cli-demo --read-properties ReadTelemetry --write-properties WriteAnnotations -g demoRg --app testApp + + :example: Create a component with kind web and location without any permission + az monitor app-insights api-key create --api-key cli-demo --read-properties '""' --write-properties '""' -g demoRg --app testApp + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/apikeys", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.read_properties = AAZListArg( + options=["--read-properties"], + help="A space-separated list of names of read Roles for this API key to inherit.", + ) + _args_schema.write_properties = AAZListArg( + options=["--write-properties"], + help="A space-separated list of names of write Roles for this API key to inherit.", + ) + _args_schema.api_key = AAZStrArg( + options=["--api-key"], + help="Name of the API key to create.", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + ) + + read_properties = cls._args_schema.read_properties + read_properties.Element = AAZStrArg() + + write_properties = cls._args_schema.write_properties + write_properties.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.APIKeysCreate(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 APIKeysCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("linkedReadProperties", AAZListType, ".read_properties") + _builder.set_prop("linkedWriteProperties", AAZListType, ".write_properties") + _builder.set_prop("name", AAZStrType, ".api_key") + + linked_read_properties = _builder.get(".linkedReadProperties") + if linked_read_properties is not None: + linked_read_properties.set_elements(AAZStrType, ".") + + linked_write_properties = _builder.get(".linkedWriteProperties") + if linked_write_properties is not None: + linked_write_properties.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.api_key = AAZStrType( + serialized_name="apiKey", + flags={"read_only": True}, + ) + _schema_on_200.created_date = AAZStrType( + serialized_name="createdDate", + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.linked_read_properties = AAZListType( + serialized_name="linkedReadProperties", + ) + _schema_on_200.linked_write_properties = AAZListType( + serialized_name="linkedWriteProperties", + ) + _schema_on_200.name = AAZStrType() + + linked_read_properties = cls._schema_on_200.linked_read_properties + linked_read_properties.Element = AAZStrType() + + linked_write_properties = cls._schema_on_200.linked_write_properties + linked_write_properties.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_delete.py new file mode 100644 index 00000000000..f930e8333bd --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_delete.py @@ -0,0 +1,198 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights api-key delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an API key from an Application Insights resource. + + :example: Delete API Key. + az monitor app-insights api-key delete --app demoApp -g demoRg --api-key demo-key + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/apikeys/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_key = AAZStrArg( + options=["--api-key"], + help="Name of the API key to delete. Can be found using `api-key show`.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.APIKeysDelete(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 APIKeysDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}", + **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( + "keyId", self.ctx.args.api_key, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.api_key = AAZStrType( + serialized_name="apiKey", + flags={"read_only": True}, + ) + _schema_on_200.created_date = AAZStrType( + serialized_name="createdDate", + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.linked_read_properties = AAZListType( + serialized_name="linkedReadProperties", + ) + _schema_on_200.linked_write_properties = AAZListType( + serialized_name="linkedWriteProperties", + ) + _schema_on_200.name = AAZStrType() + + linked_read_properties = cls._schema_on_200.linked_read_properties + linked_read_properties.Element = AAZStrType() + + linked_write_properties = cls._schema_on_200.linked_write_properties + linked_write_properties.Element = AAZStrType() + + return cls._schema_on_200 + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_list.py new file mode 100644 index 00000000000..9b48a15a394 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_list.py @@ -0,0 +1,191 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights api-key list", +) +class List(AAZCommand): + """List a list of API keys of an Application Insights component. + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/apikeys", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.APIKeysList(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) + return result + + class APIKeysList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.api_key = AAZStrType( + serialized_name="apiKey", + flags={"read_only": True}, + ) + _element.created_date = AAZStrType( + serialized_name="createdDate", + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.linked_read_properties = AAZListType( + serialized_name="linkedReadProperties", + ) + _element.linked_write_properties = AAZListType( + serialized_name="linkedWriteProperties", + ) + _element.name = AAZStrType() + + linked_read_properties = cls._schema_on_200.value.Element.linked_read_properties + linked_read_properties.Element = AAZStrType() + + linked_write_properties = cls._schema_on_200.value.Element.linked_write_properties + linked_write_properties.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_show.py new file mode 100644 index 00000000000..b87997380a6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/api_key/_show.py @@ -0,0 +1,194 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights api-key show", +) +class Show(AAZCommand): + """Get the API Key for this key id. + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/apikeys/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.key_id = AAZStrArg( + options=["-n", "--name", "--key-id"], + help="The API Key ID. This is unique within a Application Insights component.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.APIKeysGet(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 APIKeysGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}", + **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( + "keyId", self.ctx.args.key_id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.api_key = AAZStrType( + serialized_name="apiKey", + flags={"read_only": True}, + ) + _schema_on_200.created_date = AAZStrType( + serialized_name="createdDate", + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.linked_read_properties = AAZListType( + serialized_name="linkedReadProperties", + ) + _schema_on_200.linked_write_properties = AAZListType( + serialized_name="linkedWriteProperties", + ) + _schema_on_200.name = AAZStrType() + + linked_read_properties = cls._schema_on_200.linked_read_properties + linked_read_properties.Element = AAZStrType() + + linked_write_properties = cls._schema_on_200.linked_write_properties + linked_write_properties.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/__cmd_group.py new file mode 100644 index 00000000000..99d4b933cd1 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights component", +) +class __CMDGroup(AAZCommandGroup): + """Manage an Application Insights component or its subcomponents. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/__cmd_group.py new file mode 100644 index 00000000000..227498c87f6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights component billing", +) +class __CMDGroup(AAZCommandGroup): + """Manage an Application Insights component billing features. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/__init__.py new file mode 100644 index 00000000000..1fcc89bcaa3 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/__init__.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_create.py new file mode 100644 index 00000000000..a50dd98f65c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_create.py @@ -0,0 +1,252 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component billing create", +) +class Create(AAZCommand): + """Create current billing features for an Application Insights component. + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/currentbillingfeatures", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + ) + + # define Arg Group "BillingFeaturesProperties" + + _args_schema = cls._args_schema + _args_schema.current_billing_features = AAZListArg( + options=["--current-billing-features"], + arg_group="BillingFeaturesProperties", + help="Current enabled pricing plan. When the component is in the Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'.", + ) + _args_schema.data_volume_cap = AAZObjectArg( + options=["--data-volume-cap"], + arg_group="BillingFeaturesProperties", + help="An Application Insights component daily data volume cap", + ) + + current_billing_features = cls._args_schema.current_billing_features + current_billing_features.Element = AAZStrArg() + + data_volume_cap = cls._args_schema.data_volume_cap + data_volume_cap.cap = AAZFloatArg( + options=["cap"], + help="Daily data volume cap in GB.", + ) + data_volume_cap.stop_send_notification_when_hit_cap = AAZBoolArg( + options=["stop-send-notification-when-hit-cap"], + help="Do not send a notification email when the daily data volume cap is met.", + ) + data_volume_cap.stop_send_notification_when_hit_threshold = AAZBoolArg( + options=["stop-send-notification-when-hit-threshold"], + help="Reserved, not used for now.", + ) + data_volume_cap.warning_threshold = AAZIntArg( + options=["warning-threshold"], + help="Reserved, not used for now.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentCurrentBillingFeaturesUpdate(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 ComponentCurrentBillingFeaturesUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("CurrentBillingFeatures", AAZListType, ".current_billing_features") + _builder.set_prop("DataVolumeCap", AAZObjectType, ".data_volume_cap") + + current_billing_features = _builder.get(".CurrentBillingFeatures") + if current_billing_features is not None: + current_billing_features.set_elements(AAZStrType, ".") + + data_volume_cap = _builder.get(".DataVolumeCap") + if data_volume_cap is not None: + data_volume_cap.set_prop("Cap", AAZFloatType, ".cap") + data_volume_cap.set_prop("StopSendNotificationWhenHitCap", AAZBoolType, ".stop_send_notification_when_hit_cap") + data_volume_cap.set_prop("StopSendNotificationWhenHitThreshold", AAZBoolType, ".stop_send_notification_when_hit_threshold") + data_volume_cap.set_prop("WarningThreshold", AAZIntType, ".warning_threshold") + + 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.current_billing_features = AAZListType( + serialized_name="CurrentBillingFeatures", + ) + _schema_on_200.data_volume_cap = AAZObjectType( + serialized_name="DataVolumeCap", + ) + + current_billing_features = cls._schema_on_200.current_billing_features + current_billing_features.Element = AAZStrType() + + data_volume_cap = cls._schema_on_200.data_volume_cap + data_volume_cap.cap = AAZFloatType( + serialized_name="Cap", + ) + data_volume_cap.max_history_cap = AAZFloatType( + serialized_name="MaxHistoryCap", + flags={"read_only": True}, + ) + data_volume_cap.reset_time = AAZIntType( + serialized_name="ResetTime", + flags={"read_only": True}, + ) + data_volume_cap.stop_send_notification_when_hit_cap = AAZBoolType( + serialized_name="StopSendNotificationWhenHitCap", + ) + data_volume_cap.stop_send_notification_when_hit_threshold = AAZBoolType( + serialized_name="StopSendNotificationWhenHitThreshold", + ) + data_volume_cap.warning_threshold = AAZIntType( + serialized_name="WarningThreshold", + ) + + return cls._schema_on_200 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_show.py new file mode 100644 index 00000000000..6dd134d0d5d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_show.py @@ -0,0 +1,195 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component billing show", +) +class Show(AAZCommand): + """Show the billing features of an Application Insights resource. + + :example: Show the billing features of an application insights component + az monitor app-insights component billing show --app demoApp -g demoRg + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/currentbillingfeatures", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentCurrentBillingFeaturesGet(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 ComponentCurrentBillingFeaturesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.current_billing_features = AAZListType( + serialized_name="CurrentBillingFeatures", + ) + _schema_on_200.data_volume_cap = AAZObjectType( + serialized_name="DataVolumeCap", + ) + + current_billing_features = cls._schema_on_200.current_billing_features + current_billing_features.Element = AAZStrType() + + data_volume_cap = cls._schema_on_200.data_volume_cap + data_volume_cap.cap = AAZFloatType( + serialized_name="Cap", + ) + data_volume_cap.max_history_cap = AAZFloatType( + serialized_name="MaxHistoryCap", + flags={"read_only": True}, + ) + data_volume_cap.reset_time = AAZIntType( + serialized_name="ResetTime", + flags={"read_only": True}, + ) + data_volume_cap.stop_send_notification_when_hit_cap = AAZBoolType( + serialized_name="StopSendNotificationWhenHitCap", + ) + data_volume_cap.stop_send_notification_when_hit_threshold = AAZBoolType( + serialized_name="StopSendNotificationWhenHitThreshold", + ) + data_volume_cap.warning_threshold = AAZIntType( + serialized_name="WarningThreshold", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_update.py new file mode 100644 index 00000000000..c4c6f42577a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/billing/_update.py @@ -0,0 +1,359 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component billing update", +) +class Update(AAZCommand): + """Update the billing features of an Application Insights resource. + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/currentbillingfeatures", "2015-05-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cap = AAZFloatArg( + options=["--cap"], + help="Daily data volume cap in GB.", + nullable=True, + ) + _args_schema.stop = AAZBoolArg( + options=["-s", "--stop"], + help="Do not send a notification email when the daily data volume cap is met.", + nullable=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + + # define Arg Group "BillingFeaturesProperties" + + # define Arg Group "DataVolumeCap" + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentCurrentBillingFeaturesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.ComponentCurrentBillingFeaturesUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ComponentCurrentBillingFeaturesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_application_insights_component_billing_features_read(cls._schema_on_200) + + return cls._schema_on_200 + + class ComponentCurrentBillingFeaturesUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_application_insights_component_billing_features_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("DataVolumeCap", AAZObjectType) + + data_volume_cap = _builder.get(".DataVolumeCap") + if data_volume_cap is not None: + data_volume_cap.set_prop("Cap", AAZFloatType, ".cap") + data_volume_cap.set_prop("StopSendNotificationWhenHitCap", AAZBoolType, ".stop") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_application_insights_component_billing_features_read = None + + @classmethod + def _build_schema_application_insights_component_billing_features_read(cls, _schema): + if cls._schema_application_insights_component_billing_features_read is not None: + _schema.current_billing_features = cls._schema_application_insights_component_billing_features_read.current_billing_features + _schema.data_volume_cap = cls._schema_application_insights_component_billing_features_read.data_volume_cap + return + + cls._schema_application_insights_component_billing_features_read = _schema_application_insights_component_billing_features_read = AAZObjectType() + + application_insights_component_billing_features_read = _schema_application_insights_component_billing_features_read + application_insights_component_billing_features_read.current_billing_features = AAZListType( + serialized_name="CurrentBillingFeatures", + ) + application_insights_component_billing_features_read.data_volume_cap = AAZObjectType( + serialized_name="DataVolumeCap", + ) + + current_billing_features = _schema_application_insights_component_billing_features_read.current_billing_features + current_billing_features.Element = AAZStrType() + + data_volume_cap = _schema_application_insights_component_billing_features_read.data_volume_cap + data_volume_cap.cap = AAZFloatType( + serialized_name="Cap", + ) + data_volume_cap.max_history_cap = AAZFloatType( + serialized_name="MaxHistoryCap", + flags={"read_only": True}, + ) + data_volume_cap.reset_time = AAZIntType( + serialized_name="ResetTime", + flags={"read_only": True}, + ) + data_volume_cap.stop_send_notification_when_hit_cap = AAZBoolType( + serialized_name="StopSendNotificationWhenHitCap", + ) + data_volume_cap.stop_send_notification_when_hit_threshold = AAZBoolType( + serialized_name="StopSendNotificationWhenHitThreshold", + ) + data_volume_cap.warning_threshold = AAZIntType( + serialized_name="WarningThreshold", + ) + + _schema.current_billing_features = cls._schema_application_insights_component_billing_features_read.current_billing_features + _schema.data_volume_cap = cls._schema_application_insights_component_billing_features_read.data_volume_cap + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/__cmd_group.py new file mode 100644 index 00000000000..2b2d8728dab --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights component continues-export", +) +class __CMDGroup(AAZCommandGroup): + """Manage Continuous Export configurations for an Application Insights component. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/__init__.py new file mode 100644 index 00000000000..282c7710144 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._create_untitled import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_create.py new file mode 100644 index 00000000000..adcf42d3b3d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_create.py @@ -0,0 +1,317 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component continues-export create", +) +class Create(AAZCommand): + """Create a Continuous Export configuration for an Application Insights component. + + :example: Create a Continuous Export configuration. + az monitor app-insights component continues-export create -g rg --app 578f0e27-12e9-4631-bc02-50b965da2633 --record-types Requests Event Exceptions Metrics PageViews --dest-account account --dest-container container --dest-sub-id sub-id --dest-sas se=2020-10-27&sp=w&sv=2018-11-09&sr=c + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/exportconfiguration/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.export_id = AAZStrArg( + options=["-n", "--name", "--export-id"], + help="The Continuous Export configuration ID. This is unique within a Application Insights component.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + ) + + # define Arg Group "ExportProperties" + + _args_schema = cls._args_schema + _args_schema.destination_account_id = AAZStrArg( + options=["--destination-account-id"], + arg_group="ExportProperties", + help="The name of destination storage account.", + ) + _args_schema.destination_address = AAZStrArg( + options=["--destination-address"], + arg_group="ExportProperties", + help="The SAS URL for the destination storage container. It must grant write permission.", + ) + _args_schema.destination_storage_location_id = AAZStrArg( + options=["--destination-storage-location-id"], + arg_group="ExportProperties", + help="The location ID of the destination storage container.", + ) + _args_schema.destination_storage_subscription_id = AAZStrArg( + options=["--destination-storage-subscription-id"], + arg_group="ExportProperties", + help="The subscription ID of the destination storage container.", + ) + _args_schema.destination_type = AAZStrArg( + options=["--destination-type"], + arg_group="ExportProperties", + help="The Continuous Export destination type. This has to be 'Blob'.", + ) + _args_schema.is_enabled = AAZStrArg( + options=["--is-enabled"], + arg_group="ExportProperties", + help="Set to 'true' to create a Continuous Export configuration as enabled, otherwise set it to 'false'.", + ) + _args_schema.notification_queue_enabled = AAZStrArg( + options=["--notification-queue-enabled"], + arg_group="ExportProperties", + help="Deprecated", + ) + _args_schema.notification_queue_uri = AAZStrArg( + options=["--notification-queue-uri"], + arg_group="ExportProperties", + help="Deprecated", + ) + _args_schema.record_types = AAZStrArg( + options=["--record-types"], + arg_group="ExportProperties", + help="The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ExportConfigurationsUpdate(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 ExportConfigurationsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + **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( + "exportId", self.ctx.args.export_id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("DestinationAccountId", AAZStrType, ".destination_account_id") + _builder.set_prop("DestinationAddress", AAZStrType, ".destination_address") + _builder.set_prop("DestinationStorageLocationId", AAZStrType, ".destination_storage_location_id") + _builder.set_prop("DestinationStorageSubscriptionId", AAZStrType, ".destination_storage_subscription_id") + _builder.set_prop("DestinationType", AAZStrType, ".destination_type") + _builder.set_prop("IsEnabled", AAZStrType, ".is_enabled") + _builder.set_prop("NotificationQueueEnabled", AAZStrType, ".notification_queue_enabled") + _builder.set_prop("NotificationQueueUri", AAZStrType, ".notification_queue_uri") + _builder.set_prop("RecordTypes", AAZStrType, ".record_types") + + 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.application_name = AAZStrType( + serialized_name="ApplicationName", + flags={"read_only": True}, + ) + _schema_on_200.container_name = AAZStrType( + serialized_name="ContainerName", + flags={"read_only": True}, + ) + _schema_on_200.destination_account_id = AAZStrType( + serialized_name="DestinationAccountId", + flags={"read_only": True}, + ) + _schema_on_200.destination_storage_location_id = AAZStrType( + serialized_name="DestinationStorageLocationId", + flags={"read_only": True}, + ) + _schema_on_200.destination_storage_subscription_id = AAZStrType( + serialized_name="DestinationStorageSubscriptionId", + flags={"read_only": True}, + ) + _schema_on_200.destination_type = AAZStrType( + serialized_name="DestinationType", + flags={"read_only": True}, + ) + _schema_on_200.export_id = AAZStrType( + serialized_name="ExportId", + flags={"read_only": True}, + ) + _schema_on_200.export_status = AAZStrType( + serialized_name="ExportStatus", + flags={"read_only": True}, + ) + _schema_on_200.instrumentation_key = AAZStrType( + serialized_name="InstrumentationKey", + flags={"read_only": True}, + ) + _schema_on_200.is_user_enabled = AAZStrType( + serialized_name="IsUserEnabled", + flags={"read_only": True}, + ) + _schema_on_200.last_gap_time = AAZStrType( + serialized_name="LastGapTime", + flags={"read_only": True}, + ) + _schema_on_200.last_success_time = AAZStrType( + serialized_name="LastSuccessTime", + flags={"read_only": True}, + ) + _schema_on_200.last_user_update = AAZStrType( + serialized_name="LastUserUpdate", + flags={"read_only": True}, + ) + _schema_on_200.notification_queue_enabled = AAZStrType( + serialized_name="NotificationQueueEnabled", + ) + _schema_on_200.permanent_error_reason = AAZStrType( + serialized_name="PermanentErrorReason", + flags={"read_only": True}, + ) + _schema_on_200.record_types = AAZStrType( + serialized_name="RecordTypes", + ) + _schema_on_200.resource_group = AAZStrType( + serialized_name="ResourceGroup", + flags={"read_only": True}, + ) + _schema_on_200.storage_name = AAZStrType( + serialized_name="StorageName", + flags={"read_only": True}, + ) + _schema_on_200.subscription_id = AAZStrType( + serialized_name="SubscriptionId", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_create_untitled.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_create_untitled.py new file mode 100644 index 00000000000..031404b79c7 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_create_untitled.py @@ -0,0 +1,309 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component continues-export create-untitled", +) +class CreateUntitled(AAZCommand): + """Create a Continuous Export configuration of an Application Insights component. + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/exportconfiguration", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + + # define Arg Group "ExportProperties" + + _args_schema = cls._args_schema + _args_schema.destination_account_id = AAZStrArg( + options=["--destination-account-id"], + arg_group="ExportProperties", + help="The name of destination storage account.", + ) + _args_schema.destination_address = AAZStrArg( + options=["--destination-address"], + arg_group="ExportProperties", + help="The SAS URL for the destination storage container. It must grant write permission.", + ) + _args_schema.destination_storage_location_id = AAZStrArg( + options=["--destination-storage-location-id"], + arg_group="ExportProperties", + help="The location ID of the destination storage container.", + ) + _args_schema.destination_storage_subscription_id = AAZStrArg( + options=["--destination-storage-subscription-id"], + arg_group="ExportProperties", + help="The subscription ID of the destination storage container.", + ) + _args_schema.destination_type = AAZStrArg( + options=["--destination-type"], + arg_group="ExportProperties", + help="The Continuous Export destination type. This has to be 'Blob'.", + ) + _args_schema.is_enabled = AAZStrArg( + options=["--is-enabled"], + arg_group="ExportProperties", + help="Set to 'true' to create a Continuous Export configuration as enabled, otherwise set it to 'false'.", + ) + _args_schema.notification_queue_enabled = AAZStrArg( + options=["--notification-queue-enabled"], + arg_group="ExportProperties", + help="Deprecated", + ) + _args_schema.notification_queue_uri = AAZStrArg( + options=["--notification-queue-uri"], + arg_group="ExportProperties", + help="Deprecated", + ) + _args_schema.record_types = AAZStrArg( + options=["--record-types"], + arg_group="ExportProperties", + help="The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ExportConfigurationsCreate(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 ExportConfigurationsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("DestinationAccountId", AAZStrType, ".destination_account_id") + _builder.set_prop("DestinationAddress", AAZStrType, ".destination_address") + _builder.set_prop("DestinationStorageLocationId", AAZStrType, ".destination_storage_location_id") + _builder.set_prop("DestinationStorageSubscriptionId", AAZStrType, ".destination_storage_subscription_id") + _builder.set_prop("DestinationType", AAZStrType, ".destination_type") + _builder.set_prop("IsEnabled", AAZStrType, ".is_enabled") + _builder.set_prop("NotificationQueueEnabled", AAZStrType, ".notification_queue_enabled") + _builder.set_prop("NotificationQueueUri", AAZStrType, ".notification_queue_uri") + _builder.set_prop("RecordTypes", AAZStrType, ".record_types") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.application_name = AAZStrType( + serialized_name="ApplicationName", + flags={"read_only": True}, + ) + _element.container_name = AAZStrType( + serialized_name="ContainerName", + flags={"read_only": True}, + ) + _element.destination_account_id = AAZStrType( + serialized_name="DestinationAccountId", + flags={"read_only": True}, + ) + _element.destination_storage_location_id = AAZStrType( + serialized_name="DestinationStorageLocationId", + flags={"read_only": True}, + ) + _element.destination_storage_subscription_id = AAZStrType( + serialized_name="DestinationStorageSubscriptionId", + flags={"read_only": True}, + ) + _element.destination_type = AAZStrType( + serialized_name="DestinationType", + flags={"read_only": True}, + ) + _element.export_id = AAZStrType( + serialized_name="ExportId", + flags={"read_only": True}, + ) + _element.export_status = AAZStrType( + serialized_name="ExportStatus", + flags={"read_only": True}, + ) + _element.instrumentation_key = AAZStrType( + serialized_name="InstrumentationKey", + flags={"read_only": True}, + ) + _element.is_user_enabled = AAZStrType( + serialized_name="IsUserEnabled", + flags={"read_only": True}, + ) + _element.last_gap_time = AAZStrType( + serialized_name="LastGapTime", + flags={"read_only": True}, + ) + _element.last_success_time = AAZStrType( + serialized_name="LastSuccessTime", + flags={"read_only": True}, + ) + _element.last_user_update = AAZStrType( + serialized_name="LastUserUpdate", + flags={"read_only": True}, + ) + _element.notification_queue_enabled = AAZStrType( + serialized_name="NotificationQueueEnabled", + ) + _element.permanent_error_reason = AAZStrType( + serialized_name="PermanentErrorReason", + flags={"read_only": True}, + ) + _element.record_types = AAZStrType( + serialized_name="RecordTypes", + ) + _element.resource_group = AAZStrType( + serialized_name="ResourceGroup", + flags={"read_only": True}, + ) + _element.storage_name = AAZStrType( + serialized_name="StorageName", + flags={"read_only": True}, + ) + _element.subscription_id = AAZStrType( + serialized_name="SubscriptionId", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _CreateUntitledHelper: + """Helper class for CreateUntitled""" + + +__all__ = ["CreateUntitled"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_delete.py new file mode 100644 index 00000000000..4449baccdd6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_delete.py @@ -0,0 +1,249 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component continues-export delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a specific Continuous Export configuration of an Application Insights component. + + :example: Delete a Continuous Export configuration by ID. + az monitor app-insights component continues-export delete -g rg --app 578f0e27-12e9-4631-bc02-50b965da2633 --id exportid + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/exportconfiguration/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.id = AAZStrArg( + options=["--id"], + help="The Continuous Export configuration ID. This is unique within a Application Insights component.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ExportConfigurationsDelete(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 ExportConfigurationsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + **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( + "exportId", self.ctx.args.id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.application_name = AAZStrType( + serialized_name="ApplicationName", + flags={"read_only": True}, + ) + _schema_on_200.container_name = AAZStrType( + serialized_name="ContainerName", + flags={"read_only": True}, + ) + _schema_on_200.destination_account_id = AAZStrType( + serialized_name="DestinationAccountId", + flags={"read_only": True}, + ) + _schema_on_200.destination_storage_location_id = AAZStrType( + serialized_name="DestinationStorageLocationId", + flags={"read_only": True}, + ) + _schema_on_200.destination_storage_subscription_id = AAZStrType( + serialized_name="DestinationStorageSubscriptionId", + flags={"read_only": True}, + ) + _schema_on_200.destination_type = AAZStrType( + serialized_name="DestinationType", + flags={"read_only": True}, + ) + _schema_on_200.export_id = AAZStrType( + serialized_name="ExportId", + flags={"read_only": True}, + ) + _schema_on_200.export_status = AAZStrType( + serialized_name="ExportStatus", + flags={"read_only": True}, + ) + _schema_on_200.instrumentation_key = AAZStrType( + serialized_name="InstrumentationKey", + flags={"read_only": True}, + ) + _schema_on_200.is_user_enabled = AAZStrType( + serialized_name="IsUserEnabled", + flags={"read_only": True}, + ) + _schema_on_200.last_gap_time = AAZStrType( + serialized_name="LastGapTime", + flags={"read_only": True}, + ) + _schema_on_200.last_success_time = AAZStrType( + serialized_name="LastSuccessTime", + flags={"read_only": True}, + ) + _schema_on_200.last_user_update = AAZStrType( + serialized_name="LastUserUpdate", + flags={"read_only": True}, + ) + _schema_on_200.notification_queue_enabled = AAZStrType( + serialized_name="NotificationQueueEnabled", + ) + _schema_on_200.permanent_error_reason = AAZStrType( + serialized_name="PermanentErrorReason", + flags={"read_only": True}, + ) + _schema_on_200.record_types = AAZStrType( + serialized_name="RecordTypes", + ) + _schema_on_200.resource_group = AAZStrType( + serialized_name="ResourceGroup", + flags={"read_only": True}, + ) + _schema_on_200.storage_name = AAZStrType( + serialized_name="StorageName", + flags={"read_only": True}, + ) + _schema_on_200.subscription_id = AAZStrType( + serialized_name="SubscriptionId", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_list.py new file mode 100644 index 00000000000..da6f049ea01 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_list.py @@ -0,0 +1,240 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component continues-export list", +) +class List(AAZCommand): + """List a list of Continuous Export configuration of an Application Insights component. + + :example: List export configurations + az monitor app-insights component continues-export list -g rg --app 578f0e27-12e9-4631-bc02-50b965da2633 + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/exportconfiguration", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ExportConfigurationsList(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 ExportConfigurationsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.application_name = AAZStrType( + serialized_name="ApplicationName", + flags={"read_only": True}, + ) + _element.container_name = AAZStrType( + serialized_name="ContainerName", + flags={"read_only": True}, + ) + _element.destination_account_id = AAZStrType( + serialized_name="DestinationAccountId", + flags={"read_only": True}, + ) + _element.destination_storage_location_id = AAZStrType( + serialized_name="DestinationStorageLocationId", + flags={"read_only": True}, + ) + _element.destination_storage_subscription_id = AAZStrType( + serialized_name="DestinationStorageSubscriptionId", + flags={"read_only": True}, + ) + _element.destination_type = AAZStrType( + serialized_name="DestinationType", + flags={"read_only": True}, + ) + _element.export_id = AAZStrType( + serialized_name="ExportId", + flags={"read_only": True}, + ) + _element.export_status = AAZStrType( + serialized_name="ExportStatus", + flags={"read_only": True}, + ) + _element.instrumentation_key = AAZStrType( + serialized_name="InstrumentationKey", + flags={"read_only": True}, + ) + _element.is_user_enabled = AAZStrType( + serialized_name="IsUserEnabled", + flags={"read_only": True}, + ) + _element.last_gap_time = AAZStrType( + serialized_name="LastGapTime", + flags={"read_only": True}, + ) + _element.last_success_time = AAZStrType( + serialized_name="LastSuccessTime", + flags={"read_only": True}, + ) + _element.last_user_update = AAZStrType( + serialized_name="LastUserUpdate", + flags={"read_only": True}, + ) + _element.notification_queue_enabled = AAZStrType( + serialized_name="NotificationQueueEnabled", + ) + _element.permanent_error_reason = AAZStrType( + serialized_name="PermanentErrorReason", + flags={"read_only": True}, + ) + _element.record_types = AAZStrType( + serialized_name="RecordTypes", + ) + _element.resource_group = AAZStrType( + serialized_name="ResourceGroup", + flags={"read_only": True}, + ) + _element.storage_name = AAZStrType( + serialized_name="StorageName", + flags={"read_only": True}, + ) + _element.subscription_id = AAZStrType( + serialized_name="SubscriptionId", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_show.py new file mode 100644 index 00000000000..874ae79672e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_show.py @@ -0,0 +1,248 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component continues-export show", +) +class Show(AAZCommand): + """Get the Continuous Export configuration for this export id. + + :example: Show a continuous export configuration by ID. + az monitor app-insights component continues-export show -g rg --app 578f0e27-12e9-4631-bc02-50b965da2633 --id exportid + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/exportconfiguration/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.id = AAZStrArg( + options=["--id"], + help="The Continuous Export configuration ID. This is unique within a Application Insights component.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ExportConfigurationsGet(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 ExportConfigurationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + **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( + "exportId", self.ctx.args.id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.application_name = AAZStrType( + serialized_name="ApplicationName", + flags={"read_only": True}, + ) + _schema_on_200.container_name = AAZStrType( + serialized_name="ContainerName", + flags={"read_only": True}, + ) + _schema_on_200.destination_account_id = AAZStrType( + serialized_name="DestinationAccountId", + flags={"read_only": True}, + ) + _schema_on_200.destination_storage_location_id = AAZStrType( + serialized_name="DestinationStorageLocationId", + flags={"read_only": True}, + ) + _schema_on_200.destination_storage_subscription_id = AAZStrType( + serialized_name="DestinationStorageSubscriptionId", + flags={"read_only": True}, + ) + _schema_on_200.destination_type = AAZStrType( + serialized_name="DestinationType", + flags={"read_only": True}, + ) + _schema_on_200.export_id = AAZStrType( + serialized_name="ExportId", + flags={"read_only": True}, + ) + _schema_on_200.export_status = AAZStrType( + serialized_name="ExportStatus", + flags={"read_only": True}, + ) + _schema_on_200.instrumentation_key = AAZStrType( + serialized_name="InstrumentationKey", + flags={"read_only": True}, + ) + _schema_on_200.is_user_enabled = AAZStrType( + serialized_name="IsUserEnabled", + flags={"read_only": True}, + ) + _schema_on_200.last_gap_time = AAZStrType( + serialized_name="LastGapTime", + flags={"read_only": True}, + ) + _schema_on_200.last_success_time = AAZStrType( + serialized_name="LastSuccessTime", + flags={"read_only": True}, + ) + _schema_on_200.last_user_update = AAZStrType( + serialized_name="LastUserUpdate", + flags={"read_only": True}, + ) + _schema_on_200.notification_queue_enabled = AAZStrType( + serialized_name="NotificationQueueEnabled", + ) + _schema_on_200.permanent_error_reason = AAZStrType( + serialized_name="PermanentErrorReason", + flags={"read_only": True}, + ) + _schema_on_200.record_types = AAZStrType( + serialized_name="RecordTypes", + ) + _schema_on_200.resource_group = AAZStrType( + serialized_name="ResourceGroup", + flags={"read_only": True}, + ) + _schema_on_200.storage_name = AAZStrType( + serialized_name="StorageName", + flags={"read_only": True}, + ) + _schema_on_200.subscription_id = AAZStrType( + serialized_name="SubscriptionId", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_update.py new file mode 100644 index 00000000000..475166317e5 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/continues_export/_update.py @@ -0,0 +1,497 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component continues-export update", +) +class Update(AAZCommand): + """Update the Continuous Export configuration for this export id. + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/exportconfiguration/{}", "2015-05-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.export_id = AAZStrArg( + options=["-n", "--name", "--export-id"], + help="The Continuous Export configuration ID. This is unique within a Application Insights component.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + + # define Arg Group "ExportProperties" + + _args_schema = cls._args_schema + _args_schema.destination_account_id = AAZStrArg( + options=["--destination-account-id"], + arg_group="ExportProperties", + help="The name of destination storage account.", + nullable=True, + ) + _args_schema.destination_address = AAZStrArg( + options=["--destination-address"], + arg_group="ExportProperties", + help="The SAS URL for the destination storage container. It must grant write permission.", + nullable=True, + ) + _args_schema.destination_storage_location_id = AAZStrArg( + options=["--destination-storage-location-id"], + arg_group="ExportProperties", + help="The location ID of the destination storage container.", + nullable=True, + ) + _args_schema.destination_storage_subscription_id = AAZStrArg( + options=["--destination-storage-subscription-id"], + arg_group="ExportProperties", + help="The subscription ID of the destination storage container.", + nullable=True, + ) + _args_schema.destination_type = AAZStrArg( + options=["--destination-type"], + arg_group="ExportProperties", + help="The Continuous Export destination type. This has to be 'Blob'.", + nullable=True, + ) + _args_schema.is_enabled = AAZStrArg( + options=["--is-enabled"], + arg_group="ExportProperties", + help="Set to 'true' to create a Continuous Export configuration as enabled, otherwise set it to 'false'.", + nullable=True, + ) + _args_schema.notification_queue_enabled = AAZStrArg( + options=["--notification-queue-enabled"], + arg_group="ExportProperties", + help="Deprecated", + nullable=True, + ) + _args_schema.notification_queue_uri = AAZStrArg( + options=["--notification-queue-uri"], + arg_group="ExportProperties", + help="Deprecated", + nullable=True, + ) + _args_schema.record_types = AAZStrArg( + options=["--record-types"], + arg_group="ExportProperties", + help="The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ExportConfigurationsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.ExportConfigurationsUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ExportConfigurationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + **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( + "exportId", self.ctx.args.export_id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_application_insights_component_export_configuration_read(cls._schema_on_200) + + return cls._schema_on_200 + + class ExportConfigurationsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + **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( + "exportId", self.ctx.args.export_id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_application_insights_component_export_configuration_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("DestinationAccountId", AAZStrType, ".destination_account_id") + _builder.set_prop("DestinationAddress", AAZStrType, ".destination_address") + _builder.set_prop("DestinationStorageLocationId", AAZStrType, ".destination_storage_location_id") + _builder.set_prop("DestinationStorageSubscriptionId", AAZStrType, ".destination_storage_subscription_id") + _builder.set_prop("DestinationType", AAZStrType, ".destination_type") + _builder.set_prop("IsEnabled", AAZStrType, ".is_enabled") + _builder.set_prop("NotificationQueueEnabled", AAZStrType, ".notification_queue_enabled") + _builder.set_prop("NotificationQueueUri", AAZStrType, ".notification_queue_uri") + _builder.set_prop("RecordTypes", AAZStrType, ".record_types") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_application_insights_component_export_configuration_read = None + + @classmethod + def _build_schema_application_insights_component_export_configuration_read(cls, _schema): + if cls._schema_application_insights_component_export_configuration_read is not None: + _schema.application_name = cls._schema_application_insights_component_export_configuration_read.application_name + _schema.container_name = cls._schema_application_insights_component_export_configuration_read.container_name + _schema.destination_account_id = cls._schema_application_insights_component_export_configuration_read.destination_account_id + _schema.destination_storage_location_id = cls._schema_application_insights_component_export_configuration_read.destination_storage_location_id + _schema.destination_storage_subscription_id = cls._schema_application_insights_component_export_configuration_read.destination_storage_subscription_id + _schema.destination_type = cls._schema_application_insights_component_export_configuration_read.destination_type + _schema.export_id = cls._schema_application_insights_component_export_configuration_read.export_id + _schema.export_status = cls._schema_application_insights_component_export_configuration_read.export_status + _schema.instrumentation_key = cls._schema_application_insights_component_export_configuration_read.instrumentation_key + _schema.is_user_enabled = cls._schema_application_insights_component_export_configuration_read.is_user_enabled + _schema.last_gap_time = cls._schema_application_insights_component_export_configuration_read.last_gap_time + _schema.last_success_time = cls._schema_application_insights_component_export_configuration_read.last_success_time + _schema.last_user_update = cls._schema_application_insights_component_export_configuration_read.last_user_update + _schema.notification_queue_enabled = cls._schema_application_insights_component_export_configuration_read.notification_queue_enabled + _schema.permanent_error_reason = cls._schema_application_insights_component_export_configuration_read.permanent_error_reason + _schema.record_types = cls._schema_application_insights_component_export_configuration_read.record_types + _schema.resource_group = cls._schema_application_insights_component_export_configuration_read.resource_group + _schema.storage_name = cls._schema_application_insights_component_export_configuration_read.storage_name + _schema.subscription_id = cls._schema_application_insights_component_export_configuration_read.subscription_id + return + + cls._schema_application_insights_component_export_configuration_read = _schema_application_insights_component_export_configuration_read = AAZObjectType() + + application_insights_component_export_configuration_read = _schema_application_insights_component_export_configuration_read + application_insights_component_export_configuration_read.application_name = AAZStrType( + serialized_name="ApplicationName", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.container_name = AAZStrType( + serialized_name="ContainerName", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.destination_account_id = AAZStrType( + serialized_name="DestinationAccountId", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.destination_storage_location_id = AAZStrType( + serialized_name="DestinationStorageLocationId", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.destination_storage_subscription_id = AAZStrType( + serialized_name="DestinationStorageSubscriptionId", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.destination_type = AAZStrType( + serialized_name="DestinationType", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.export_id = AAZStrType( + serialized_name="ExportId", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.export_status = AAZStrType( + serialized_name="ExportStatus", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.instrumentation_key = AAZStrType( + serialized_name="InstrumentationKey", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.is_user_enabled = AAZStrType( + serialized_name="IsUserEnabled", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.last_gap_time = AAZStrType( + serialized_name="LastGapTime", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.last_success_time = AAZStrType( + serialized_name="LastSuccessTime", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.last_user_update = AAZStrType( + serialized_name="LastUserUpdate", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.notification_queue_enabled = AAZStrType( + serialized_name="NotificationQueueEnabled", + ) + application_insights_component_export_configuration_read.permanent_error_reason = AAZStrType( + serialized_name="PermanentErrorReason", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.record_types = AAZStrType( + serialized_name="RecordTypes", + ) + application_insights_component_export_configuration_read.resource_group = AAZStrType( + serialized_name="ResourceGroup", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.storage_name = AAZStrType( + serialized_name="StorageName", + flags={"read_only": True}, + ) + application_insights_component_export_configuration_read.subscription_id = AAZStrType( + serialized_name="SubscriptionId", + flags={"read_only": True}, + ) + + _schema.application_name = cls._schema_application_insights_component_export_configuration_read.application_name + _schema.container_name = cls._schema_application_insights_component_export_configuration_read.container_name + _schema.destination_account_id = cls._schema_application_insights_component_export_configuration_read.destination_account_id + _schema.destination_storage_location_id = cls._schema_application_insights_component_export_configuration_read.destination_storage_location_id + _schema.destination_storage_subscription_id = cls._schema_application_insights_component_export_configuration_read.destination_storage_subscription_id + _schema.destination_type = cls._schema_application_insights_component_export_configuration_read.destination_type + _schema.export_id = cls._schema_application_insights_component_export_configuration_read.export_id + _schema.export_status = cls._schema_application_insights_component_export_configuration_read.export_status + _schema.instrumentation_key = cls._schema_application_insights_component_export_configuration_read.instrumentation_key + _schema.is_user_enabled = cls._schema_application_insights_component_export_configuration_read.is_user_enabled + _schema.last_gap_time = cls._schema_application_insights_component_export_configuration_read.last_gap_time + _schema.last_success_time = cls._schema_application_insights_component_export_configuration_read.last_success_time + _schema.last_user_update = cls._schema_application_insights_component_export_configuration_read.last_user_update + _schema.notification_queue_enabled = cls._schema_application_insights_component_export_configuration_read.notification_queue_enabled + _schema.permanent_error_reason = cls._schema_application_insights_component_export_configuration_read.permanent_error_reason + _schema.record_types = cls._schema_application_insights_component_export_configuration_read.record_types + _schema.resource_group = cls._schema_application_insights_component_export_configuration_read.resource_group + _schema.storage_name = cls._schema_application_insights_component_export_configuration_read.storage_name + _schema.subscription_id = cls._schema_application_insights_component_export_configuration_read.subscription_id + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/__cmd_group.py new file mode 100644 index 00000000000..53324e26b88 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights component favorite", +) +class __CMDGroup(AAZCommandGroup): + """Manage component favorite + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_create.py new file mode 100644 index 00000000000..41a0fb65356 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_create.py @@ -0,0 +1,284 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component favorite create", +) +class Create(AAZCommand): + """Create a new favorites to an Application Insights component. + + :example: Create favorite + az monitor app-insights component favorite create -g rg -n favorite-name --resource-name component-name --config 'myconfig' --version ME --favorite-id favorite-name --favorite-type shared + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/favorites/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The Id of a specific favorite defined in the Application Insights component", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + ) + + # define Arg Group "FavoriteProperties" + + _args_schema = cls._args_schema + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="FavoriteProperties", + help="Favorite category, as defined by the user at creation time.", + ) + _args_schema.config = AAZStrArg( + options=["--config"], + arg_group="FavoriteProperties", + help="Configuration of this particular favorite, which are driven by the Azure portal UX. Configuration data is a string containing valid JSON", + ) + _args_schema.favorite_id = AAZStrArg( + options=["--favorite-id"], + arg_group="FavoriteProperties", + help="Internally assigned unique id of the favorite definition.", + ) + _args_schema.favorite_type = AAZStrArg( + options=["--favorite-type"], + arg_group="FavoriteProperties", + help="Enum indicating if this favorite definition is owned by a specific user or is shared between all users with access to the Application Insights component.", + enum={"shared": "shared", "user": "user"}, + ) + _args_schema.is_generated_from_template = AAZBoolArg( + options=["--is-generated-from-template"], + arg_group="FavoriteProperties", + help="Flag denoting wether or not this favorite was generated from a template.", + ) + _args_schema.source_type = AAZStrArg( + options=["--source-type"], + arg_group="FavoriteProperties", + help="The source of the favorite definition.", + ) + _args_schema.tags = AAZListArg( + options=["--tags"], + arg_group="FavoriteProperties", + help="A list of 0 or more tags that are associated with this favorite definition", + ) + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="FavoriteProperties", + help="This instance's version of the data model. This can change as new features are added that can be marked favorite. Current examples include MetricsExplorer (ME) and Search.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FavoritesAdd(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 FavoritesAdd(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteName}", + **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( + "favoriteName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("Category", AAZStrType, ".category") + _builder.set_prop("Config", AAZStrType, ".config") + _builder.set_prop("FavoriteId", AAZStrType, ".favorite_id") + _builder.set_prop("FavoriteType", AAZStrType, ".favorite_type") + _builder.set_prop("IsGeneratedFromTemplate", AAZBoolType, ".is_generated_from_template") + _builder.set_prop("Name", AAZStrType, ".name") + _builder.set_prop("SourceType", AAZStrType, ".source_type") + _builder.set_prop("Tags", AAZListType, ".tags") + _builder.set_prop("Version", AAZStrType, ".version") + + tags = _builder.get(".Tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.category = AAZStrType( + serialized_name="Category", + ) + _schema_on_200.config = AAZStrType( + serialized_name="Config", + ) + _schema_on_200.favorite_id = AAZStrType( + serialized_name="FavoriteId", + ) + _schema_on_200.favorite_type = AAZStrType( + serialized_name="FavoriteType", + ) + _schema_on_200.is_generated_from_template = AAZBoolType( + serialized_name="IsGeneratedFromTemplate", + ) + _schema_on_200.name = AAZStrType( + serialized_name="Name", + ) + _schema_on_200.source_type = AAZStrType( + serialized_name="SourceType", + ) + _schema_on_200.tags = AAZListType( + serialized_name="Tags", + ) + _schema_on_200.time_modified = AAZStrType( + serialized_name="TimeModified", + flags={"read_only": True}, + ) + _schema_on_200.user_id = AAZStrType( + serialized_name="UserId", + flags={"read_only": True}, + ) + _schema_on_200.version = AAZStrType( + serialized_name="Version", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_delete.py new file mode 100644 index 00000000000..c4b6ff2bc6c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_delete.py @@ -0,0 +1,144 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component favorite delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a favorite that is associated to an Application Insights component. + + :example: Delete favorite + az monitor app-insights component favorite delete -g rg -n favorite-name --resource-name component-name + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/favorites/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The Id of a specific favorite defined in the Application Insights component", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FavoritesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class FavoritesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteName}", + **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( + "favoriteName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_list.py new file mode 100644 index 00000000000..68ad6cd9ddd --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_list.py @@ -0,0 +1,238 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component favorite list", +) +class List(AAZCommand): + """List a list of favorites defined within an Application Insights component. + + :example: List favorite + az monitor app-insights component favorite list -g rg --resource-name component-name --favorite-type shared --tags [tag] + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/favorites", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + ) + _args_schema.can_fetch_content = AAZBoolArg( + options=["--can-fetch-content"], + help="Flag indicating whether or not to return the full content for each applicable favorite. If false, only return summary content for favorites.", + ) + _args_schema.favorite_type = AAZStrArg( + options=["--favorite-type"], + help="The type of favorite. Value can be either shared or user.", + default="shared", + enum={"shared": "shared", "user": "user"}, + ) + _args_schema.source_type = AAZStrArg( + options=["--source-type"], + help="Source type of favorite to return. When left out, the source type defaults to 'other' (not present in this enum).", + enum={"events": "events", "funnel": "funnel", "impact": "impact", "notebook": "notebook", "retention": "retention", "segmentation": "segmentation", "sessions": "sessions", "userflows": "userflows"}, + ) + _args_schema.tags = AAZListArg( + options=["--tags"], + help="Tags that must be present on each favorite returned.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FavoritesList(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 FavoritesList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "canFetchContent", self.ctx.args.can_fetch_content, + ), + **self.serialize_query_param( + "favoriteType", self.ctx.args.favorite_type, + ), + **self.serialize_query_param( + "sourceType", self.ctx.args.source_type, + ), + **self.serialize_query_param( + "tags", self.ctx.args.tags, + ), + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZListType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZObjectType() + + _element = cls._schema_on_200.Element + _element.category = AAZStrType( + serialized_name="Category", + ) + _element.config = AAZStrType( + serialized_name="Config", + ) + _element.favorite_id = AAZStrType( + serialized_name="FavoriteId", + ) + _element.favorite_type = AAZStrType( + serialized_name="FavoriteType", + ) + _element.is_generated_from_template = AAZBoolType( + serialized_name="IsGeneratedFromTemplate", + ) + _element.name = AAZStrType( + serialized_name="Name", + ) + _element.source_type = AAZStrType( + serialized_name="SourceType", + ) + _element.tags = AAZListType( + serialized_name="Tags", + ) + _element.time_modified = AAZStrType( + serialized_name="TimeModified", + flags={"read_only": True}, + ) + _element.user_id = AAZStrType( + serialized_name="UserId", + flags={"read_only": True}, + ) + _element.version = AAZStrType( + serialized_name="Version", + ) + + tags = cls._schema_on_200.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_show.py new file mode 100644 index 00000000000..12ee8435997 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_show.py @@ -0,0 +1,212 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component favorite show", +) +class Show(AAZCommand): + """Get a single favorite by its FavoriteId, defined within an Application Insights component. + + :example: Show favorite + az monitor app-insights component favorite show -g rg -n favorite-name --resource-name component-name + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/favorites/{}", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The Id of a specific favorite defined in the Application Insights component", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FavoritesGet(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 FavoritesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteName}", + **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( + "favoriteName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.category = AAZStrType( + serialized_name="Category", + ) + _schema_on_200.config = AAZStrType( + serialized_name="Config", + ) + _schema_on_200.favorite_id = AAZStrType( + serialized_name="FavoriteId", + ) + _schema_on_200.favorite_type = AAZStrType( + serialized_name="FavoriteType", + ) + _schema_on_200.is_generated_from_template = AAZBoolType( + serialized_name="IsGeneratedFromTemplate", + ) + _schema_on_200.name = AAZStrType( + serialized_name="Name", + ) + _schema_on_200.source_type = AAZStrType( + serialized_name="SourceType", + ) + _schema_on_200.tags = AAZListType( + serialized_name="Tags", + ) + _schema_on_200.time_modified = AAZStrType( + serialized_name="TimeModified", + flags={"read_only": True}, + ) + _schema_on_200.user_id = AAZStrType( + serialized_name="UserId", + flags={"read_only": True}, + ) + _schema_on_200.version = AAZStrType( + serialized_name="Version", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_update.py new file mode 100644 index 00000000000..2094c138e2f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/favorite/_update.py @@ -0,0 +1,452 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component favorite update", +) +class Update(AAZCommand): + """Update a new favorites to an Application Insights component. + + :example: Update favorite + az monitor app-insights component favorite update -g rg -n favorite-name --resource-name component-name --config 'myconfig' --version ME --favorite-id favorite-name --favorite-type shared --tags [tag,test] + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/favorites/{}", "2015-05-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The Id of a specific favorite defined in the Application Insights component", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + + # define Arg Group "FavoriteProperties" + + _args_schema = cls._args_schema + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="FavoriteProperties", + help="Favorite category, as defined by the user at creation time.", + nullable=True, + ) + _args_schema.config = AAZStrArg( + options=["--config"], + arg_group="FavoriteProperties", + help="Configuration of this particular favorite, which are driven by the Azure portal UX. Configuration data is a string containing valid JSON", + nullable=True, + ) + _args_schema.favorite_id = AAZStrArg( + options=["--favorite-id"], + arg_group="FavoriteProperties", + help="Internally assigned unique id of the favorite definition.", + nullable=True, + ) + _args_schema.favorite_type = AAZStrArg( + options=["--favorite-type"], + arg_group="FavoriteProperties", + help="Enum indicating if this favorite definition is owned by a specific user or is shared between all users with access to the Application Insights component.", + nullable=True, + enum={"shared": "shared", "user": "user"}, + ) + _args_schema.is_generated_from_template = AAZBoolArg( + options=["--is-generated-from-template"], + arg_group="FavoriteProperties", + help="Flag denoting wether or not this favorite was generated from a template.", + nullable=True, + ) + _args_schema.source_type = AAZStrArg( + options=["--source-type"], + arg_group="FavoriteProperties", + help="The source of the favorite definition.", + nullable=True, + ) + _args_schema.tags = AAZListArg( + options=["--tags"], + arg_group="FavoriteProperties", + help="A list of 0 or more tags that are associated with this favorite definition", + nullable=True, + ) + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="FavoriteProperties", + help="This instance's version of the data model. This can change as new features are added that can be marked favorite. Current examples include MetricsExplorer (ME) and Search.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FavoritesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.FavoritesAdd(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class FavoritesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteName}", + **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( + "favoriteName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_application_insights_component_favorite_read(cls._schema_on_200) + + return cls._schema_on_200 + + class FavoritesAdd(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteName}", + **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( + "favoriteName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_application_insights_component_favorite_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("Category", AAZStrType, ".category") + _builder.set_prop("Config", AAZStrType, ".config") + _builder.set_prop("FavoriteId", AAZStrType, ".favorite_id") + _builder.set_prop("FavoriteType", AAZStrType, ".favorite_type") + _builder.set_prop("IsGeneratedFromTemplate", AAZBoolType, ".is_generated_from_template") + _builder.set_prop("Name", AAZStrType, ".name") + _builder.set_prop("SourceType", AAZStrType, ".source_type") + _builder.set_prop("Tags", AAZListType, ".tags") + _builder.set_prop("Version", AAZStrType, ".version") + + tags = _builder.get(".Tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_application_insights_component_favorite_read = None + + @classmethod + def _build_schema_application_insights_component_favorite_read(cls, _schema): + if cls._schema_application_insights_component_favorite_read is not None: + _schema.category = cls._schema_application_insights_component_favorite_read.category + _schema.config = cls._schema_application_insights_component_favorite_read.config + _schema.favorite_id = cls._schema_application_insights_component_favorite_read.favorite_id + _schema.favorite_type = cls._schema_application_insights_component_favorite_read.favorite_type + _schema.is_generated_from_template = cls._schema_application_insights_component_favorite_read.is_generated_from_template + _schema.name = cls._schema_application_insights_component_favorite_read.name + _schema.source_type = cls._schema_application_insights_component_favorite_read.source_type + _schema.tags = cls._schema_application_insights_component_favorite_read.tags + _schema.time_modified = cls._schema_application_insights_component_favorite_read.time_modified + _schema.user_id = cls._schema_application_insights_component_favorite_read.user_id + _schema.version = cls._schema_application_insights_component_favorite_read.version + return + + cls._schema_application_insights_component_favorite_read = _schema_application_insights_component_favorite_read = AAZObjectType() + + application_insights_component_favorite_read = _schema_application_insights_component_favorite_read + application_insights_component_favorite_read.category = AAZStrType( + serialized_name="Category", + ) + application_insights_component_favorite_read.config = AAZStrType( + serialized_name="Config", + ) + application_insights_component_favorite_read.favorite_id = AAZStrType( + serialized_name="FavoriteId", + ) + application_insights_component_favorite_read.favorite_type = AAZStrType( + serialized_name="FavoriteType", + ) + application_insights_component_favorite_read.is_generated_from_template = AAZBoolType( + serialized_name="IsGeneratedFromTemplate", + ) + application_insights_component_favorite_read.name = AAZStrType( + serialized_name="Name", + ) + application_insights_component_favorite_read.source_type = AAZStrType( + serialized_name="SourceType", + ) + application_insights_component_favorite_read.tags = AAZListType( + serialized_name="Tags", + ) + application_insights_component_favorite_read.time_modified = AAZStrType( + serialized_name="TimeModified", + flags={"read_only": True}, + ) + application_insights_component_favorite_read.user_id = AAZStrType( + serialized_name="UserId", + flags={"read_only": True}, + ) + application_insights_component_favorite_read.version = AAZStrType( + serialized_name="Version", + ) + + tags = _schema_application_insights_component_favorite_read.tags + tags.Element = AAZStrType() + + _schema.category = cls._schema_application_insights_component_favorite_read.category + _schema.config = cls._schema_application_insights_component_favorite_read.config + _schema.favorite_id = cls._schema_application_insights_component_favorite_read.favorite_id + _schema.favorite_type = cls._schema_application_insights_component_favorite_read.favorite_type + _schema.is_generated_from_template = cls._schema_application_insights_component_favorite_read.is_generated_from_template + _schema.name = cls._schema_application_insights_component_favorite_read.name + _schema.source_type = cls._schema_application_insights_component_favorite_read.source_type + _schema.tags = cls._schema_application_insights_component_favorite_read.tags + _schema.time_modified = cls._schema_application_insights_component_favorite_read.time_modified + _schema.user_id = cls._schema_application_insights_component_favorite_read.user_id + _schema.version = cls._schema_application_insights_component_favorite_read.version + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/__cmd_group.py new file mode 100644 index 00000000000..bc2499e6d81 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights component linked-storage", +) +class __CMDGroup(AAZCommandGroup): + """Manage linked storage account for an Application Insights component. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/__init__.py new file mode 100644 index 00000000000..e24cbf3fd90 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._link import * +from ._show import * +from ._unlink import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_link.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_link.py new file mode 100644 index 00000000000..ed1c53dadc3 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_link.py @@ -0,0 +1,217 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component linked-storage link", +) +class Link(AAZCommand): + """Link a storage account with an Application Insights component. + """ + + _aaz_info = { + "version": "2020-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/linkedstorageaccounts/{}", "2020-03-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + _args_schema.storage_type = AAZStrArg( + options=["--storage-type"], + help="The type of the Application Insights component data source for the linked storage account.", + required=True, + id_part="child_name_1", + default="ServiceProfiler", + enum={"ServiceProfiler": "ServiceProfiler"}, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.linked_storage_account = AAZStrArg( + options=["--linked-storage-account"], + arg_group="Properties", + help="Linked storage account resource ID", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentLinkedStorageAccountsCreateAndUpdate(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 ComponentLinkedStorageAccountsCreateAndUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "storageType", self.ctx.args.storage_type, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2020-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("linkedStorageAccount", AAZStrType, ".linked_storage_account") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.linked_storage_account = AAZStrType( + serialized_name="linkedStorageAccount", + ) + + return cls._schema_on_200 + + +class _LinkHelper: + """Helper class for Link""" + + +__all__ = ["Link"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_show.py new file mode 100644 index 00000000000..445c7c10190 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_show.py @@ -0,0 +1,190 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component linked-storage show", +) +class Show(AAZCommand): + """Get the current linked storage settings for an Application Insights component. + """ + + _aaz_info = { + "version": "2020-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/linkedstorageaccounts/{}", "2020-03-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + _args_schema.storage_type = AAZStrArg( + options=["--storage-type"], + help="The type of the Application Insights component data source for the linked storage account.", + required=True, + id_part="child_name_1", + default="ServiceProfiler", + enum={"ServiceProfiler": "ServiceProfiler"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentLinkedStorageAccountsGet(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 ComponentLinkedStorageAccountsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "storageType", self.ctx.args.storage_type, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2020-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.linked_storage_account = AAZStrType( + serialized_name="linkedStorageAccount", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_unlink.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_unlink.py new file mode 100644 index 00000000000..eb632f4155f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_unlink.py @@ -0,0 +1,148 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component linked-storage unlink", + confirmation="Are you sure you want to perform this operation?", +) +class Unlink(AAZCommand): + """Unlink a storage account with an Application Insights component. + """ + + _aaz_info = { + "version": "2020-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/linkedstorageaccounts/{}", "2020-03-01-preview"], + ] + } + + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + _args_schema.storage_type = AAZStrArg( + options=["--storage-type"], + help="The type of the Application Insights component data source for the linked storage account.", + required=True, + id_part="child_name_1", + default="ServiceProfiler", + enum={"ServiceProfiler": "ServiceProfiler"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentLinkedStorageAccountsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ComponentLinkedStorageAccountsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "storageType", self.ctx.args.storage_type, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2020-03-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _UnlinkHelper: + """Helper class for Unlink""" + + +__all__ = ["Unlink"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_update.py new file mode 100644 index 00000000000..ee8148c2f1d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/linked_storage/_update.py @@ -0,0 +1,216 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component linked-storage update", +) +class Update(AAZCommand): + """Update current linked storage account for an Application Insights component. + """ + + _aaz_info = { + "version": "2020-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/linkedstorageaccounts/{}", "2020-03-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.app = AAZStrArg( + options=["-a", "--app"], + help="GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.", + required=True, + id_part="name", + ) + _args_schema.storage_type = AAZStrArg( + options=["--storage-type"], + help="The type of the Application Insights component data source for the linked storage account.", + required=True, + id_part="child_name_1", + enum={"ServiceProfiler": "ServiceProfiler"}, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.linked_storage_account = AAZStrArg( + options=["--linked-storage-account"], + arg_group="Properties", + help="Linked storage account resource ID", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentLinkedStorageAccountsUpdate(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 ComponentLinkedStorageAccountsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.app, + required=True, + ), + **self.serialize_url_param( + "storageType", self.ctx.args.storage_type, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2020-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("linkedStorageAccount", AAZStrType, ".linked_storage_account") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.linked_storage_account = AAZStrType( + serialized_name="linkedStorageAccount", + ) + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/__cmd_group.py new file mode 100644 index 00000000000..f7f3bf8d66b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights component quotastatus", +) +class __CMDGroup(AAZCommandGroup): + """Manage component quotastatus + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/__init__.py new file mode 100644 index 00000000000..28d5f355813 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/_show.py new file mode 100644 index 00000000000..39f116be1ab --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/component/quotastatus/_show.py @@ -0,0 +1,176 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights component quotastatus show", +) +class Show(AAZCommand): + """Show daily data volume cap (quota) status for an Application Insights component. + + :example: Show component quotastatus + az monitor app-insights component quotastatus show -g rg --resource-name name + """ + + _aaz_info = { + "version": "2015-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/components/{}/quotastatus", "2015-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ComponentQuotaStatusGet(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 ComponentQuotaStatusGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.app_id = AAZStrType( + serialized_name="AppId", + flags={"read_only": True}, + ) + _schema_on_200.expiration_time = AAZStrType( + serialized_name="ExpirationTime", + flags={"read_only": True}, + ) + _schema_on_200.should_be_throttled = AAZBoolType( + serialized_name="ShouldBeThrottled", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/__cmd_group.py new file mode 100644 index 00000000000..b629778b418 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights events", +) +class __CMDGroup(AAZCommandGroup): + """Manage Event + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/__init__.py new file mode 100644 index 00000000000..28d5f355813 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/_show.py new file mode 100644 index 00000000000..192308b3183 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/events/_show.py @@ -0,0 +1,1002 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights events show", +) +class Show(AAZCommand): + """Get the data for a single event + """ + + _aaz_info = { + "version": "v1", + "resources": [ + ["data-plane:microsoft.insights", "/apps/{}/events/{}", "v1"], + ["data-plane:microsoft.insights", "/apps/{}/events/{}/{}", "v1"], + ] + } + + 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.app_id = AAZStrArg( + options=["--app-id"], + help="ID of the application. This is Application ID from the API Access settings blade in the Azure portal.", + required=True, + ) + _args_schema.event_id = AAZStrArg( + options=["--event-id"], + help="ID of event.", + ) + _args_schema.event_type = AAZStrArg( + options=["--event-type"], + help="The type of events to query; either a standard event type (`traces`, `customEvents`, `pageViews`, `requests`, `dependencies`, `exceptions`, `availabilityResults`) or `$all` to query across all event types.", + required=True, + enum={"$all": "$all", "availabilityResults": "availabilityResults", "browserTimings": "browserTimings", "customEvents": "customEvents", "customMetrics": "customMetrics", "dependencies": "dependencies", "exceptions": "exceptions", "pageViews": "pageViews", "performanceCounters": "performanceCounters", "requests": "requests", "traces": "traces"}, + ) + _args_schema.apply = AAZStrArg( + options=["--apply"], + help="An expression used for aggregation over returned events", + ) + _args_schema.count = AAZBoolArg( + options=["--count"], + help="Request a count of matching items included with the returned events", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="An expression used to filter the returned events", + ) + _args_schema.format = AAZStrArg( + options=["--format"], + help="Format for the returned events", + ) + _args_schema.orderby = AAZStrArg( + options=["--orderby"], + help="A comma-separated list of properties with \\\"asc\\\" (the default) or \\\"desc\\\" to control the order of returned events", + ) + _args_schema.search = AAZStrArg( + options=["--search"], + help="A free-text search expression to match for whether a particular event should be returned", + ) + _args_schema.select = AAZStrArg( + options=["--select"], + help="Limits the properties to just those requested on each returned event", + ) + _args_schema.skip = AAZIntArg( + options=["--skip"], + help="The number of items to skip over before returning events", + ) + _args_schema.timespan = AAZStrArg( + options=["--timespan"], + help="Optional. The timespan over which to retrieve events. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the Odata expression.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The number of events to return", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.app_id) and has_value(self.ctx.args.event_type) and has_value(self.ctx.args.event_id) is not True + condition_1 = has_value(self.ctx.args.app_id) and has_value(self.ctx.args.event_id) and has_value(self.ctx.args.event_type) + if condition_0: + self.EventsGetByType(ctx=self.ctx)() + if condition_1: + self.EventsGet(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 EventsGetByType(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftInsightsDataPlaneClient_monitor" + + def __call__(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( + "/v1/apps/{appId}/events/{eventType}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "appId", self.ctx.args.app_id, + required=True, + ), + **self.serialize_url_param( + "eventType", self.ctx.args.event_type, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$apply", self.ctx.args.apply, + ), + **self.serialize_query_param( + "$count", self.ctx.args.count, + ), + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "$format", self.ctx.args.format, + ), + **self.serialize_query_param( + "$orderby", self.ctx.args.orderby, + ), + **self.serialize_query_param( + "$search", self.ctx.args.search, + ), + **self.serialize_query_param( + "$select", self.ctx.args.select, + ), + **self.serialize_query_param( + "$skip", self.ctx.args.skip, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "timespan", self.ctx.args.timespan, + ), + } + 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["@ai.messages"] = AAZListType() + _schema_on_200["@odata.context"] = AAZStrType() + _schema_on_200.value = AAZListType() + + @ai.messages = cls._schema_on_200.@ai.messages + @ai.messages.Element = AAZFreeFormDictType() + _ShowHelper._build_schema_error_info_read(@ai.messages.Element) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.ai = AAZObjectType() + _element.application = AAZObjectType() + _element.client = AAZObjectType() + _element.cloud = AAZObjectType() + _element.count = AAZIntType() + _element.custom_dimensions = AAZObjectType( + serialized_name="customDimensions", + ) + _element.custom_measurements = AAZObjectType( + serialized_name="customMeasurements", + ) + _element.id = AAZStrType() + _element.operation = AAZObjectType() + _element.session = AAZObjectType() + _element.timestamp = AAZStrType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.user = AAZObjectType() + + ai = cls._schema_on_200.value.Element.ai + ai.app_id = AAZStrType( + serialized_name="appId", + ) + ai.app_name = AAZStrType( + serialized_name="appName", + ) + ai.i_key = AAZStrType( + serialized_name="iKey", + ) + ai.sdk_version = AAZStrType( + serialized_name="sdkVersion", + ) + + application = cls._schema_on_200.value.Element.application + application.version = AAZStrType() + + client = cls._schema_on_200.value.Element.client + client.browser = AAZStrType() + client.city = AAZStrType() + client.country_or_region = AAZStrType( + serialized_name="countryOrRegion", + ) + client.ip = AAZStrType() + client.model = AAZStrType() + client.os = AAZStrType() + client.state_or_province = AAZStrType( + serialized_name="stateOrProvince", + ) + client.type = AAZStrType() + + cloud = cls._schema_on_200.value.Element.cloud + cloud.role_instance = AAZStrType( + serialized_name="roleInstance", + ) + cloud.role_name = AAZStrType( + serialized_name="roleName", + ) + + custom_dimensions = cls._schema_on_200.value.Element.custom_dimensions + custom_dimensions.additional_properties = AAZDictType( + serialized_name="additionalProperties", + ) + + additional_properties = cls._schema_on_200.value.Element.custom_dimensions.additional_properties + additional_properties.Element = AAZAnyType() + + custom_measurements = cls._schema_on_200.value.Element.custom_measurements + custom_measurements.additional_properties = AAZDictType( + serialized_name="additionalProperties", + ) + + additional_properties = cls._schema_on_200.value.Element.custom_measurements.additional_properties + additional_properties.Element = AAZAnyType() + + operation = cls._schema_on_200.value.Element.operation + operation.id = AAZStrType() + operation.name = AAZStrType() + operation.parent_id = AAZStrType( + serialized_name="parentId", + ) + operation.synthetic_source = AAZStrType( + serialized_name="syntheticSource", + ) + + session = cls._schema_on_200.value.Element.session + session.id = AAZStrType() + + user = cls._schema_on_200.value.Element.user + user.account_id = AAZStrType( + serialized_name="accountId", + ) + user.authenticated_id = AAZStrType( + serialized_name="authenticatedId", + ) + user.id = AAZStrType() + + disc_availability_result = cls._schema_on_200.value.Element.discriminate_by("type", "availabilityResult") + disc_availability_result.availability_result = AAZObjectType( + serialized_name="availabilityResult", + ) + + availability_result = cls._schema_on_200.value.Element.discriminate_by("type", "availabilityResult").availability_result + availability_result.duration = AAZIntType() + availability_result.id = AAZStrType() + availability_result.location = AAZStrType() + availability_result.message = AAZStrType() + availability_result.name = AAZStrType() + availability_result.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + availability_result.size = AAZStrType() + availability_result.success = AAZStrType() + + disc_browser_timing = cls._schema_on_200.value.Element.discriminate_by("type", "browserTiming") + disc_browser_timing.browser_timing = AAZObjectType( + serialized_name="browserTiming", + ) + disc_browser_timing.client_performance = AAZObjectType( + serialized_name="clientPerformance", + ) + + browser_timing = cls._schema_on_200.value.Element.discriminate_by("type", "browserTiming").browser_timing + browser_timing.name = AAZStrType() + browser_timing.network_duration = AAZIntType( + serialized_name="networkDuration", + ) + browser_timing.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + browser_timing.processing_duration = AAZIntType( + serialized_name="processingDuration", + ) + browser_timing.receive_duration = AAZIntType( + serialized_name="receiveDuration", + ) + browser_timing.send_duration = AAZIntType( + serialized_name="sendDuration", + ) + browser_timing.total_duration = AAZIntType( + serialized_name="totalDuration", + ) + browser_timing.url = AAZStrType() + browser_timing.url_host = AAZStrType( + serialized_name="urlHost", + ) + browser_timing.url_path = AAZStrType( + serialized_name="urlPath", + ) + + client_performance = cls._schema_on_200.value.Element.discriminate_by("type", "browserTiming").client_performance + client_performance.name = AAZStrType() + + disc_custom_event = cls._schema_on_200.value.Element.discriminate_by("type", "customEvent") + disc_custom_event.custom_event = AAZObjectType( + serialized_name="customEvent", + ) + + custom_event = cls._schema_on_200.value.Element.discriminate_by("type", "customEvent").custom_event + custom_event.name = AAZStrType() + + disc_custom_metric = cls._schema_on_200.value.Element.discriminate_by("type", "customMetric") + disc_custom_metric.custom_metric = AAZObjectType( + serialized_name="customMetric", + ) + + custom_metric = cls._schema_on_200.value.Element.discriminate_by("type", "customMetric").custom_metric + custom_metric.name = AAZStrType() + custom_metric.value = AAZFloatType() + custom_metric.value_count = AAZIntType( + serialized_name="valueCount", + ) + custom_metric.value_max = AAZFloatType( + serialized_name="valueMax", + ) + custom_metric.value_min = AAZFloatType( + serialized_name="valueMin", + ) + custom_metric.value_std_dev = AAZFloatType( + serialized_name="valueStdDev", + ) + custom_metric.value_sum = AAZFloatType( + serialized_name="valueSum", + ) + + disc_dependency = cls._schema_on_200.value.Element.discriminate_by("type", "dependency") + disc_dependency.dependency = AAZObjectType() + + dependency = cls._schema_on_200.value.Element.discriminate_by("type", "dependency").dependency + dependency.data = AAZStrType() + dependency.duration = AAZIntType() + dependency.id = AAZStrType() + dependency.name = AAZStrType() + dependency.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + dependency.result_code = AAZStrType( + serialized_name="resultCode", + ) + dependency.success = AAZStrType() + dependency.target = AAZStrType() + dependency.type = AAZStrType() + + disc_exception = cls._schema_on_200.value.Element.discriminate_by("type", "exception") + disc_exception.exception = AAZObjectType() + + exception = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception + exception.assembly = AAZStrType() + exception.details = AAZListType() + exception.handled_at = AAZStrType( + serialized_name="handledAt", + ) + exception.innermost_assembly = AAZStrType( + serialized_name="innermostAssembly", + ) + exception.innermost_message = AAZStrType( + serialized_name="innermostMessage", + ) + exception.innermost_method = AAZStrType( + serialized_name="innermostMethod", + ) + exception.innermost_type = AAZStrType( + serialized_name="innermostType", + ) + exception.message = AAZStrType() + exception.method = AAZStrType() + exception.outer_assembly = AAZStrType( + serialized_name="outerAssembly", + ) + exception.outer_message = AAZStrType( + serialized_name="outerMessage", + ) + exception.outer_method = AAZStrType( + serialized_name="outerMethod", + ) + exception.outer_type = AAZStrType( + serialized_name="outerType", + ) + exception.problem_id = AAZStrType( + serialized_name="problemId", + ) + exception.severity_level = AAZIntType( + serialized_name="severityLevel", + ) + exception.type = AAZStrType() + + details = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details + details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details.Element + _element.id = AAZStrType() + _element.message = AAZStrType() + _element.outer_id = AAZStrType( + serialized_name="outerId", + ) + _element.parsed_stack = AAZListType( + serialized_name="parsedStack", + ) + _element.severity_level = AAZStrType( + serialized_name="severityLevel", + ) + _element.type = AAZStrType() + + parsed_stack = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details.Element.parsed_stack + parsed_stack.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details.Element.parsed_stack.Element + _element.assembly = AAZStrType() + _element.level = AAZIntType() + _element.line = AAZIntType() + _element.method = AAZStrType() + + disc_page_view = cls._schema_on_200.value.Element.discriminate_by("type", "pageView") + disc_page_view.page_view = AAZObjectType( + serialized_name="pageView", + ) + + page_view = cls._schema_on_200.value.Element.discriminate_by("type", "pageView").page_view + page_view.duration = AAZStrType() + page_view.name = AAZStrType() + page_view.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + page_view.url = AAZStrType() + + disc_performance_counter = cls._schema_on_200.value.Element.discriminate_by("type", "performanceCounter") + disc_performance_counter.performance_counter = AAZObjectType( + serialized_name="performanceCounter", + ) + + performance_counter = cls._schema_on_200.value.Element.discriminate_by("type", "performanceCounter").performance_counter + performance_counter.category = AAZStrType() + performance_counter.counter = AAZStrType() + performance_counter.instance = AAZStrType() + performance_counter.instance_name = AAZStrType( + serialized_name="instanceName", + ) + performance_counter.name = AAZStrType() + performance_counter.value = AAZFloatType() + + disc_request = cls._schema_on_200.value.Element.discriminate_by("type", "request") + disc_request.request = AAZObjectType() + + request = cls._schema_on_200.value.Element.discriminate_by("type", "request").request + request.duration = AAZFloatType() + request.id = AAZStrType() + request.name = AAZStrType() + request.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + request.result_code = AAZStrType( + serialized_name="resultCode", + ) + request.source = AAZStrType() + request.success = AAZStrType() + request.url = AAZStrType() + + disc_trace = cls._schema_on_200.value.Element.discriminate_by("type", "trace") + disc_trace.trace = AAZObjectType() + + trace = cls._schema_on_200.value.Element.discriminate_by("type", "trace").trace + trace.message = AAZStrType() + trace.severity_level = AAZIntType( + serialized_name="severityLevel", + ) + + return cls._schema_on_200 + + class EventsGet(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftInsightsDataPlaneClient_monitor" + + def __call__(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( + "/v1/apps/{appId}/events/{eventType}/{eventId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "appId", self.ctx.args.app_id, + required=True, + ), + **self.serialize_url_param( + "eventId", self.ctx.args.event_id, + required=True, + ), + **self.serialize_url_param( + "eventType", self.ctx.args.event_type, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "timespan", self.ctx.args.timespan, + ), + } + 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["@ai.messages"] = AAZListType() + _schema_on_200["@odata.context"] = AAZStrType() + _schema_on_200.value = AAZListType() + + @ai.messages = cls._schema_on_200.@ai.messages + @ai.messages.Element = AAZFreeFormDictType() + _ShowHelper._build_schema_error_info_read(@ai.messages.Element) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.ai = AAZObjectType() + _element.application = AAZObjectType() + _element.client = AAZObjectType() + _element.cloud = AAZObjectType() + _element.count = AAZIntType() + _element.custom_dimensions = AAZObjectType( + serialized_name="customDimensions", + ) + _element.custom_measurements = AAZObjectType( + serialized_name="customMeasurements", + ) + _element.id = AAZStrType() + _element.operation = AAZObjectType() + _element.session = AAZObjectType() + _element.timestamp = AAZStrType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.user = AAZObjectType() + + ai = cls._schema_on_200.value.Element.ai + ai.app_id = AAZStrType( + serialized_name="appId", + ) + ai.app_name = AAZStrType( + serialized_name="appName", + ) + ai.i_key = AAZStrType( + serialized_name="iKey", + ) + ai.sdk_version = AAZStrType( + serialized_name="sdkVersion", + ) + + application = cls._schema_on_200.value.Element.application + application.version = AAZStrType() + + client = cls._schema_on_200.value.Element.client + client.browser = AAZStrType() + client.city = AAZStrType() + client.country_or_region = AAZStrType( + serialized_name="countryOrRegion", + ) + client.ip = AAZStrType() + client.model = AAZStrType() + client.os = AAZStrType() + client.state_or_province = AAZStrType( + serialized_name="stateOrProvince", + ) + client.type = AAZStrType() + + cloud = cls._schema_on_200.value.Element.cloud + cloud.role_instance = AAZStrType( + serialized_name="roleInstance", + ) + cloud.role_name = AAZStrType( + serialized_name="roleName", + ) + + custom_dimensions = cls._schema_on_200.value.Element.custom_dimensions + custom_dimensions.additional_properties = AAZDictType( + serialized_name="additionalProperties", + ) + + additional_properties = cls._schema_on_200.value.Element.custom_dimensions.additional_properties + additional_properties.Element = AAZAnyType() + + custom_measurements = cls._schema_on_200.value.Element.custom_measurements + custom_measurements.additional_properties = AAZDictType( + serialized_name="additionalProperties", + ) + + additional_properties = cls._schema_on_200.value.Element.custom_measurements.additional_properties + additional_properties.Element = AAZAnyType() + + operation = cls._schema_on_200.value.Element.operation + operation.id = AAZStrType() + operation.name = AAZStrType() + operation.parent_id = AAZStrType( + serialized_name="parentId", + ) + operation.synthetic_source = AAZStrType( + serialized_name="syntheticSource", + ) + + session = cls._schema_on_200.value.Element.session + session.id = AAZStrType() + + user = cls._schema_on_200.value.Element.user + user.account_id = AAZStrType( + serialized_name="accountId", + ) + user.authenticated_id = AAZStrType( + serialized_name="authenticatedId", + ) + user.id = AAZStrType() + + disc_availability_result = cls._schema_on_200.value.Element.discriminate_by("type", "availabilityResult") + disc_availability_result.availability_result = AAZObjectType( + serialized_name="availabilityResult", + ) + + availability_result = cls._schema_on_200.value.Element.discriminate_by("type", "availabilityResult").availability_result + availability_result.duration = AAZIntType() + availability_result.id = AAZStrType() + availability_result.location = AAZStrType() + availability_result.message = AAZStrType() + availability_result.name = AAZStrType() + availability_result.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + availability_result.size = AAZStrType() + availability_result.success = AAZStrType() + + disc_browser_timing = cls._schema_on_200.value.Element.discriminate_by("type", "browserTiming") + disc_browser_timing.browser_timing = AAZObjectType( + serialized_name="browserTiming", + ) + disc_browser_timing.client_performance = AAZObjectType( + serialized_name="clientPerformance", + ) + + browser_timing = cls._schema_on_200.value.Element.discriminate_by("type", "browserTiming").browser_timing + browser_timing.name = AAZStrType() + browser_timing.network_duration = AAZIntType( + serialized_name="networkDuration", + ) + browser_timing.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + browser_timing.processing_duration = AAZIntType( + serialized_name="processingDuration", + ) + browser_timing.receive_duration = AAZIntType( + serialized_name="receiveDuration", + ) + browser_timing.send_duration = AAZIntType( + serialized_name="sendDuration", + ) + browser_timing.total_duration = AAZIntType( + serialized_name="totalDuration", + ) + browser_timing.url = AAZStrType() + browser_timing.url_host = AAZStrType( + serialized_name="urlHost", + ) + browser_timing.url_path = AAZStrType( + serialized_name="urlPath", + ) + + client_performance = cls._schema_on_200.value.Element.discriminate_by("type", "browserTiming").client_performance + client_performance.name = AAZStrType() + + disc_custom_event = cls._schema_on_200.value.Element.discriminate_by("type", "customEvent") + disc_custom_event.custom_event = AAZObjectType( + serialized_name="customEvent", + ) + + custom_event = cls._schema_on_200.value.Element.discriminate_by("type", "customEvent").custom_event + custom_event.name = AAZStrType() + + disc_custom_metric = cls._schema_on_200.value.Element.discriminate_by("type", "customMetric") + disc_custom_metric.custom_metric = AAZObjectType( + serialized_name="customMetric", + ) + + custom_metric = cls._schema_on_200.value.Element.discriminate_by("type", "customMetric").custom_metric + custom_metric.name = AAZStrType() + custom_metric.value = AAZFloatType() + custom_metric.value_count = AAZIntType( + serialized_name="valueCount", + ) + custom_metric.value_max = AAZFloatType( + serialized_name="valueMax", + ) + custom_metric.value_min = AAZFloatType( + serialized_name="valueMin", + ) + custom_metric.value_std_dev = AAZFloatType( + serialized_name="valueStdDev", + ) + custom_metric.value_sum = AAZFloatType( + serialized_name="valueSum", + ) + + disc_dependency = cls._schema_on_200.value.Element.discriminate_by("type", "dependency") + disc_dependency.dependency = AAZObjectType() + + dependency = cls._schema_on_200.value.Element.discriminate_by("type", "dependency").dependency + dependency.data = AAZStrType() + dependency.duration = AAZIntType() + dependency.id = AAZStrType() + dependency.name = AAZStrType() + dependency.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + dependency.result_code = AAZStrType( + serialized_name="resultCode", + ) + dependency.success = AAZStrType() + dependency.target = AAZStrType() + dependency.type = AAZStrType() + + disc_exception = cls._schema_on_200.value.Element.discriminate_by("type", "exception") + disc_exception.exception = AAZObjectType() + + exception = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception + exception.assembly = AAZStrType() + exception.details = AAZListType() + exception.handled_at = AAZStrType( + serialized_name="handledAt", + ) + exception.innermost_assembly = AAZStrType( + serialized_name="innermostAssembly", + ) + exception.innermost_message = AAZStrType( + serialized_name="innermostMessage", + ) + exception.innermost_method = AAZStrType( + serialized_name="innermostMethod", + ) + exception.innermost_type = AAZStrType( + serialized_name="innermostType", + ) + exception.message = AAZStrType() + exception.method = AAZStrType() + exception.outer_assembly = AAZStrType( + serialized_name="outerAssembly", + ) + exception.outer_message = AAZStrType( + serialized_name="outerMessage", + ) + exception.outer_method = AAZStrType( + serialized_name="outerMethod", + ) + exception.outer_type = AAZStrType( + serialized_name="outerType", + ) + exception.problem_id = AAZStrType( + serialized_name="problemId", + ) + exception.severity_level = AAZIntType( + serialized_name="severityLevel", + ) + exception.type = AAZStrType() + + details = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details + details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details.Element + _element.id = AAZStrType() + _element.message = AAZStrType() + _element.outer_id = AAZStrType( + serialized_name="outerId", + ) + _element.parsed_stack = AAZListType( + serialized_name="parsedStack", + ) + _element.severity_level = AAZStrType( + serialized_name="severityLevel", + ) + _element.type = AAZStrType() + + parsed_stack = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details.Element.parsed_stack + parsed_stack.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.discriminate_by("type", "exception").exception.details.Element.parsed_stack.Element + _element.assembly = AAZStrType() + _element.level = AAZIntType() + _element.line = AAZIntType() + _element.method = AAZStrType() + + disc_page_view = cls._schema_on_200.value.Element.discriminate_by("type", "pageView") + disc_page_view.page_view = AAZObjectType( + serialized_name="pageView", + ) + + page_view = cls._schema_on_200.value.Element.discriminate_by("type", "pageView").page_view + page_view.duration = AAZStrType() + page_view.name = AAZStrType() + page_view.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + page_view.url = AAZStrType() + + disc_performance_counter = cls._schema_on_200.value.Element.discriminate_by("type", "performanceCounter") + disc_performance_counter.performance_counter = AAZObjectType( + serialized_name="performanceCounter", + ) + + performance_counter = cls._schema_on_200.value.Element.discriminate_by("type", "performanceCounter").performance_counter + performance_counter.category = AAZStrType() + performance_counter.counter = AAZStrType() + performance_counter.instance = AAZStrType() + performance_counter.instance_name = AAZStrType( + serialized_name="instanceName", + ) + performance_counter.name = AAZStrType() + performance_counter.value = AAZFloatType() + + disc_request = cls._schema_on_200.value.Element.discriminate_by("type", "request") + disc_request.request = AAZObjectType() + + request = cls._schema_on_200.value.Element.discriminate_by("type", "request").request + request.duration = AAZFloatType() + request.id = AAZStrType() + request.name = AAZStrType() + request.performance_bucket = AAZStrType( + serialized_name="performanceBucket", + ) + request.result_code = AAZStrType( + serialized_name="resultCode", + ) + request.source = AAZStrType() + request.success = AAZStrType() + request.url = AAZStrType() + + disc_trace = cls._schema_on_200.value.Element.discriminate_by("type", "trace") + disc_trace.trace = AAZObjectType() + + trace = cls._schema_on_200.value.Element.discriminate_by("type", "trace").trace + trace.message = AAZStrType() + trace.severity_level = AAZIntType( + serialized_name="severityLevel", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_error_info_read = None + + @classmethod + def _build_schema_error_info_read(cls, _schema): + if cls._schema_error_info_read is not None: + return + + cls._schema_error_info_read = _schema_error_info_read = AAZFreeFormDictType() + + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/__cmd_group.py new file mode 100644 index 00000000000..0787f439b9b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights metric", +) +class __CMDGroup(AAZCommandGroup): + """Manage Metric + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/__init__.py new file mode 100644 index 00000000000..406f79dcdaf --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._get_metadata import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/_get_metadata.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/_get_metadata.py new file mode 100644 index 00000000000..d444d183031 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/_get_metadata.py @@ -0,0 +1,140 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights metric get-metadata", +) +class GetMetadata(AAZCommand): + """Get metadata describing the available metrics + """ + + _aaz_info = { + "version": "v1", + "resources": [ + ["data-plane:microsoft.insights", "/apps/{}/metrics/metadata", "v1"], + ] + } + + 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.app_id = AAZStrArg( + options=["--app-id"], + help="ID of the application. This is Application ID from the API Access settings blade in the Azure portal.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricsGetMetadata(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 MetricsGetMetadata(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftInsightsDataPlaneClient_monitor" + + def __call__(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( + "/v1/apps/{appId}/metrics/metadata", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "appId", self.ctx.args.app_id, + 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 = AAZDictType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.Element = AAZAnyType() + + return cls._schema_on_200 + + +class _GetMetadataHelper: + """Helper class for GetMetadata""" + + +__all__ = ["GetMetadata"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/_show.py new file mode 100644 index 00000000000..b4d186b24ce --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/metric/_show.py @@ -0,0 +1,231 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights metric show", +) +class Show(AAZCommand): + """Get metric values for a single metric + """ + + _aaz_info = { + "version": "v1", + "resources": [ + ["data-plane:microsoft.insights", "/apps/{}/metrics/{}", "v1"], + ] + } + + 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.app_id = AAZStrArg( + options=["--app-id"], + help="ID of the application. This is Application ID from the API Access settings blade in the Azure portal.", + required=True, + ) + _args_schema.metric_id = AAZStrArg( + options=["--metric-id"], + help="ID of the metric. This is either a standard AI metric, or an application-specific custom metric.", + required=True, + enum={"availabilityResults/availabilityPercentage": "availabilityResults/availabilityPercentage", "availabilityResults/duration": "availabilityResults/duration", "billing/telemetryCount": "billing/telemetryCount", "client/networkDuration": "client/networkDuration", "client/processingDuration": "client/processingDuration", "client/receiveDuration": "client/receiveDuration", "client/sendDuration": "client/sendDuration", "client/totalDuration": "client/totalDuration", "customEvents/count": "customEvents/count", "dependencies/count": "dependencies/count", "dependencies/duration": "dependencies/duration", "dependencies/failed": "dependencies/failed", "exceptions/browser": "exceptions/browser", "exceptions/count": "exceptions/count", "exceptions/server": "exceptions/server", "pageViews/count": "pageViews/count", "pageViews/duration": "pageViews/duration", "performanceCounters/exceptionsPerSecond": "performanceCounters/exceptionsPerSecond", "performanceCounters/memoryAvailableBytes": "performanceCounters/memoryAvailableBytes", "performanceCounters/processCpuPercentage": "performanceCounters/processCpuPercentage", "performanceCounters/processIOBytesPerSecond": "performanceCounters/processIOBytesPerSecond", "performanceCounters/processPrivateBytes": "performanceCounters/processPrivateBytes", "performanceCounters/processorCpuPercentage": "performanceCounters/processorCpuPercentage", "performanceCounters/requestExecutionTime": "performanceCounters/requestExecutionTime", "performanceCounters/requestsInQueue": "performanceCounters/requestsInQueue", "performanceCounters/requestsPerSecond": "performanceCounters/requestsPerSecond", "requests/count": "requests/count", "requests/duration": "requests/duration", "requests/failed": "requests/failed", "sessions/count": "sessions/count", "users/authenticated": "users/authenticated", "users/count": "users/count"}, + ) + _args_schema.aggregation = AAZListArg( + options=["--aggregation"], + help="The aggregation to use when computing the metric values. To retrieve more than one aggregation at a time, separate them with a comma. If no aggregation is specified, then the default aggregation for the metric is used.", + fmt=AAZListArgFormat( + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="An expression used to filter the results. This value should be a valid OData filter expression where the keys of each clause should be applicable dimensions for the metric you are retrieving.", + ) + _args_schema.interval = AAZDurationArg( + options=["--interval"], + help="The time interval to use when retrieving metric values. This is an ISO8601 duration. If interval is omitted, the metric value is aggregated across the entire timespan. If interval is supplied, the server may adjust the interval to a more appropriate size based on the timespan used for the query. In all cases, the actual interval used for the query is included in the response.", + ) + _args_schema.orderby = AAZStrArg( + options=["--orderby"], + help="The aggregation function and direction to sort the segments by. This value is only valid when segment is specified.", + ) + _args_schema.segment = AAZListArg( + options=["--segment"], + help="The name of the dimension to segment the metric values by. This dimension must be applicable to the metric you are retrieving. To segment by more than one dimension at a time, separate them with a comma (,). In this case, the metric data will be segmented in the order the dimensions are listed in the parameter.", + fmt=AAZListArgFormat( + min_length=1, + ), + ) + _args_schema.timespan = AAZStrArg( + options=["--timespan"], + help="The timespan over which to retrieve metric values. This is an ISO8601 time period value. If timespan is omitted, a default time range of `PT12H` (\"last 12 hours\") is used. The actual timespan that is queried may be adjusted by the server based. In all cases, the actual time span used for the query is included in the response.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The number of segments to return. This value is only valid when segment is specified.", + ) + + aggregation = cls._args_schema.aggregation + aggregation.Element = AAZStrArg( + enum={"avg": "avg", "count": "count", "max": "max", "min": "min", "sum": "sum", "unique": "unique"}, + ) + + segment = cls._args_schema.segment + segment.Element = AAZStrArg( + enum={"applicationBuild": "applicationBuild", "applicationVersion": "applicationVersion", "authenticatedOrAnonymousTraffic": "authenticatedOrAnonymousTraffic", "browser": "browser", "browserVersion": "browserVersion", "city": "city", "cloudRoleName": "cloudRoleName", "cloudServiceName": "cloudServiceName", "continent": "continent", "countryOrRegion": "countryOrRegion", "deploymentId": "deploymentId", "deploymentUnit": "deploymentUnit", "deviceType": "deviceType", "environment": "environment", "hostingLocation": "hostingLocation", "instanceName": "instanceName"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricsGet(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 MetricsGet(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftInsightsDataPlaneClient_monitor" + + def __call__(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( + "/v1/apps/{appId}/metrics/{metricId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "appId", self.ctx.args.app_id, + required=True, + ), + **self.serialize_url_param( + "metricId", self.ctx.args.metric_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "aggregation", self.ctx.args.aggregation, + ), + **self.serialize_query_param( + "filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "interval", self.ctx.args.interval, + ), + **self.serialize_query_param( + "orderby", self.ctx.args.orderby, + ), + **self.serialize_query_param( + "segment", self.ctx.args.segment, + ), + **self.serialize_query_param( + "timespan", self.ctx.args.timespan, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + } + 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.value = AAZFreeFormDictType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_metrics_segment_info_read = None + + @classmethod + def _build_schema_metrics_segment_info_read(cls, _schema): + if cls._schema_metrics_segment_info_read is not None: + return + + cls._schema_metrics_segment_info_read = _schema_metrics_segment_info_read = AAZFreeFormDictType() + + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/__cmd_group.py new file mode 100644 index 00000000000..38020c3dee9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights my-workbook", +) +class __CMDGroup(AAZCommandGroup): + """Manage my-workbook + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_create.py new file mode 100644 index 00000000000..e0d56bb6428 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_create.py @@ -0,0 +1,373 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights my-workbook create", +) +class Create(AAZCommand): + """Create a new private workbook. + """ + + _aaz_info = { + "version": "2021-03-08", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/myworkbooks/{}", "2021-03-08"], + ] + } + + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="Properties", + help="Workbook category, as defined by the user at creation time.", + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The user-defined name of the private workbook.", + ) + _args_schema.serialized_data = AAZStrArg( + options=["--serialized-data"], + arg_group="Properties", + help="Configuration of this particular private workbook. Configuration data is a string containing valid JSON", + nullable=True, + ) + _args_schema.storage_uri = AAZStrArg( + options=["--storage-uri"], + arg_group="Properties", + help="BYOS Storage Account URI", + nullable=True, + ) + _args_schema.tags = AAZListArg( + options=["--tags"], + arg_group="Properties", + help="A list of 0 or more tags that are associated with this private workbook definition", + ) + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="Properties", + help="This instance's version of the data model. This can change as new features are added that can be marked private workbook.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "WorkbookProperties" + + _args_schema = cls._args_schema + _args_schema.etag = AAZDictArg( + options=["--etag"], + arg_group="WorkbookProperties", + help="Resource etag", + ) + _args_schema.identity = AAZObjectArg( + options=["--identity"], + arg_group="WorkbookProperties", + help="Identity used for BYOS", + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="WorkbookProperties", + help="The kind of workbook. Choices are user and shared.", + enum={"shared": "shared", "user": "user"}, + ) + _args_schema.location = AAZResourceLocationArg( + arg_group="WorkbookProperties", + help="Resource location", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.type = AAZStrArg( + options=["--type"], + arg_group="WorkbookProperties", + help="Azure resource type", + ) + + etag = cls._args_schema.etag + etag.Element = AAZStrArg() + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="The identity type.", + enum={"None": "None", "UserAssigned": "UserAssigned"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MyWorkbooksCreateOrUpdate(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 MyWorkbooksCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "api-version", "2021-03-08", + 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("etag", AAZDictType, ".etag") + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("location", AAZStrType, ".location") + _builder.set_prop("name", AAZStrType, ".resource_name") + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("type", AAZStrType, ".type") + + etag = _builder.get(".etag") + if etag is not None: + etag.set_elements(AAZStrType, ".") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("category", AAZStrType, ".category", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("displayName", AAZStrType, ".display_name", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("serializedData", AAZStrType, ".serialized_data", typ_kwargs={"flags": {"required": True}, "nullable": True}) + properties.set_prop("storageUri", AAZStrType, ".storage_uri", typ_kwargs={"nullable": True}) + properties.set_prop("tags", AAZListType, ".tags") + properties.set_prop("version", AAZStrType, ".version") + + tags = _builder.get(".properties.tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.etag = AAZDictType() + _schema_on_200_201.id = AAZStrType() + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.kind = AAZStrType() + _schema_on_200_201.location = AAZStrType() + _schema_on_200_201.name = AAZStrType() + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType() + + etag = cls._schema_on_200_201.etag + etag.Element = AAZStrType() + + identity = cls._schema_on_200_201.identity + identity.type = AAZStrType() + identity.user_assigned_identities = AAZObjectType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + user_assigned_identities.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.tags = AAZListType() + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + tags = cls._schema_on_200_201.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_delete.py new file mode 100644 index 00000000000..89cbbb9318a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_delete.py @@ -0,0 +1,136 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights my-workbook delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a private workbook. + """ + + _aaz_info = { + "version": "2021-03-08", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/myworkbooks/{}", "2021-03-08"], + ] + } + + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MyWorkbooksDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class MyWorkbooksDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2021-03-08", + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_list.py new file mode 100644 index 00000000000..6fb8efe7d75 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_list.py @@ -0,0 +1,470 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights my-workbook list", +) +class List(AAZCommand): + """List all private workbooks defined within a specified subscription and category. + + :example: List my workbook + az monitor app-insights my-workbook list -g rg --category retention + """ + + _aaz_info = { + "version": "2021-03-08", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/myworkbooks", "2021-03-08"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/myworkbooks", "2021-03-08"], + ] + } + + 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.resource_group = AAZResourceGroupNameArg() + _args_schema.can_fetch_content = AAZBoolArg( + options=["--can-fetch-content"], + help="Flag indicating whether or not to return the full content for each applicable workbook. If false, only return summary content for workbooks.", + ) + _args_schema.category = AAZStrArg( + options=["--category"], + help="Category of workbook to return.", + required=True, + enum={"TSG": "TSG", "performance": "performance", "retention": "retention", "workbook": "workbook"}, + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + _args_schema.tags = AAZListArg( + options=["--tags"], + help="Tags presents on each workbook returned.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) and has_value(self.ctx.args.category) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.category) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.MyWorkbooksListByResourceGroup(ctx=self.ctx)() + if condition_1: + self.MyWorkbooksListBySubscription(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 MyWorkbooksListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "canFetchContent", self.ctx.args.can_fetch_content, + ), + **self.serialize_query_param( + "category", self.ctx.args.category, + required=True, + ), + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "tags", self.ctx.args.tags, + ), + **self.serialize_query_param( + "api-version", "2021-03-08", + 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={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZDictType() + _element.id = AAZStrType() + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType() + _element.name = AAZStrType() + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType() + + etag = cls._schema_on_200.value.Element.etag + etag.Element = AAZStrType() + + identity = cls._schema_on_200.value.Element.identity + identity.type = AAZStrType() + identity.user_assigned_identities = AAZObjectType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + user_assigned_identities.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.tags = AAZListType() + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + tags = cls._schema_on_200.value.Element.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + class MyWorkbooksListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "canFetchContent", self.ctx.args.can_fetch_content, + ), + **self.serialize_query_param( + "category", self.ctx.args.category, + required=True, + ), + **self.serialize_query_param( + "tags", self.ctx.args.tags, + ), + **self.serialize_query_param( + "api-version", "2021-03-08", + 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={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZDictType() + _element.id = AAZStrType() + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType() + _element.name = AAZStrType() + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType() + + etag = cls._schema_on_200.value.Element.etag + etag.Element = AAZStrType() + + identity = cls._schema_on_200.value.Element.identity + identity.type = AAZStrType() + identity.user_assigned_identities = AAZObjectType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + user_assigned_identities.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.tags = AAZListType() + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + tags = cls._schema_on_200.value.Element.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_show.py new file mode 100644 index 00000000000..7d761e10192 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_show.py @@ -0,0 +1,245 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights my-workbook show", +) +class Show(AAZCommand): + """Get a single private workbook by its resourceName. + """ + + _aaz_info = { + "version": "2021-03-08", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/myworkbooks/{}", "2021-03-08"], + ] + } + + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MyWorkbooksGet(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 MyWorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2021-03-08", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZDictType() + _schema_on_200.id = AAZStrType() + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.kind = AAZStrType() + _schema_on_200.location = AAZStrType() + _schema_on_200.name = AAZStrType() + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType() + + etag = cls._schema_on_200.etag + etag.Element = AAZStrType() + + identity = cls._schema_on_200.identity + identity.type = AAZStrType() + identity.user_assigned_identities = AAZObjectType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + user_assigned_identities.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.tags = AAZListType() + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_update.py new file mode 100644 index 00000000000..296ff8d1394 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/my_workbook/_update.py @@ -0,0 +1,517 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights my-workbook update", +) +class Update(AAZCommand): + """Update a private workbook. + """ + + _aaz_info = { + "version": "2021-03-08", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/myworkbooks/{}", "2021-03-08"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the Application Insights component resource.", + required=True, + id_part="name", + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="Properties", + help="Workbook category, as defined by the user at creation time.", + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The user-defined name of the private workbook.", + ) + _args_schema.serialized_data = AAZStrArg( + options=["--serialized-data"], + arg_group="Properties", + help="Configuration of this particular private workbook. Configuration data is a string containing valid JSON", + nullable=True, + ) + _args_schema.storage_uri = AAZStrArg( + options=["--storage-uri"], + arg_group="Properties", + help="BYOS Storage Account URI", + nullable=True, + ) + _args_schema.tags = AAZListArg( + options=["--tags"], + arg_group="Properties", + help="A list of 0 or more tags that are associated with this private workbook definition", + nullable=True, + ) + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="Properties", + help="This instance's version of the data model. This can change as new features are added that can be marked private workbook.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "WorkbookProperties" + + _args_schema = cls._args_schema + _args_schema.etag = AAZDictArg( + options=["--etag"], + arg_group="WorkbookProperties", + help="Resource etag", + nullable=True, + ) + _args_schema.identity = AAZObjectArg( + options=["--identity"], + arg_group="WorkbookProperties", + help="Identity used for BYOS", + nullable=True, + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="WorkbookProperties", + help="The kind of workbook. Choices are user and shared.", + nullable=True, + enum={"shared": "shared", "user": "user"}, + ) + + etag = cls._args_schema.etag + etag.Element = AAZStrArg( + nullable=True, + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="The identity type.", + nullable=True, + enum={"None": "None", "UserAssigned": "UserAssigned"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MyWorkbooksGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.MyWorkbooksCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class MyWorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2021-03-08", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_my_workbook_read(cls._schema_on_200) + + return cls._schema_on_200 + + class MyWorkbooksCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "api-version", "2021-03-08", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_my_workbook_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("etag", AAZDictType, ".etag") + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + etag = _builder.get(".etag") + if etag is not None: + etag.set_elements(AAZStrType, ".") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("category", AAZStrType, ".category", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("displayName", AAZStrType, ".display_name", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("serializedData", AAZStrType, ".serialized_data", typ_kwargs={"flags": {"required": True}, "nullable": True}) + properties.set_prop("storageUri", AAZStrType, ".storage_uri", typ_kwargs={"nullable": True}) + properties.set_prop("tags", AAZListType, ".tags") + properties.set_prop("version", AAZStrType, ".version") + + tags = _builder.get(".properties.tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_my_workbook_read = None + + @classmethod + def _build_schema_my_workbook_read(cls, _schema): + if cls._schema_my_workbook_read is not None: + _schema.etag = cls._schema_my_workbook_read.etag + _schema.id = cls._schema_my_workbook_read.id + _schema.identity = cls._schema_my_workbook_read.identity + _schema.kind = cls._schema_my_workbook_read.kind + _schema.location = cls._schema_my_workbook_read.location + _schema.name = cls._schema_my_workbook_read.name + _schema.properties = cls._schema_my_workbook_read.properties + _schema.system_data = cls._schema_my_workbook_read.system_data + _schema.type = cls._schema_my_workbook_read.type + return + + cls._schema_my_workbook_read = _schema_my_workbook_read = AAZObjectType() + + my_workbook_read = _schema_my_workbook_read + my_workbook_read.etag = AAZDictType() + my_workbook_read.id = AAZStrType() + my_workbook_read.identity = AAZIdentityObjectType() + my_workbook_read.kind = AAZStrType() + my_workbook_read.location = AAZStrType() + my_workbook_read.name = AAZStrType() + my_workbook_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + my_workbook_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + my_workbook_read.type = AAZStrType() + + etag = _schema_my_workbook_read.etag + etag.Element = AAZStrType() + + identity = _schema_my_workbook_read.identity + identity.type = AAZStrType() + identity.user_assigned_identities = AAZObjectType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_my_workbook_read.identity.user_assigned_identities + user_assigned_identities.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + user_assigned_identities.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + + properties = _schema_my_workbook_read.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.tags = AAZListType() + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + tags = _schema_my_workbook_read.properties.tags + tags.Element = AAZStrType() + + system_data = _schema_my_workbook_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.etag = cls._schema_my_workbook_read.etag + _schema.id = cls._schema_my_workbook_read.id + _schema.identity = cls._schema_my_workbook_read.identity + _schema.kind = cls._schema_my_workbook_read.kind + _schema.location = cls._schema_my_workbook_read.location + _schema.name = cls._schema_my_workbook_read.name + _schema.properties = cls._schema_my_workbook_read.properties + _schema.system_data = cls._schema_my_workbook_read.system_data + _schema.type = cls._schema_my_workbook_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/__cmd_group.py new file mode 100644 index 00000000000..39a7839d6f0 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights workbook", +) +class __CMDGroup(AAZCommandGroup): + """Manage app-insights workbook + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_create.py new file mode 100644 index 00000000000..ee73da0c34c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_create.py @@ -0,0 +1,404 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook create", +) +class Create(AAZCommand): + """Create a workbook. + + :example: Create workbook + az monitor app-insights workbook create -n 00000000-0000-0000-0000-000000000000 -g rg --serialized-data mydata --kind shared --category workbook --display-name workbookname + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="Properties", + help="Workbook category, as defined by the user at creation time.", + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="The description of the workbook.", + nullable=True, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The user-defined name (display name) of the workbook.", + ) + _args_schema.serialized_data = AAZStrArg( + options=["--serialized-data"], + arg_group="Properties", + help="Configuration of this particular workbook. Configuration data is a string containing valid JSON", + nullable=True, + ) + _args_schema.storage_uri = AAZStrArg( + options=["--storage-uri"], + arg_group="Properties", + help="The resourceId to the storage account when bring your own storage is used", + nullable=True, + ) + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="Properties", + help="Workbook schema version format, like 'Notebook/1.0', which should match the workbook in serializedData", + ) + + # define Arg Group "WorkbookProperties" + + _args_schema = cls._args_schema + _args_schema.identity = AAZObjectArg( + options=["--identity"], + arg_group="WorkbookProperties", + help="Identity used for BYOS", + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="WorkbookProperties", + help="The kind of workbook. Only valid value is shared.", + enum={"shared": "shared"}, + ) + _args_schema.location = AAZResourceLocationArg( + arg_group="WorkbookProperties", + help="The geo-location where the resource lives", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="WorkbookProperties", + help="Resource tags.", + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + required=True, + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksCreateOrUpdate(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 WorkbooksCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("category", AAZStrType, ".category", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("description", AAZStrType, ".description", typ_kwargs={"nullable": True}) + properties.set_prop("displayName", AAZStrType, ".display_name", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("serializedData", AAZStrType, ".serialized_data", typ_kwargs={"flags": {"required": True}, "nullable": True}) + properties.set_prop("storageUri", AAZStrType, ".storage_uri", typ_kwargs={"nullable": True}) + properties.set_prop("version", AAZStrType, ".version") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.etag = AAZStrType() + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.kind = AAZStrType() + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_delete.py new file mode 100644 index 00000000000..324dd2f1635 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_delete.py @@ -0,0 +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( + "monitor app-insights workbook delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a workbook. + + :example: Delete workbook + az monitor app-insights workbook delete -n 00000000-0000-0000-0000-000000000000 -g wktest + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class WorkbooksDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_list.py new file mode 100644 index 00000000000..3b6efb748d1 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_list.py @@ -0,0 +1,520 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook list", +) +class List(AAZCommand): + """List all workbooks defined within a specified resource group and category. + + :example: List workbook + az monitor app-insights workbook list -g rg --category workbook + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/workbooks", "2023-06-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks", "2023-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + _args_schema.can_fetch_content = AAZBoolArg( + options=["--can-fetch-content"], + help="Flag indicating whether or not to return the full content for each applicable workbook. If false, only return summary content for workbooks.", + ) + _args_schema.category = AAZStrArg( + options=["--category"], + help="Category of workbook to return.", + required=True, + enum={"TSG": "TSG", "performance": "performance", "retention": "retention", "workbook": "workbook"}, + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + _args_schema.tags = AAZListArg( + options=["--tags"], + help="Tags presents on each workbook returned.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.category) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) and has_value(self.ctx.args.category) + if condition_0: + self.WorkbooksListBySubscription(ctx=self.ctx)() + if condition_1: + self.WorkbooksListByResourceGroup(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 WorkbooksListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "canFetchContent", self.ctx.args.can_fetch_content, + ), + **self.serialize_query_param( + "category", self.ctx.args.category, + required=True, + ), + **self.serialize_query_param( + "tags", self.ctx.args.tags, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class WorkbooksListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "canFetchContent", self.ctx.args.can_fetch_content, + ), + **self.serialize_query_param( + "category", self.ctx.args.category, + required=True, + ), + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "tags", self.ctx.args.tags, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_show.py new file mode 100644 index 00000000000..276c6747a0a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_show.py @@ -0,0 +1,280 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook show", +) +class Show(AAZCommand): + """Show a single workbook by its resource name. + + :example: Show workbook + az monitor app-insights workbook show -n 00000000-0000-0000-0000-000000000000 -g wktest + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + id_part="name", + ) + _args_schema.can_fetch_content = AAZBoolArg( + options=["--can-fetch-content"], + help="Flag indicating whether or not to return the full content for each applicable workbook. If false, only return summary content for workbooks.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksGet(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 WorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "canFetchContent", self.ctx.args.can_fetch_content, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZStrType() + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.kind = AAZStrType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_update.py new file mode 100644 index 00000000000..d54b9c56681 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/_update.py @@ -0,0 +1,553 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook update", +) +class Update(AAZCommand): + """Update a workbook. + + :example: Update workbook + az monitor app-insights workbook update -n 00000000-0000-0000-0000-000000000000 -g rg --tags tag=test + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + id_part="name", + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.category = AAZStrArg( + options=["--category"], + arg_group="Properties", + help="Workbook category, as defined by the user at creation time.", + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="The description of the workbook.", + nullable=True, + ) + _args_schema.display_name = AAZStrArg( + options=["--display-name"], + arg_group="Properties", + help="The user-defined name (display name) of the workbook.", + ) + _args_schema.serialized_data = AAZStrArg( + options=["--serialized-data"], + arg_group="Properties", + help="Configuration of this particular workbook. Configuration data is a string containing valid JSON", + nullable=True, + ) + _args_schema.storage_uri = AAZStrArg( + options=["--storage-uri"], + arg_group="Properties", + help="The resourceId to the storage account when bring your own storage is used", + nullable=True, + ) + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="Properties", + help="Workbook schema version format, like 'Notebook/1.0', which should match the workbook in serializedData", + nullable=True, + ) + + # define Arg Group "WorkbookProperties" + + _args_schema = cls._args_schema + _args_schema.identity = AAZObjectArg( + options=["--identity"], + arg_group="WorkbookProperties", + help="Identity used for BYOS", + nullable=True, + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="WorkbookProperties", + help="The kind of workbook. Only valid value is shared.", + nullable=True, + enum={"shared": "shared"}, + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="WorkbookProperties", + help="Resource tags.", + nullable=True, + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + nullable=True, + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.WorkbooksCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class WorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_workbook_read(cls._schema_on_200) + + return cls._schema_on_200 + + class WorkbooksCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_workbook_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("category", AAZStrType, ".category", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("description", AAZStrType, ".description", typ_kwargs={"nullable": True}) + properties.set_prop("displayName", AAZStrType, ".display_name", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("serializedData", AAZStrType, ".serialized_data", typ_kwargs={"flags": {"required": True}, "nullable": True}) + properties.set_prop("storageUri", AAZStrType, ".storage_uri", typ_kwargs={"nullable": True}) + properties.set_prop("version", AAZStrType, ".version") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_workbook_read = None + + @classmethod + def _build_schema_workbook_read(cls, _schema): + if cls._schema_workbook_read is not None: + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + return + + cls._schema_workbook_read = _schema_workbook_read = AAZObjectType() + + workbook_read = _schema_workbook_read + workbook_read.etag = AAZStrType() + workbook_read.id = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.identity = AAZIdentityObjectType() + workbook_read.kind = AAZStrType() + workbook_read.location = AAZStrType( + flags={"required": True}, + ) + workbook_read.name = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + workbook_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + workbook_read.tags = AAZDictType() + workbook_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_workbook_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_workbook_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_workbook_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_workbook_read.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = _schema_workbook_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_workbook_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/__cmd_group.py new file mode 100644 index 00000000000..574bf9f9e08 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights workbook identity", +) +class __CMDGroup(AAZCommandGroup): + """Manage workbook idneity + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/__init__.py new file mode 100644 index 00000000000..ef1ca2e5632 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._assign import * +from ._delete import * +from ._remove import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_assign.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_assign.py new file mode 100644 index 00000000000..f37856af78a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_assign.py @@ -0,0 +1,466 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook identity assign", +) +class Assign(AAZCommand): + """Assign identities + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + + # define Arg Group "WorkbookProperties.identity" + + _args_schema = cls._args_schema + _args_schema.type = AAZStrArg( + options=["--type"], + arg_group="WorkbookProperties.identity", + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + required=True, + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + _args_schema.user_assigned_identities = AAZDictArg( + options=["--user-assigned-identities"], + arg_group="WorkbookProperties.identity", + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + ) + + user_assigned_identities = cls._args_schema.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + blank={}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksGet(ctx=self.ctx)() + self.pre_instance_create() + self.InstanceCreateByJson(ctx=self.ctx)() + self.post_instance_create(self.ctx.selectors.subresource.get()) + self.WorkbooksCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_create(self): + pass + + @register_callback + def post_instance_create(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class WorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _AssignHelper._build_schema_workbook_read(cls._schema_on_200) + + return cls._schema_on_200 + + class WorkbooksCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _AssignHelper._build_schema_workbook_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceCreateByJson(AAZJsonInstanceCreateOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._create_instance()) + + def _create_instance(self): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZIdentityObjectType + ) + _builder.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".") + + return _instance_value + + +class _AssignHelper: + """Helper class for Assign""" + + _schema_workbook_read = None + + @classmethod + def _build_schema_workbook_read(cls, _schema): + if cls._schema_workbook_read is not None: + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + return + + cls._schema_workbook_read = _schema_workbook_read = AAZObjectType() + + workbook_read = _schema_workbook_read + workbook_read.etag = AAZStrType() + workbook_read.id = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.identity = AAZIdentityObjectType() + workbook_read.kind = AAZStrType() + workbook_read.location = AAZStrType( + flags={"required": True}, + ) + workbook_read.name = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + workbook_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + workbook_read.tags = AAZDictType() + workbook_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_workbook_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_workbook_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_workbook_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_workbook_read.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = _schema_workbook_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_workbook_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + + +__all__ = ["Assign"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_delete.py new file mode 100644 index 00000000000..6d27cdd9880 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_delete.py @@ -0,0 +1,428 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook identity delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """None + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksGet(ctx=self.ctx)() + self.pre_instance_delete() + self.InstanceDeleteByJson(ctx=self.ctx)() + self.post_instance_delete() + self.WorkbooksCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_delete(self): + pass + + @register_callback + def post_instance_delete(self): + pass + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class WorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _DeleteHelper._build_schema_workbook_read(cls._schema_on_200) + + return cls._schema_on_200 + + class WorkbooksCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _DeleteHelper._build_schema_workbook_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceDeleteByJson(AAZJsonInstanceDeleteOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._delete_instance()) + + +class _DeleteHelper: + """Helper class for Delete""" + + _schema_workbook_read = None + + @classmethod + def _build_schema_workbook_read(cls, _schema): + if cls._schema_workbook_read is not None: + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + return + + cls._schema_workbook_read = _schema_workbook_read = AAZObjectType() + + workbook_read = _schema_workbook_read + workbook_read.etag = AAZStrType() + workbook_read.id = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.identity = AAZIdentityObjectType() + workbook_read.kind = AAZStrType() + workbook_read.location = AAZStrType( + flags={"required": True}, + ) + workbook_read.name = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + workbook_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + workbook_read.tags = AAZDictType() + workbook_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_workbook_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_workbook_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_workbook_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_workbook_read.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = _schema_workbook_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_workbook_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_remove.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_remove.py new file mode 100644 index 00000000000..6b977423b2f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_remove.py @@ -0,0 +1,468 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook identity remove", +) +class Remove(AAZCommand): + """Remove identities + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + ) + _args_schema.source_id = AAZStrArg( + options=["--source-id"], + help="Azure Resource Id that will fetch all linked workbooks.", + ) + + # define Arg Group "WorkbookProperties.identity" + + _args_schema = cls._args_schema + _args_schema.type = AAZStrArg( + options=["--type"], + arg_group="WorkbookProperties.identity", + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + _args_schema.user_assigned_identities = AAZDictArg( + options=["--user-assigned-identities"], + arg_group="WorkbookProperties.identity", + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + nullable=True, + ) + + user_assigned_identities = cls._args_schema.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.WorkbooksCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class WorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _RemoveHelper._build_schema_workbook_read(cls._schema_on_200) + + return cls._schema_on_200 + + class WorkbooksCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "sourceId", self.ctx.args.source_id, + ), + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _RemoveHelper._build_schema_workbook_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZIdentityObjectType + ) + _builder.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".") + + return _instance_value + + +class _RemoveHelper: + """Helper class for Remove""" + + _schema_workbook_read = None + + @classmethod + def _build_schema_workbook_read(cls, _schema): + if cls._schema_workbook_read is not None: + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + return + + cls._schema_workbook_read = _schema_workbook_read = AAZObjectType() + + workbook_read = _schema_workbook_read + workbook_read.etag = AAZStrType() + workbook_read.id = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.identity = AAZIdentityObjectType() + workbook_read.kind = AAZStrType() + workbook_read.location = AAZStrType( + flags={"required": True}, + ) + workbook_read.name = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + workbook_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + workbook_read.tags = AAZDictType() + workbook_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_workbook_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_workbook_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_workbook_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_workbook_read.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = _schema_workbook_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_workbook_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + + +__all__ = ["Remove"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_show.py new file mode 100644 index 00000000000..cc39a86594e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/identity/_show.py @@ -0,0 +1,312 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook identity show", +) +class Show(AAZCommand): + """None + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}", "2023-06-01", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class WorkbooksGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_workbook_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_workbook_read = None + + @classmethod + def _build_schema_workbook_read(cls, _schema): + if cls._schema_workbook_read is not None: + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + return + + cls._schema_workbook_read = _schema_workbook_read = AAZObjectType() + + workbook_read = _schema_workbook_read + workbook_read.etag = AAZStrType() + workbook_read.id = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.identity = AAZIdentityObjectType() + workbook_read.kind = AAZStrType() + workbook_read.location = AAZStrType( + flags={"required": True}, + ) + workbook_read.name = AAZStrType( + flags={"read_only": True}, + ) + workbook_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + workbook_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + workbook_read.tags = AAZDictType() + workbook_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_workbook_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_workbook_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_workbook_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_workbook_read.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = _schema_workbook_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_workbook_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_workbook_read.etag + _schema.id = cls._schema_workbook_read.id + _schema.identity = cls._schema_workbook_read.identity + _schema.kind = cls._schema_workbook_read.kind + _schema.location = cls._schema_workbook_read.location + _schema.name = cls._schema_workbook_read.name + _schema.properties = cls._schema_workbook_read.properties + _schema.system_data = cls._schema_workbook_read.system_data + _schema.tags = cls._schema_workbook_read.tags + _schema.type = cls._schema_workbook_read.type + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/__cmd_group.py new file mode 100644 index 00000000000..e41c4ac54ba --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor app-insights workbook revision", +) +class __CMDGroup(AAZCommandGroup): + """Manage workbook revision + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/__init__.py new file mode 100644 index 00000000000..2df85698253 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/_list.py new file mode 100644 index 00000000000..f33c2a57356 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/_list.py @@ -0,0 +1,292 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook revision list", +) +class List(AAZCommand): + """List the revisions for the workbook. + + :example: List the revisions for the workbook + az monitor app-insights workbook revision list -g rg --resource-name name + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}/revisions", "2023-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksRevisionsList(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 WorkbooksRevisionsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.source_id = AAZStrType( + serialized_name="sourceId", + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.tags = AAZListType() + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + tags = cls._schema_on_200.value.Element.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/_show.py new file mode 100644 index 00000000000..4606d572fde --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/app_insights/workbook/revision/_show.py @@ -0,0 +1,290 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor app-insights workbook revision show", +) +class Show(AAZCommand): + """Show workbook revision. + + :example: Show workbook revision + az monitor app-insights workbook revision list -g rg --resource-name name --revision-id id + """ + + _aaz_info = { + "version": "2023-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/workbooks/{}/revisions/{}", "2023-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The name of the workbook resource. The value must be an UUID.", + required=True, + id_part="name", + ) + _args_schema.revision_id = AAZStrArg( + options=["-n", "--name", "--revision-id"], + help="The id of the workbook's revision.", + required=True, + id_part="child_name_1", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkbooksRevisionGet(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 WorkbooksRevisionGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "revisionId", self.ctx.args.revision_id, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZStrType() + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.kind = AAZStrType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType( + nullable=True, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.revision = AAZStrType( + nullable=True, + flags={"read_only": True}, + ) + properties.serialized_data = AAZStrType( + serialized_name="serializedData", + flags={"required": True}, + nullable=True, + ) + properties.source_id = AAZStrType( + serialized_name="sourceId", + ) + properties.storage_uri = AAZStrType( + serialized_name="storageUri", + nullable=True, + ) + properties.tags = AAZListType() + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + properties.user_id = AAZStrType( + serialized_name="userId", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + tags = cls._schema_on_200.properties.tags + tags.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/__cmd_group.py new file mode 100644 index 00000000000..9f3a7393ca6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection", +) +class __CMDGroup(AAZCommandGroup): + """Manage data collection for monitor control service. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/__cmd_group.py new file mode 100644 index 00000000000..7c9cb2b17a6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection endpoint", +) +class __CMDGroup(AAZCommandGroup): + """Manage data collection endpoint for monitor control service. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_create.py new file mode 100644 index 00000000000..2fb798064ca --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_create.py @@ -0,0 +1,427 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection endpoint create", +) +class Create(AAZCommand): + """Create a data collection endpoint. + + :example: Create data collection endpoint + az monitor data-collection endpoint create -g "myResourceGroup" -l "eastus2euap" --name "myCollectionEndpoint" --public-network-access "Enabled" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionendpoints/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_endpoint_name = AAZStrArg( + options=["-n", "--name", "--data-collection-endpoint-name"], + help="The name of the data collection endpoint. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.identity = AAZObjectArg( + options=["--identity"], + help="Managed service identity of the resource.", + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + help="The kind of the resource.", + enum={"Linux": "Linux", "Windows": "Windows"}, + ) + _args_schema.location = AAZResourceLocationArg( + help="The geo-location where the resource lives.", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.description = AAZStrArg( + options=["--description"], + help="Description of the association.", + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Resource tags.", + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + required=True, + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Network Acls" + + _args_schema = cls._args_schema + _args_schema.public_network_access = AAZStrArg( + options=["--public-network-access"], + arg_group="Network Acls", + help="The configuration to set whether network access from public internet to the endpoints are allowed.", + enum={"Disabled": "Disabled", "Enabled": "Enabled", "SecuredByPerimeter": "SecuredByPerimeter"}, + ) + + # define Arg Group "Properties" + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionEndpointsCreate(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 DataCollectionEndpointsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + **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( + "dataCollectionEndpointName", self.ctx.args.data_collection_endpoint_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".", typ_kwargs={"nullable": True}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("networkAcls", AAZObjectType) + + network_acls = _builder.get(".properties.networkAcls") + if network_acls is not None: + network_acls.set_prop("publicNetworkAccess", AAZStrType, ".public_network_access") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.etag = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.kind = AAZStrType() + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.configuration_access = AAZObjectType( + serialized_name="configurationAccess", + ) + properties.description = AAZStrType() + properties.failover_configuration = AAZObjectType( + serialized_name="failoverConfiguration", + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + ) + properties.logs_ingestion = AAZObjectType( + serialized_name="logsIngestion", + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.metrics_ingestion = AAZObjectType( + serialized_name="metricsIngestion", + ) + properties.network_acls = AAZObjectType( + serialized_name="networkAcls", + ) + properties.private_link_scoped_resources = AAZListType( + serialized_name="privateLinkScopedResources", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + configuration_access = cls._schema_on_200_201.properties.configuration_access + configuration_access.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + failover_configuration = cls._schema_on_200_201.properties.failover_configuration + failover_configuration.active_location = AAZStrType( + serialized_name="activeLocation", + ) + failover_configuration.locations = AAZListType() + + locations = cls._schema_on_200_201.properties.failover_configuration.locations + locations.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.failover_configuration.locations.Element + _element.location = AAZStrType() + _element.provisioning_status = AAZStrType( + serialized_name="provisioningStatus", + ) + + logs_ingestion = cls._schema_on_200_201.properties.logs_ingestion + logs_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200_201.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + metrics_ingestion = cls._schema_on_200_201.properties.metrics_ingestion + metrics_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + network_acls = cls._schema_on_200_201.properties.network_acls + network_acls.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + private_link_scoped_resources = cls._schema_on_200_201.properties.private_link_scoped_resources + private_link_scoped_resources.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.private_link_scoped_resources.Element + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + _element.scope_id = AAZStrType( + serialized_name="scopeId", + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_delete.py new file mode 100644 index 00000000000..dbc20c44c5f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_delete.py @@ -0,0 +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( + "monitor data-collection endpoint delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a data collection endpoint. + + :example: Delete data collection endpoint + az monitor data-collection endpoint delete --name "myCollectionEndpoint" --resource-group "myResourceGroup" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionendpoints/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_endpoint_name = AAZStrArg( + options=["-n", "--name", "--data-collection-endpoint-name"], + help="The name of the data collection endpoint. The name is case insensitive.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionEndpointsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DataCollectionEndpointsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + **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( + "dataCollectionEndpointName", self.ctx.args.data_collection_endpoint_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_list.py new file mode 100644 index 00000000000..f33010e3eb4 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_list.py @@ -0,0 +1,597 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection endpoint list", +) +class List(AAZCommand): + """List all data collection endpoints in the specified subscription + + :example: List data collection endpoints by resource group + az monitor data-collection endpoint list --resource-group "myResourceGroup" + + :example: List data collection endpoints by subscription + az monitor data-collection endpoint list + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/datacollectionendpoints", "2022-06-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionendpoints", "2022-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.DataCollectionEndpointsListByResourceGroup(ctx=self.ctx)() + if condition_1: + self.DataCollectionEndpointsListBySubscription(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 DataCollectionEndpointsListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType( + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.configuration_access = AAZObjectType( + serialized_name="configurationAccess", + ) + properties.description = AAZStrType() + properties.failover_configuration = AAZObjectType( + serialized_name="failoverConfiguration", + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + ) + properties.logs_ingestion = AAZObjectType( + serialized_name="logsIngestion", + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.metrics_ingestion = AAZObjectType( + serialized_name="metricsIngestion", + ) + properties.network_acls = AAZObjectType( + serialized_name="networkAcls", + ) + properties.private_link_scoped_resources = AAZListType( + serialized_name="privateLinkScopedResources", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + configuration_access = cls._schema_on_200.value.Element.properties.configuration_access + configuration_access.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + failover_configuration = cls._schema_on_200.value.Element.properties.failover_configuration + failover_configuration.active_location = AAZStrType( + serialized_name="activeLocation", + ) + failover_configuration.locations = AAZListType() + + locations = cls._schema_on_200.value.Element.properties.failover_configuration.locations + locations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.failover_configuration.locations.Element + _element.location = AAZStrType() + _element.provisioning_status = AAZStrType( + serialized_name="provisioningStatus", + ) + + logs_ingestion = cls._schema_on_200.value.Element.properties.logs_ingestion + logs_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + metrics_ingestion = cls._schema_on_200.value.Element.properties.metrics_ingestion + metrics_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + network_acls = cls._schema_on_200.value.Element.properties.network_acls + network_acls.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + private_link_scoped_resources = cls._schema_on_200.value.Element.properties.private_link_scoped_resources + private_link_scoped_resources.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.private_link_scoped_resources.Element + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + _element.scope_id = AAZStrType( + serialized_name="scopeId", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class DataCollectionEndpointsListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType( + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.configuration_access = AAZObjectType( + serialized_name="configurationAccess", + ) + properties.description = AAZStrType() + properties.failover_configuration = AAZObjectType( + serialized_name="failoverConfiguration", + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + ) + properties.logs_ingestion = AAZObjectType( + serialized_name="logsIngestion", + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.metrics_ingestion = AAZObjectType( + serialized_name="metricsIngestion", + ) + properties.network_acls = AAZObjectType( + serialized_name="networkAcls", + ) + properties.private_link_scoped_resources = AAZListType( + serialized_name="privateLinkScopedResources", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + configuration_access = cls._schema_on_200.value.Element.properties.configuration_access + configuration_access.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + failover_configuration = cls._schema_on_200.value.Element.properties.failover_configuration + failover_configuration.active_location = AAZStrType( + serialized_name="activeLocation", + ) + failover_configuration.locations = AAZListType() + + locations = cls._schema_on_200.value.Element.properties.failover_configuration.locations + locations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.failover_configuration.locations.Element + _element.location = AAZStrType() + _element.provisioning_status = AAZStrType( + serialized_name="provisioningStatus", + ) + + logs_ingestion = cls._schema_on_200.value.Element.properties.logs_ingestion + logs_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + metrics_ingestion = cls._schema_on_200.value.Element.properties.metrics_ingestion + metrics_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + network_acls = cls._schema_on_200.value.Element.properties.network_acls + network_acls.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + private_link_scoped_resources = cls._schema_on_200.value.Element.properties.private_link_scoped_resources + private_link_scoped_resources.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.private_link_scoped_resources.Element + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + _element.scope_id = AAZStrType( + serialized_name="scopeId", + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_show.py new file mode 100644 index 00000000000..0a66f011203 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_show.py @@ -0,0 +1,332 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection endpoint show", +) +class Show(AAZCommand): + """Get the specified data collection endpoint. + + :example: Get data collection endpoint + az monitor data-collection endpoint show --name "myCollectionEndpoint" --resource-group "myResourceGroup" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionendpoints/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_endpoint_name = AAZStrArg( + options=["-n", "--name", "--data-collection-endpoint-name"], + help="The name of the data collection endpoint. The name is case insensitive.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionEndpointsGet(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 DataCollectionEndpointsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + **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( + "dataCollectionEndpointName", self.ctx.args.data_collection_endpoint_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.kind = AAZStrType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.configuration_access = AAZObjectType( + serialized_name="configurationAccess", + ) + properties.description = AAZStrType() + properties.failover_configuration = AAZObjectType( + serialized_name="failoverConfiguration", + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + ) + properties.logs_ingestion = AAZObjectType( + serialized_name="logsIngestion", + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.metrics_ingestion = AAZObjectType( + serialized_name="metricsIngestion", + ) + properties.network_acls = AAZObjectType( + serialized_name="networkAcls", + ) + properties.private_link_scoped_resources = AAZListType( + serialized_name="privateLinkScopedResources", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + configuration_access = cls._schema_on_200.properties.configuration_access + configuration_access.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + failover_configuration = cls._schema_on_200.properties.failover_configuration + failover_configuration.active_location = AAZStrType( + serialized_name="activeLocation", + ) + failover_configuration.locations = AAZListType() + + locations = cls._schema_on_200.properties.failover_configuration.locations + locations.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.failover_configuration.locations.Element + _element.location = AAZStrType() + _element.provisioning_status = AAZStrType( + serialized_name="provisioningStatus", + ) + + logs_ingestion = cls._schema_on_200.properties.logs_ingestion + logs_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + metrics_ingestion = cls._schema_on_200.properties.metrics_ingestion + metrics_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + network_acls = cls._schema_on_200.properties.network_acls + network_acls.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + private_link_scoped_resources = cls._schema_on_200.properties.private_link_scoped_resources + private_link_scoped_resources.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.private_link_scoped_resources.Element + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + _element.scope_id = AAZStrType( + serialized_name="scopeId", + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_update.py new file mode 100644 index 00000000000..ea555231037 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/_update.py @@ -0,0 +1,578 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection endpoint update", +) +class Update(AAZCommand): + """Update a data collection endpoint. + + :example: Update data collection endpoint + az monitor data-collection endpoint update --tags tag1="A" tag2="B" tag3="C" --name "myCollectionEndpoint" --resource-group "myResourceGroup" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionendpoints/{}", "2022-06-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_endpoint_name = AAZStrArg( + options=["-n", "--name", "--data-collection-endpoint-name"], + help="The name of the data collection endpoint. The name is case insensitive.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.identity = AAZObjectArg( + options=["--identity"], + help="Managed service identity of the resource.", + nullable=True, + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + help="The kind of the resource.", + nullable=True, + enum={"Linux": "Linux", "Windows": "Windows"}, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + help="Description of the association.", + nullable=True, + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Resource tags.", + nullable=True, + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + nullable=True, + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Network Acls" + + _args_schema = cls._args_schema + _args_schema.public_network_access = AAZStrArg( + options=["--public-network-access"], + arg_group="Network Acls", + help="The configuration to set whether network access from public internet to the endpoints are allowed.", + nullable=True, + enum={"Disabled": "Disabled", "Enabled": "Enabled", "SecuredByPerimeter": "SecuredByPerimeter"}, + ) + + # define Arg Group "Properties" + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionEndpointsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.DataCollectionEndpointsCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DataCollectionEndpointsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + **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( + "dataCollectionEndpointName", self.ctx.args.data_collection_endpoint_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_endpoint_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionEndpointsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + **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( + "dataCollectionEndpointName", self.ctx.args.data_collection_endpoint_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_endpoint_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".", typ_kwargs={"nullable": True}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("networkAcls", AAZObjectType) + + network_acls = _builder.get(".properties.networkAcls") + if network_acls is not None: + network_acls.set_prop("publicNetworkAccess", AAZStrType, ".public_network_access") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_collection_endpoint_resource_read = None + + @classmethod + def _build_schema_data_collection_endpoint_resource_read(cls, _schema): + if cls._schema_data_collection_endpoint_resource_read is not None: + _schema.etag = cls._schema_data_collection_endpoint_resource_read.etag + _schema.id = cls._schema_data_collection_endpoint_resource_read.id + _schema.identity = cls._schema_data_collection_endpoint_resource_read.identity + _schema.kind = cls._schema_data_collection_endpoint_resource_read.kind + _schema.location = cls._schema_data_collection_endpoint_resource_read.location + _schema.name = cls._schema_data_collection_endpoint_resource_read.name + _schema.properties = cls._schema_data_collection_endpoint_resource_read.properties + _schema.system_data = cls._schema_data_collection_endpoint_resource_read.system_data + _schema.tags = cls._schema_data_collection_endpoint_resource_read.tags + _schema.type = cls._schema_data_collection_endpoint_resource_read.type + return + + cls._schema_data_collection_endpoint_resource_read = _schema_data_collection_endpoint_resource_read = AAZObjectType() + + data_collection_endpoint_resource_read = _schema_data_collection_endpoint_resource_read + data_collection_endpoint_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_endpoint_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_endpoint_resource_read.identity = AAZIdentityObjectType() + data_collection_endpoint_resource_read.kind = AAZStrType() + data_collection_endpoint_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_endpoint_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_endpoint_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_endpoint_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_endpoint_resource_read.tags = AAZDictType() + data_collection_endpoint_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_endpoint_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_endpoint_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_endpoint_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_endpoint_resource_read.properties + properties.configuration_access = AAZObjectType( + serialized_name="configurationAccess", + ) + properties.description = AAZStrType() + properties.failover_configuration = AAZObjectType( + serialized_name="failoverConfiguration", + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + ) + properties.logs_ingestion = AAZObjectType( + serialized_name="logsIngestion", + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.metrics_ingestion = AAZObjectType( + serialized_name="metricsIngestion", + ) + properties.network_acls = AAZObjectType( + serialized_name="networkAcls", + ) + properties.private_link_scoped_resources = AAZListType( + serialized_name="privateLinkScopedResources", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + configuration_access = _schema_data_collection_endpoint_resource_read.properties.configuration_access + configuration_access.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + failover_configuration = _schema_data_collection_endpoint_resource_read.properties.failover_configuration + failover_configuration.active_location = AAZStrType( + serialized_name="activeLocation", + ) + failover_configuration.locations = AAZListType() + + locations = _schema_data_collection_endpoint_resource_read.properties.failover_configuration.locations + locations.Element = AAZObjectType() + + _element = _schema_data_collection_endpoint_resource_read.properties.failover_configuration.locations.Element + _element.location = AAZStrType() + _element.provisioning_status = AAZStrType( + serialized_name="provisioningStatus", + ) + + logs_ingestion = _schema_data_collection_endpoint_resource_read.properties.logs_ingestion + logs_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_endpoint_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + metrics_ingestion = _schema_data_collection_endpoint_resource_read.properties.metrics_ingestion + metrics_ingestion.endpoint = AAZStrType( + flags={"read_only": True}, + ) + + network_acls = _schema_data_collection_endpoint_resource_read.properties.network_acls + network_acls.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + private_link_scoped_resources = _schema_data_collection_endpoint_resource_read.properties.private_link_scoped_resources + private_link_scoped_resources.Element = AAZObjectType() + + _element = _schema_data_collection_endpoint_resource_read.properties.private_link_scoped_resources.Element + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + _element.scope_id = AAZStrType( + serialized_name="scopeId", + ) + + system_data = _schema_data_collection_endpoint_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_endpoint_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_endpoint_resource_read.etag + _schema.id = cls._schema_data_collection_endpoint_resource_read.id + _schema.identity = cls._schema_data_collection_endpoint_resource_read.identity + _schema.kind = cls._schema_data_collection_endpoint_resource_read.kind + _schema.location = cls._schema_data_collection_endpoint_resource_read.location + _schema.name = cls._schema_data_collection_endpoint_resource_read.name + _schema.properties = cls._schema_data_collection_endpoint_resource_read.properties + _schema.system_data = cls._schema_data_collection_endpoint_resource_read.system_data + _schema.tags = cls._schema_data_collection_endpoint_resource_read.tags + _schema.type = cls._schema_data_collection_endpoint_resource_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/__cmd_group.py new file mode 100644 index 00000000000..078ceb815c1 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection endpoint association", +) +class __CMDGroup(AAZCommandGroup): + """monitor data-collection endpoint association + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/__init__.py new file mode 100644 index 00000000000..d63ae5a6fc9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/_list.py new file mode 100644 index 00000000000..06043d87239 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/endpoint/association/_list.py @@ -0,0 +1,238 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection endpoint association list", +) +class List(AAZCommand): + """List associations for the specified data collection endpoint. + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionendpoints/{}/associations", "2022-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_endpoint_name = AAZStrArg( + options=["-n", "--name", "--data-collection-endpoint-name"], + help="The name of the data collection endpoint. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRuleAssociationsListByDataCollectionEndpoint(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 DataCollectionRuleAssociationsListByDataCollectionEndpoint(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations", + **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( + "dataCollectionEndpointName", self.ctx.args.data_collection_endpoint_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType( + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_collection_rule_id = AAZStrType( + serialized_name="dataCollectionRuleId", + ) + properties.description = AAZStrType() + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/__cmd_group.py new file mode 100644 index 00000000000..ff7501757db --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection rule", +) +class __CMDGroup(AAZCommandGroup): + """Manage data collection rule for monitor control service. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_create.py new file mode 100644 index 00000000000..4141fc64dfb --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_create.py @@ -0,0 +1,1583 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule create", +) +class Create(AAZCommand): + """Create a data collection rule. + + :example: Create data collection rule + az monitor data-collection rule create --resource-group "myResourceGroup" --location "eastus" --name "myCollectionRule" --rule-file "C:\\samples\\dcrEx1.json" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_rule_name = AAZStrArg( + options=["-n", "--name", "--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.identity = AAZObjectArg( + options=["--identity"], + help="Managed service identity of the resource.", + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + help="The kind of the resource.", + enum={"Linux": "Linux", "Windows": "Windows"}, + ) + _args_schema.location = AAZResourceLocationArg( + help="The geo-location where the resource lives.", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.data_collection_endpoint_id = AAZStrArg( + options=["--endpoint-id", "--data-collection-endpoint-id"], + help="The resource ID of the data collection endpoint that is to be associated.", + ) + _args_schema.description = AAZStrArg( + options=["--description"], + help="Description of the association.", + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Resource tags.", + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + required=True, + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.data_flows = AAZListArg( + options=["--data-flows"], + arg_group="Properties", + help="The specification of data flows.", + ) + _args_schema.data_sources = AAZObjectArg( + options=["--data-sources"], + arg_group="Properties", + help="The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint.", + ) + _args_schema.destinations = AAZObjectArg( + options=["--destinations"], + arg_group="Properties", + help="The specification of destinations.", + ) + _args_schema.stream_declarations = AAZDictArg( + options=["--stream-declarations"], + arg_group="Properties", + help="Declaration of custom streams used in this rule.", + ) + + data_flows = cls._args_schema.data_flows + data_flows.Element = AAZObjectArg() + + _element = cls._args_schema.data_flows.Element + _element.built_in_transform = AAZStrArg( + options=["built-in-transform"], + help="The builtIn transform to transform stream data", + ) + _element.destinations = AAZListArg( + options=["destinations"], + help="List of destinations for this data flow.", + ) + _element.output_stream = AAZStrArg( + options=["output-stream"], + help="The output stream of the transform. Only required if the transform changes data to a different stream.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams for this data flow.", + ) + _element.transform_kql = AAZStrArg( + options=["transform-kql"], + help="The KQL query to transform stream data.", + ) + + destinations = cls._args_schema.data_flows.Element.destinations + destinations.Element = AAZStrArg() + + streams = cls._args_schema.data_flows.Element.streams + streams.Element = AAZStrArg( + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf", "Microsoft-Syslog": "Microsoft-Syslog", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + ) + + data_sources = cls._args_schema.data_sources + data_sources.data_imports = AAZObjectArg( + options=["data-imports"], + help="Specifications of pull based data sources", + ) + data_sources.extensions = AAZListArg( + options=["extensions"], + help="The list of Azure VM extension data source configurations.", + ) + data_sources.iis_logs = AAZListArg( + options=["iis-logs"], + help="The list of IIS logs source configurations.", + ) + data_sources.log_files = AAZListArg( + options=["log-files"], + help="The list of Log files source configurations.", + ) + data_sources.performance_counters = AAZListArg( + options=["performance-counters"], + help="The list of performance counter data source configurations.", + ) + data_sources.platform_telemetry = AAZListArg( + options=["platform-telemetry"], + help="The list of platform telemetry configurations", + ) + data_sources.prometheus_forwarder = AAZListArg( + options=["prometheus-forwarder"], + help="The list of Prometheus forwarder data source configurations.", + ) + data_sources.syslog = AAZListArg( + options=["syslog"], + help="The list of Syslog data source configurations.", + ) + data_sources.windows_event_logs = AAZListArg( + options=["windows-event-logs"], + help="The list of Windows Event Log data source configurations.", + ) + data_sources.windows_firewall_logs = AAZListArg( + options=["windows-firewall-logs"], + help="The list of Windows Firewall logs source configurations.", + ) + + data_imports = cls._args_schema.data_sources.data_imports + data_imports.event_hub = AAZObjectArg( + options=["event-hub"], + help="Definition of Event Hub configuration.", + ) + + event_hub = cls._args_schema.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrArg( + options=["consumer-group"], + help="Event Hub consumer group name", + ) + event_hub.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + event_hub.stream = AAZStrArg( + options=["stream"], + help="The stream to collect from EventHub", + ) + + extensions = cls._args_schema.data_sources.extensions + extensions.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.extensions.Element + _element.extension_name = AAZStrArg( + options=["extension-name"], + help="The name of the VM extension.", + required=True, + ) + _element.extension_settings = AAZObjectArg( + options=["extension-settings"], + help="The extension settings. The format is specific for particular extension.", + blank={}, + ) + _element.input_data_sources = AAZListArg( + options=["input-data-sources"], + help="The list of data sources this extension needs data from.", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + ) + + input_data_sources = cls._args_schema.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrArg() + + streams = cls._args_schema.data_sources.extensions.Element.streams + streams.Element = AAZStrArg( + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf", "Microsoft-Syslog": "Microsoft-Syslog", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + ) + + iis_logs = cls._args_schema.data_sources.iis_logs + iis_logs.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.iis_logs.Element + _element.log_directories = AAZListArg( + options=["log-directories"], + help="Absolute paths file location", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="IIS streams", + required=True, + ) + + log_directories = cls._args_schema.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrArg() + + streams = cls._args_schema.data_sources.iis_logs.Element.streams + streams.Element = AAZStrArg() + + log_files = cls._args_schema.data_sources.log_files + log_files.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.log_files.Element + _element.file_patterns = AAZListArg( + options=["file-patterns"], + help="File Patterns where the log files are located", + required=True, + ) + _element.format = AAZStrArg( + options=["format"], + help="The data format of the log files", + required=True, + enum={"text": "text"}, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.settings = AAZObjectArg( + options=["settings"], + help="The log files specific settings.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data source", + required=True, + ) + + file_patterns = cls._args_schema.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrArg() + + settings = cls._args_schema.data_sources.log_files.Element.settings + settings.text = AAZObjectArg( + options=["text"], + help="Text settings", + ) + + text = cls._args_schema.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrArg( + options=["record-start-timestamp-format"], + help="One of the supported timestamp formats", + required=True, + enum={"ISO 8601": "ISO 8601", "M/D/YYYY HH:MM:SS AM/PM": "M/D/YYYY HH:MM:SS AM/PM", "MMM d hh:mm:ss": "MMM d hh:mm:ss", "Mon DD, YYYY HH:MM:SS": "Mon DD, YYYY HH:MM:SS", "YYYY-MM-DD HH:MM:SS": "YYYY-MM-DD HH:MM:SS", "dd/MMM/yyyy:HH:mm:ss zzz": "dd/MMM/yyyy:HH:mm:ss zzz", "ddMMyy HH:mm:ss": "ddMMyy HH:mm:ss", "yyMMdd HH:mm:ss": "yyMMdd HH:mm:ss", "yyyy-MM-ddTHH:mm:ssK": "yyyy-MM-ddTHH:mm:ssK"}, + ) + + streams = cls._args_schema.data_sources.log_files.Element.streams + streams.Element = AAZStrArg() + + performance_counters = cls._args_schema.data_sources.performance_counters + performance_counters.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListArg( + options=["counter-specifiers"], + help="A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'.", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.sampling_frequency_in_seconds = AAZIntArg( + options=["sampling-frequency-in-seconds"], + help="The number of seconds between consecutive counter measurements (samples).", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + ) + + counter_specifiers = cls._args_schema.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrArg() + + streams = cls._args_schema.data_sources.performance_counters.Element.streams + streams.Element = AAZStrArg( + enum={"Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf"}, + ) + + platform_telemetry = cls._args_schema.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.platform_telemetry.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of platform telemetry streams to collect", + required=True, + ) + + streams = cls._args_schema.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrArg() + + prometheus_forwarder = cls._args_schema.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictArg( + options=["label-include-filter"], + help="The list of label inclusion filters in the form of label \"name-value\" pairs. Currently only one label is supported: 'microsoft_metrics_include_label'. Label values are matched case-insensitively.", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to.", + ) + + label_include_filter = cls._args_schema.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrArg() + + streams = cls._args_schema.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrArg( + enum={"Microsoft-PrometheusMetrics": "Microsoft-PrometheusMetrics"}, + ) + + syslog = cls._args_schema.data_sources.syslog + syslog.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.syslog.Element + _element.facility_names = AAZListArg( + options=["facility-names"], + help="The list of facility names.", + ) + _element.log_levels = AAZListArg( + options=["log-levels"], + help="The log levels to collect.", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + ) + + facility_names = cls._args_schema.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrArg( + enum={"*": "*", "auth": "auth", "authpriv": "authpriv", "cron": "cron", "daemon": "daemon", "kern": "kern", "local0": "local0", "local1": "local1", "local2": "local2", "local3": "local3", "local4": "local4", "local5": "local5", "local6": "local6", "local7": "local7", "lpr": "lpr", "mail": "mail", "mark": "mark", "news": "news", "syslog": "syslog", "user": "user", "uucp": "uucp"}, + ) + + log_levels = cls._args_schema.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrArg( + enum={"*": "*", "Alert": "Alert", "Critical": "Critical", "Debug": "Debug", "Emergency": "Emergency", "Error": "Error", "Info": "Info", "Notice": "Notice", "Warning": "Warning"}, + ) + + streams = cls._args_schema.data_sources.syslog.Element.streams + streams.Element = AAZStrArg( + enum={"Microsoft-Syslog": "Microsoft-Syslog"}, + ) + + windows_event_logs = cls._args_schema.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.windows_event_logs.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + ) + _element.x_path_queries = AAZListArg( + options=["x-path-queries"], + help="A list of Windows Event Log queries in XPATH format.", + ) + + streams = cls._args_schema.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrArg( + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + ) + + x_path_queries = cls._args_schema.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrArg() + + windows_firewall_logs = cls._args_schema.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectArg() + + _element = cls._args_schema.data_sources.windows_firewall_logs.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + ) + _element.streams = AAZListArg( + options=["streams"], + help="Firewall logs streams", + required=True, + ) + + streams = cls._args_schema.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrArg() + + destinations = cls._args_schema.destinations + destinations.azure_monitor_metrics = AAZObjectArg( + options=["azure-monitor-metrics"], + help="Azure Monitor Metrics destination.", + ) + destinations.event_hubs = AAZListArg( + options=["event-hubs"], + help="List of Event Hubs destinations.", + ) + destinations.event_hubs_direct = AAZListArg( + options=["event-hubs-direct"], + help="List of Event Hubs Direct destinations.", + ) + destinations.log_analytics = AAZListArg( + options=["log-analytics"], + help="List of Log Analytics destinations.", + ) + destinations.monitoring_accounts = AAZListArg( + options=["monitoring-accounts"], + help="List of monitoring account destinations.", + ) + destinations.storage_accounts = AAZListArg( + options=["storage-accounts"], + help="List of storage accounts destinations.", + ) + destinations.storage_blobs_direct = AAZListArg( + options=["storage-blobs-direct"], + help="List of Storage Blob Direct destinations. To be used only for sending data directly to store from the agent.", + ) + destinations.storage_tables_direct = AAZListArg( + options=["storage-tables-direct"], + help="List of Storage Table Direct destinations.", + ) + + azure_monitor_metrics = cls._args_schema.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + ) + + event_hubs = cls._args_schema.destinations.event_hubs + event_hubs.Element = AAZObjectArg() + + _element = cls._args_schema.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrArg( + options=["event-hub-resource-id"], + help="The resource ID of the event hub.", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + ) + + event_hubs_direct = cls._args_schema.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectArg() + + _element = cls._args_schema.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrArg( + options=["event-hub-resource-id"], + help="The resource ID of the event hub.", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + ) + + log_analytics = cls._args_schema.destinations.log_analytics + log_analytics.Element = AAZObjectArg() + + _element = cls._args_schema.destinations.log_analytics.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + ) + _element.workspace_resource_id = AAZStrArg( + options=["workspace-resource-id"], + help="The resource ID of the Log Analytics workspace.", + ) + + monitoring_accounts = cls._args_schema.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectArg() + + _element = cls._args_schema.destinations.monitoring_accounts.Element + _element.account_resource_id = AAZStrArg( + options=["account-resource-id"], + help="The resource ID of the monitoring account.", + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + ) + + storage_accounts = cls._args_schema.destinations.storage_accounts + storage_accounts.Element = AAZObjectArg() + cls._build_args_storage_blob_destination_create(storage_accounts.Element) + + storage_blobs_direct = cls._args_schema.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectArg() + cls._build_args_storage_blob_destination_create(storage_blobs_direct.Element) + + storage_tables_direct = cls._args_schema.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectArg() + + _element = cls._args_schema.destinations.storage_tables_direct.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + ) + _element.storage_account_resource_id = AAZStrArg( + options=["storage-account-resource-id"], + help="The resource ID of the storage account.", + ) + _element.table_name = AAZStrArg( + options=["table-name"], + help="The name of the Storage Table.", + ) + + stream_declarations = cls._args_schema.stream_declarations + stream_declarations.Element = AAZObjectArg() + + _element = cls._args_schema.stream_declarations.Element + _element.columns = AAZListArg( + options=["columns"], + help="List of columns used by data in this stream.", + ) + + columns = cls._args_schema.stream_declarations.Element.columns + columns.Element = AAZObjectArg() + + _element = cls._args_schema.stream_declarations.Element.columns.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the column.", + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of the column data.", + enum={"boolean": "boolean", "datetime": "datetime", "dynamic": "dynamic", "int": "int", "long": "long", "real": "real", "string": "string"}, + ) + return cls._args_schema + + _args_storage_blob_destination_create = None + + @classmethod + def _build_args_storage_blob_destination_create(cls, _schema): + if cls._args_storage_blob_destination_create is not None: + _schema.container_name = cls._args_storage_blob_destination_create.container_name + _schema.name = cls._args_storage_blob_destination_create.name + _schema.storage_account_resource_id = cls._args_storage_blob_destination_create.storage_account_resource_id + return + + cls._args_storage_blob_destination_create = AAZObjectArg() + + storage_blob_destination_create = cls._args_storage_blob_destination_create + storage_blob_destination_create.container_name = AAZStrArg( + options=["container-name"], + help="The container name of the Storage Blob.", + ) + storage_blob_destination_create.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + ) + storage_blob_destination_create.storage_account_resource_id = AAZStrArg( + options=["storage-account-resource-id"], + help="The resource ID of the storage account.", + ) + + _schema.container_name = cls._args_storage_blob_destination_create.container_name + _schema.name = cls._args_storage_blob_destination_create.name + _schema.storage_account_resource_id = cls._args_storage_blob_destination_create.storage_account_resource_id + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesCreate(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 DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".", typ_kwargs={"nullable": True}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("dataCollectionEndpointId", AAZStrType, ".data_collection_endpoint_id") + properties.set_prop("dataFlows", AAZListType, ".data_flows") + properties.set_prop("dataSources", AAZObjectType, ".data_sources") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("destinations", AAZObjectType, ".destinations") + properties.set_prop("streamDeclarations", AAZDictType, ".stream_declarations") + + data_flows = _builder.get(".properties.dataFlows") + if data_flows is not None: + data_flows.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataFlows[]") + if _elements is not None: + _elements.set_prop("builtInTransform", AAZStrType, ".built_in_transform") + _elements.set_prop("destinations", AAZListType, ".destinations") + _elements.set_prop("outputStream", AAZStrType, ".output_stream") + _elements.set_prop("streams", AAZListType, ".streams") + _elements.set_prop("transformKql", AAZStrType, ".transform_kql") + + destinations = _builder.get(".properties.dataFlows[].destinations") + if destinations is not None: + destinations.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataFlows[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + data_sources = _builder.get(".properties.dataSources") + if data_sources is not None: + data_sources.set_prop("dataImports", AAZObjectType, ".data_imports") + data_sources.set_prop("extensions", AAZListType, ".extensions") + data_sources.set_prop("iisLogs", AAZListType, ".iis_logs") + data_sources.set_prop("logFiles", AAZListType, ".log_files") + data_sources.set_prop("performanceCounters", AAZListType, ".performance_counters") + data_sources.set_prop("platformTelemetry", AAZListType, ".platform_telemetry") + data_sources.set_prop("prometheusForwarder", AAZListType, ".prometheus_forwarder") + data_sources.set_prop("syslog", AAZListType, ".syslog") + data_sources.set_prop("windowsEventLogs", AAZListType, ".windows_event_logs") + data_sources.set_prop("windowsFirewallLogs", AAZListType, ".windows_firewall_logs") + + data_imports = _builder.get(".properties.dataSources.dataImports") + if data_imports is not None: + data_imports.set_prop("eventHub", AAZObjectType, ".event_hub") + + event_hub = _builder.get(".properties.dataSources.dataImports.eventHub") + if event_hub is not None: + event_hub.set_prop("consumerGroup", AAZStrType, ".consumer_group") + event_hub.set_prop("name", AAZStrType, ".name") + event_hub.set_prop("stream", AAZStrType, ".stream") + + extensions = _builder.get(".properties.dataSources.extensions") + if extensions is not None: + extensions.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.extensions[]") + if _elements is not None: + _elements.set_prop("extensionName", AAZStrType, ".extension_name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("extensionSettings", AAZObjectType, ".extension_settings") + _elements.set_prop("inputDataSources", AAZListType, ".input_data_sources") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + + input_data_sources = _builder.get(".properties.dataSources.extensions[].inputDataSources") + if input_data_sources is not None: + input_data_sources.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.extensions[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + iis_logs = _builder.get(".properties.dataSources.iisLogs") + if iis_logs is not None: + iis_logs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.iisLogs[]") + if _elements is not None: + _elements.set_prop("logDirectories", AAZListType, ".log_directories") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + log_directories = _builder.get(".properties.dataSources.iisLogs[].logDirectories") + if log_directories is not None: + log_directories.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.iisLogs[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + log_files = _builder.get(".properties.dataSources.logFiles") + if log_files is not None: + log_files.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.logFiles[]") + if _elements is not None: + _elements.set_prop("filePatterns", AAZListType, ".file_patterns", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("format", AAZStrType, ".format", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("settings", AAZObjectType, ".settings") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + file_patterns = _builder.get(".properties.dataSources.logFiles[].filePatterns") + if file_patterns is not None: + file_patterns.set_elements(AAZStrType, ".") + + settings = _builder.get(".properties.dataSources.logFiles[].settings") + if settings is not None: + settings.set_prop("text", AAZObjectType, ".text") + + text = _builder.get(".properties.dataSources.logFiles[].settings.text") + if text is not None: + text.set_prop("recordStartTimestampFormat", AAZStrType, ".record_start_timestamp_format", typ_kwargs={"flags": {"required": True}}) + + streams = _builder.get(".properties.dataSources.logFiles[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + performance_counters = _builder.get(".properties.dataSources.performanceCounters") + if performance_counters is not None: + performance_counters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.performanceCounters[]") + if _elements is not None: + _elements.set_prop("counterSpecifiers", AAZListType, ".counter_specifiers") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("samplingFrequencyInSeconds", AAZIntType, ".sampling_frequency_in_seconds") + _elements.set_prop("streams", AAZListType, ".streams") + + counter_specifiers = _builder.get(".properties.dataSources.performanceCounters[].counterSpecifiers") + if counter_specifiers is not None: + counter_specifiers.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.performanceCounters[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + platform_telemetry = _builder.get(".properties.dataSources.platformTelemetry") + if platform_telemetry is not None: + platform_telemetry.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.platformTelemetry[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + streams = _builder.get(".properties.dataSources.platformTelemetry[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + prometheus_forwarder = _builder.get(".properties.dataSources.prometheusForwarder") + if prometheus_forwarder is not None: + prometheus_forwarder.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.prometheusForwarder[]") + if _elements is not None: + _elements.set_prop("labelIncludeFilter", AAZDictType, ".label_include_filter") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + + label_include_filter = _builder.get(".properties.dataSources.prometheusForwarder[].labelIncludeFilter") + if label_include_filter is not None: + label_include_filter.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.prometheusForwarder[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + syslog = _builder.get(".properties.dataSources.syslog") + if syslog is not None: + syslog.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.syslog[]") + if _elements is not None: + _elements.set_prop("facilityNames", AAZListType, ".facility_names") + _elements.set_prop("logLevels", AAZListType, ".log_levels") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + + facility_names = _builder.get(".properties.dataSources.syslog[].facilityNames") + if facility_names is not None: + facility_names.set_elements(AAZStrType, ".") + + log_levels = _builder.get(".properties.dataSources.syslog[].logLevels") + if log_levels is not None: + log_levels.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.syslog[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + windows_event_logs = _builder.get(".properties.dataSources.windowsEventLogs") + if windows_event_logs is not None: + windows_event_logs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.windowsEventLogs[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + _elements.set_prop("xPathQueries", AAZListType, ".x_path_queries") + + streams = _builder.get(".properties.dataSources.windowsEventLogs[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + x_path_queries = _builder.get(".properties.dataSources.windowsEventLogs[].xPathQueries") + if x_path_queries is not None: + x_path_queries.set_elements(AAZStrType, ".") + + windows_firewall_logs = _builder.get(".properties.dataSources.windowsFirewallLogs") + if windows_firewall_logs is not None: + windows_firewall_logs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.windowsFirewallLogs[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + streams = _builder.get(".properties.dataSources.windowsFirewallLogs[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + destinations = _builder.get(".properties.destinations") + if destinations is not None: + destinations.set_prop("azureMonitorMetrics", AAZObjectType, ".azure_monitor_metrics") + destinations.set_prop("eventHubs", AAZListType, ".event_hubs") + destinations.set_prop("eventHubsDirect", AAZListType, ".event_hubs_direct") + destinations.set_prop("logAnalytics", AAZListType, ".log_analytics") + destinations.set_prop("monitoringAccounts", AAZListType, ".monitoring_accounts") + destinations.set_prop("storageAccounts", AAZListType, ".storage_accounts") + destinations.set_prop("storageBlobsDirect", AAZListType, ".storage_blobs_direct") + destinations.set_prop("storageTablesDirect", AAZListType, ".storage_tables_direct") + + azure_monitor_metrics = _builder.get(".properties.destinations.azureMonitorMetrics") + if azure_monitor_metrics is not None: + azure_monitor_metrics.set_prop("name", AAZStrType, ".name") + + event_hubs = _builder.get(".properties.destinations.eventHubs") + if event_hubs is not None: + event_hubs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.eventHubs[]") + if _elements is not None: + _elements.set_prop("eventHubResourceId", AAZStrType, ".event_hub_resource_id") + _elements.set_prop("name", AAZStrType, ".name") + + event_hubs_direct = _builder.get(".properties.destinations.eventHubsDirect") + if event_hubs_direct is not None: + event_hubs_direct.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.eventHubsDirect[]") + if _elements is not None: + _elements.set_prop("eventHubResourceId", AAZStrType, ".event_hub_resource_id") + _elements.set_prop("name", AAZStrType, ".name") + + log_analytics = _builder.get(".properties.destinations.logAnalytics") + if log_analytics is not None: + log_analytics.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.logAnalytics[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("workspaceResourceId", AAZStrType, ".workspace_resource_id") + + monitoring_accounts = _builder.get(".properties.destinations.monitoringAccounts") + if monitoring_accounts is not None: + monitoring_accounts.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.monitoringAccounts[]") + if _elements is not None: + _elements.set_prop("accountResourceId", AAZStrType, ".account_resource_id") + _elements.set_prop("name", AAZStrType, ".name") + + storage_accounts = _builder.get(".properties.destinations.storageAccounts") + if storage_accounts is not None: + _CreateHelper._build_schema_storage_blob_destination_create(storage_accounts.set_elements(AAZObjectType, ".")) + + storage_blobs_direct = _builder.get(".properties.destinations.storageBlobsDirect") + if storage_blobs_direct is not None: + _CreateHelper._build_schema_storage_blob_destination_create(storage_blobs_direct.set_elements(AAZObjectType, ".")) + + storage_tables_direct = _builder.get(".properties.destinations.storageTablesDirect") + if storage_tables_direct is not None: + storage_tables_direct.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.storageTablesDirect[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("storageAccountResourceId", AAZStrType, ".storage_account_resource_id") + _elements.set_prop("tableName", AAZStrType, ".table_name") + + stream_declarations = _builder.get(".properties.streamDeclarations") + if stream_declarations is not None: + stream_declarations.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.streamDeclarations{}") + if _elements is not None: + _elements.set_prop("columns", AAZListType, ".columns") + + columns = _builder.get(".properties.streamDeclarations{}.columns") + if columns is not None: + columns.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.streamDeclarations{}.columns[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("type", AAZStrType, ".type") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_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.etag = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.kind = AAZStrType() + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + data_flows = cls._schema_on_200_201.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = cls._schema_on_200_201.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = cls._schema_on_200_201.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = cls._schema_on_200_201.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = cls._schema_on_200_201.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = cls._schema_on_200_201.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = cls._schema_on_200_201.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZObjectType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = cls._schema_on_200_201.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = cls._schema_on_200_201.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = cls._schema_on_200_201.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + log_directories = cls._schema_on_200_201.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = cls._schema_on_200_201.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = cls._schema_on_200_201.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + file_patterns = cls._schema_on_200_201.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = cls._schema_on_200_201.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = cls._schema_on_200_201.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = cls._schema_on_200_201.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = cls._schema_on_200_201.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + + counter_specifiers = cls._schema_on_200_201.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = cls._schema_on_200_201.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = cls._schema_on_200_201.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200_201.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = cls._schema_on_200_201.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = cls._schema_on_200_201.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = cls._schema_on_200_201.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = cls._schema_on_200_201.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + facility_names = cls._schema_on_200_201.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = cls._schema_on_200_201.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = cls._schema_on_200_201.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = cls._schema_on_200_201.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = cls._schema_on_200_201.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = cls._schema_on_200_201.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = cls._schema_on_200_201.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200_201.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = cls._schema_on_200_201.properties.destinations + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_monitor_metrics = cls._schema_on_200_201.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = cls._schema_on_200_201.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = cls._schema_on_200_201.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = cls._schema_on_200_201.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + monitoring_accounts = cls._schema_on_200_201.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = cls._schema_on_200_201.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + _CreateHelper._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = cls._schema_on_200_201.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + _CreateHelper._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = cls._schema_on_200_201.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + metadata = cls._schema_on_200_201.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + stream_declarations = cls._schema_on_200_201.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = cls._schema_on_200_201.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + @classmethod + def _build_schema_storage_blob_destination_create(cls, _builder): + if _builder is None: + return + _builder.set_prop("containerName", AAZStrType, ".container_name") + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("storageAccountResourceId", AAZStrType, ".storage_account_resource_id") + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_delete.py new file mode 100644 index 00000000000..e0e489f068d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_delete.py @@ -0,0 +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( + "monitor data-collection rule delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a data collection rule. + + :example: Delete data collection rule + az monitor data-collection rule delete --name "myCollectionRule" --resource-group "myResourceGroup" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_rule_name = AAZStrArg( + options=["-n", "--name", "--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DataCollectionRulesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_list.py new file mode 100644 index 00000000000..7a6f58ec518 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_list.py @@ -0,0 +1,1194 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule list", +) +class List(AAZCommand): + """List all data collection rules in the specified resource group. And Lists all data collection rules in the specified subscription. + + :example: List data collection rules by resource group + az monitor data-collection rule list --resource-group "myResourceGroup" + + :example: List data collection rules by subscription + az monitor data-collection rule list + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/datacollectionrules", "2022-06-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules", "2022-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.DataCollectionRulesListByResourceGroup(ctx=self.ctx)() + if condition_1: + self.DataCollectionRulesListBySubscription(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 DataCollectionRulesListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType( + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + data_flows = cls._schema_on_200.value.Element.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = cls._schema_on_200.value.Element.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = cls._schema_on_200.value.Element.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = cls._schema_on_200.value.Element.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = cls._schema_on_200.value.Element.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = cls._schema_on_200.value.Element.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZObjectType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = cls._schema_on_200.value.Element.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = cls._schema_on_200.value.Element.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + log_directories = cls._schema_on_200.value.Element.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = cls._schema_on_200.value.Element.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + file_patterns = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = cls._schema_on_200.value.Element.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + + counter_specifiers = cls._schema_on_200.value.Element.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = cls._schema_on_200.value.Element.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = cls._schema_on_200.value.Element.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + facility_names = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = cls._schema_on_200.value.Element.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = cls._schema_on_200.value.Element.properties.destinations + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_monitor_metrics = cls._schema_on_200.value.Element.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = cls._schema_on_200.value.Element.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = cls._schema_on_200.value.Element.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = cls._schema_on_200.value.Element.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + monitoring_accounts = cls._schema_on_200.value.Element.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = cls._schema_on_200.value.Element.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + _ListHelper._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = cls._schema_on_200.value.Element.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + _ListHelper._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = cls._schema_on_200.value.Element.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + stream_declarations = cls._schema_on_200.value.Element.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = cls._schema_on_200.value.Element.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class DataCollectionRulesListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType( + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.kind = AAZStrType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + data_flows = cls._schema_on_200.value.Element.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = cls._schema_on_200.value.Element.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = cls._schema_on_200.value.Element.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = cls._schema_on_200.value.Element.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = cls._schema_on_200.value.Element.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = cls._schema_on_200.value.Element.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZObjectType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = cls._schema_on_200.value.Element.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = cls._schema_on_200.value.Element.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + log_directories = cls._schema_on_200.value.Element.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = cls._schema_on_200.value.Element.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + file_patterns = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = cls._schema_on_200.value.Element.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + + counter_specifiers = cls._schema_on_200.value.Element.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = cls._schema_on_200.value.Element.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = cls._schema_on_200.value.Element.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + facility_names = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = cls._schema_on_200.value.Element.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = cls._schema_on_200.value.Element.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = cls._schema_on_200.value.Element.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200.value.Element.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = cls._schema_on_200.value.Element.properties.destinations + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_monitor_metrics = cls._schema_on_200.value.Element.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = cls._schema_on_200.value.Element.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = cls._schema_on_200.value.Element.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = cls._schema_on_200.value.Element.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + monitoring_accounts = cls._schema_on_200.value.Element.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = cls._schema_on_200.value.Element.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + _ListHelper._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = cls._schema_on_200.value.Element.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + _ListHelper._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = cls._schema_on_200.value.Element.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + stream_declarations = cls._schema_on_200.value.Element.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = cls._schema_on_200.value.Element.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_show.py new file mode 100644 index 00000000000..41fbacb0113 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_show.py @@ -0,0 +1,643 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule show", +) +class Show(AAZCommand): + """Return the specified data collection rule. + + :example: Get data collection rule + az monitor data-collection rule show --name "myCollectionRule" --resource-group "myResourceGroup" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_rule_name = AAZStrArg( + options=["-n", "--name", "--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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 DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.kind = AAZStrType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + data_flows = cls._schema_on_200.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = cls._schema_on_200.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = cls._schema_on_200.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = cls._schema_on_200.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = cls._schema_on_200.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = cls._schema_on_200.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = cls._schema_on_200.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZObjectType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = cls._schema_on_200.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = cls._schema_on_200.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = cls._schema_on_200.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + log_directories = cls._schema_on_200.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = cls._schema_on_200.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = cls._schema_on_200.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + file_patterns = cls._schema_on_200.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = cls._schema_on_200.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = cls._schema_on_200.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = cls._schema_on_200.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = cls._schema_on_200.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + + counter_specifiers = cls._schema_on_200.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = cls._schema_on_200.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = cls._schema_on_200.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = cls._schema_on_200.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = cls._schema_on_200.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = cls._schema_on_200.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = cls._schema_on_200.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + facility_names = cls._schema_on_200.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = cls._schema_on_200.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = cls._schema_on_200.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = cls._schema_on_200.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = cls._schema_on_200.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = cls._schema_on_200.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = cls._schema_on_200.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = cls._schema_on_200.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = cls._schema_on_200.properties.destinations + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_monitor_metrics = cls._schema_on_200.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = cls._schema_on_200.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = cls._schema_on_200.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = cls._schema_on_200.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + monitoring_accounts = cls._schema_on_200.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = cls._schema_on_200.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + _ShowHelper._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = cls._schema_on_200.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + _ShowHelper._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = cls._schema_on_200.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + metadata = cls._schema_on_200.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + stream_declarations = cls._schema_on_200.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = cls._schema_on_200.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_update.py new file mode 100644 index 00000000000..69a44fec636 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/_update.py @@ -0,0 +1,1870 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule update", +) +class Update(AAZCommand): + """Update a data collection rule. + + :example: Update data collection rule + az monitor data-collection rule update --resource-group "myResourceGroup" --name "myCollectionRule" --data-flows destinations="centralWorkspace" streams="Microsoft-Perf" streams="Microsoft-Syslog" streams="Microsoft-WindowsEvent" --log-analytics name="centralWorkspace" resource-id="/subscriptions/703362b3-f278-4e4b-9179- c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspac es/centralTeamWorkspace" --performance-counters name="appTeamExtraCounters" counter- specifiers="\\\\Process(_Total)\\\\Thread Count" sampling-frequency=30 streams="Microsoft-Perf" --syslog name="cronSyslog" facility-names="cron" log-levels="Debug" log-levels="Critical" log-levels="Emergency" streams="Microsoft-Syslog" --windows-event-logs name="cloudSecurityTeamEvents" streams="Microsoft-WindowsEvent" x-path-queries="Security!" + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2022-06-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_rule_name = AAZStrArg( + options=["-n", "--name", "--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.identity = AAZObjectArg( + options=["--identity"], + help="Managed service identity of the resource.", + nullable=True, + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + help="The kind of the resource.", + nullable=True, + enum={"Linux": "Linux", "Windows": "Windows"}, + ) + _args_schema.data_collection_endpoint_id = AAZStrArg( + options=["--endpoint-id", "--data-collection-endpoint-id"], + help="The resource ID of the data collection endpoint that is to be associated.", + nullable=True, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + help="Description of the association.", + nullable=True, + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Resource tags.", + nullable=True, + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + nullable=True, + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.data_flows_raw = AAZListArg( + options=["--data-flows-raw"], + arg_group="Properties", + help="The specification of data flows.", + nullable=True, + ) + _args_schema.data_sources = AAZObjectArg( + options=["--data-sources"], + arg_group="Properties", + help="The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint.", + nullable=True, + ) + _args_schema.destinations = AAZObjectArg( + options=["--destinations"], + arg_group="Properties", + help="The specification of destinations.", + nullable=True, + ) + _args_schema.stream_declarations = AAZDictArg( + options=["--stream-declarations"], + arg_group="Properties", + help="Declaration of custom streams used in this rule.", + nullable=True, + ) + + data_flows_raw = cls._args_schema.data_flows_raw + data_flows_raw.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_flows_raw.Element + _element.built_in_transform = AAZStrArg( + options=["built-in-transform"], + help="The builtIn transform to transform stream data", + nullable=True, + ) + _element.destinations = AAZListArg( + options=["destinations"], + help="List of destinations for this data flow.", + nullable=True, + ) + _element.output_stream = AAZStrArg( + options=["output-stream"], + help="The output stream of the transform. Only required if the transform changes data to a different stream.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams for this data flow.", + nullable=True, + ) + _element.transform_kql = AAZStrArg( + options=["transform-kql"], + help="The KQL query to transform stream data.", + nullable=True, + ) + + destinations = cls._args_schema.data_flows_raw.Element.destinations + destinations.Element = AAZStrArg( + nullable=True, + ) + + streams = cls._args_schema.data_flows_raw.Element.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf", "Microsoft-Syslog": "Microsoft-Syslog", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + ) + + data_sources = cls._args_schema.data_sources + data_sources.data_imports = AAZObjectArg( + options=["data-imports"], + help="Specifications of pull based data sources", + nullable=True, + ) + data_sources.extensions = AAZListArg( + options=["extensions"], + help="The list of Azure VM extension data source configurations.", + nullable=True, + ) + data_sources.iis_logs = AAZListArg( + options=["iis-logs"], + help="The list of IIS logs source configurations.", + nullable=True, + ) + data_sources.log_files = AAZListArg( + options=["log-files"], + help="The list of Log files source configurations.", + nullable=True, + ) + data_sources.performance_counters = AAZListArg( + options=["performance-counters"], + help="The list of performance counter data source configurations.", + nullable=True, + ) + data_sources.platform_telemetry = AAZListArg( + options=["platform-telemetry"], + help="The list of platform telemetry configurations", + nullable=True, + ) + data_sources.prometheus_forwarder = AAZListArg( + options=["prometheus-forwarder"], + help="The list of Prometheus forwarder data source configurations.", + nullable=True, + ) + data_sources.syslog = AAZListArg( + options=["syslog"], + help="The list of Syslog data source configurations.", + nullable=True, + ) + data_sources.windows_event_logs = AAZListArg( + options=["windows-event-logs"], + help="The list of Windows Event Log data source configurations.", + nullable=True, + ) + data_sources.windows_firewall_logs = AAZListArg( + options=["windows-firewall-logs"], + help="The list of Windows Firewall logs source configurations.", + nullable=True, + ) + + data_imports = cls._args_schema.data_sources.data_imports + data_imports.event_hub = AAZObjectArg( + options=["event-hub"], + help="Definition of Event Hub configuration.", + nullable=True, + ) + + event_hub = cls._args_schema.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrArg( + options=["consumer-group"], + help="Event Hub consumer group name", + nullable=True, + ) + event_hub.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + event_hub.stream = AAZStrArg( + options=["stream"], + help="The stream to collect from EventHub", + nullable=True, + ) + + extensions = cls._args_schema.data_sources.extensions + extensions.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.extensions.Element + _element.extension_name = AAZStrArg( + options=["extension-name"], + help="The name of the VM extension.", + ) + _element.extension_settings = AAZObjectArg( + options=["extension-settings"], + help="The extension settings. The format is specific for particular extension.", + nullable=True, + blank={}, + ) + _element.input_data_sources = AAZListArg( + options=["input-data-sources"], + help="The list of data sources this extension needs data from.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + nullable=True, + ) + + input_data_sources = cls._args_schema.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrArg( + nullable=True, + ) + + streams = cls._args_schema.data_sources.extensions.Element.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf", "Microsoft-Syslog": "Microsoft-Syslog", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + ) + + iis_logs = cls._args_schema.data_sources.iis_logs + iis_logs.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.iis_logs.Element + _element.log_directories = AAZListArg( + options=["log-directories"], + help="Absolute paths file location", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="IIS streams", + ) + + log_directories = cls._args_schema.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrArg( + nullable=True, + ) + + streams = cls._args_schema.data_sources.iis_logs.Element.streams + streams.Element = AAZStrArg( + nullable=True, + ) + + log_files = cls._args_schema.data_sources.log_files + log_files.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.log_files.Element + _element.file_patterns = AAZListArg( + options=["file-patterns"], + help="File Patterns where the log files are located", + ) + _element.format = AAZStrArg( + options=["format"], + help="The data format of the log files", + enum={"text": "text"}, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.settings = AAZObjectArg( + options=["settings"], + help="The log files specific settings.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data source", + ) + + file_patterns = cls._args_schema.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrArg( + nullable=True, + ) + + settings = cls._args_schema.data_sources.log_files.Element.settings + settings.text = AAZObjectArg( + options=["text"], + help="Text settings", + nullable=True, + ) + + text = cls._args_schema.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrArg( + options=["record-start-timestamp-format"], + help="One of the supported timestamp formats", + enum={"ISO 8601": "ISO 8601", "M/D/YYYY HH:MM:SS AM/PM": "M/D/YYYY HH:MM:SS AM/PM", "MMM d hh:mm:ss": "MMM d hh:mm:ss", "Mon DD, YYYY HH:MM:SS": "Mon DD, YYYY HH:MM:SS", "YYYY-MM-DD HH:MM:SS": "YYYY-MM-DD HH:MM:SS", "dd/MMM/yyyy:HH:mm:ss zzz": "dd/MMM/yyyy:HH:mm:ss zzz", "ddMMyy HH:mm:ss": "ddMMyy HH:mm:ss", "yyMMdd HH:mm:ss": "yyMMdd HH:mm:ss", "yyyy-MM-ddTHH:mm:ssK": "yyyy-MM-ddTHH:mm:ssK"}, + ) + + streams = cls._args_schema.data_sources.log_files.Element.streams + streams.Element = AAZStrArg( + nullable=True, + ) + + performance_counters = cls._args_schema.data_sources.performance_counters + performance_counters.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListArg( + options=["counter-specifiers"], + help="A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.sampling_frequency_in_seconds = AAZIntArg( + options=["sampling-frequency-in-seconds"], + help="The number of seconds between consecutive counter measurements (samples).", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + nullable=True, + ) + + counter_specifiers = cls._args_schema.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrArg( + nullable=True, + ) + + streams = cls._args_schema.data_sources.performance_counters.Element.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf"}, + ) + + platform_telemetry = cls._args_schema.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.platform_telemetry.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of platform telemetry streams to collect", + ) + + streams = cls._args_schema.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrArg( + nullable=True, + ) + + prometheus_forwarder = cls._args_schema.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictArg( + options=["label-include-filter"], + help="The list of label inclusion filters in the form of label \"name-value\" pairs. Currently only one label is supported: 'microsoft_metrics_include_label'. Label values are matched case-insensitively.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to.", + nullable=True, + ) + + label_include_filter = cls._args_schema.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrArg( + nullable=True, + ) + + streams = cls._args_schema.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-PrometheusMetrics": "Microsoft-PrometheusMetrics"}, + ) + + syslog = cls._args_schema.data_sources.syslog + syslog.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.syslog.Element + _element.facility_names = AAZListArg( + options=["facility-names"], + help="The list of facility names.", + nullable=True, + ) + _element.log_levels = AAZListArg( + options=["log-levels"], + help="The log levels to collect.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + nullable=True, + ) + + facility_names = cls._args_schema.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrArg( + nullable=True, + enum={"*": "*", "auth": "auth", "authpriv": "authpriv", "cron": "cron", "daemon": "daemon", "kern": "kern", "local0": "local0", "local1": "local1", "local2": "local2", "local3": "local3", "local4": "local4", "local5": "local5", "local6": "local6", "local7": "local7", "lpr": "lpr", "mail": "mail", "mark": "mark", "news": "news", "syslog": "syslog", "user": "user", "uucp": "uucp"}, + ) + + log_levels = cls._args_schema.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrArg( + nullable=True, + enum={"*": "*", "Alert": "Alert", "Critical": "Critical", "Debug": "Debug", "Emergency": "Emergency", "Error": "Error", "Info": "Info", "Notice": "Notice", "Warning": "Warning"}, + ) + + streams = cls._args_schema.data_sources.syslog.Element.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-Syslog": "Microsoft-Syslog"}, + ) + + windows_event_logs = cls._args_schema.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.windows_event_logs.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + nullable=True, + ) + _element.x_path_queries = AAZListArg( + options=["x-path-queries"], + help="A list of Windows Event Log queries in XPATH format.", + nullable=True, + ) + + streams = cls._args_schema.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + ) + + x_path_queries = cls._args_schema.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrArg( + nullable=True, + ) + + windows_firewall_logs = cls._args_schema.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.data_sources.windows_firewall_logs.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.streams = AAZListArg( + options=["streams"], + help="Firewall logs streams", + ) + + streams = cls._args_schema.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrArg( + nullable=True, + ) + + destinations = cls._args_schema.destinations + destinations.azure_monitor_metrics = AAZObjectArg( + options=["azure-monitor-metrics"], + help="Azure Monitor Metrics destination.", + nullable=True, + ) + destinations.event_hubs = AAZListArg( + options=["event-hubs"], + help="List of Event Hubs destinations.", + nullable=True, + ) + destinations.event_hubs_direct = AAZListArg( + options=["event-hubs-direct"], + help="List of Event Hubs Direct destinations.", + nullable=True, + ) + destinations.log_analytics = AAZListArg( + options=["log-analytics"], + help="List of Log Analytics destinations.", + nullable=True, + ) + destinations.monitoring_accounts = AAZListArg( + options=["monitoring-accounts"], + help="List of monitoring account destinations.", + nullable=True, + ) + destinations.storage_accounts = AAZListArg( + options=["storage-accounts"], + help="List of storage accounts destinations.", + nullable=True, + ) + destinations.storage_blobs_direct = AAZListArg( + options=["storage-blobs-direct"], + help="List of Storage Blob Direct destinations. To be used only for sending data directly to store from the agent.", + nullable=True, + ) + destinations.storage_tables_direct = AAZListArg( + options=["storage-tables-direct"], + help="List of Storage Table Direct destinations.", + nullable=True, + ) + + azure_monitor_metrics = cls._args_schema.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + nullable=True, + ) + + event_hubs = cls._args_schema.destinations.event_hubs + event_hubs.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrArg( + options=["event-hub-resource-id"], + help="The resource ID of the event hub.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + nullable=True, + ) + + event_hubs_direct = cls._args_schema.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrArg( + options=["event-hub-resource-id"], + help="The resource ID of the event hub.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + nullable=True, + ) + + log_analytics = cls._args_schema.destinations.log_analytics + log_analytics.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.destinations.log_analytics.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.workspace_resource_id = AAZStrArg( + options=["workspace-resource-id"], + help="The resource ID of the Log Analytics workspace.", + nullable=True, + ) + + monitoring_accounts = cls._args_schema.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.destinations.monitoring_accounts.Element + _element.account_resource_id = AAZStrArg( + options=["account-resource-id"], + help="The resource ID of the monitoring account.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + nullable=True, + ) + + storage_accounts = cls._args_schema.destinations.storage_accounts + storage_accounts.Element = AAZObjectArg( + nullable=True, + ) + cls._build_args_storage_blob_destination_update(storage_accounts.Element) + + storage_blobs_direct = cls._args_schema.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectArg( + nullable=True, + ) + cls._build_args_storage_blob_destination_update(storage_blobs_direct.Element) + + storage_tables_direct = cls._args_schema.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.destinations.storage_tables_direct.Element + _element.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + nullable=True, + ) + _element.storage_account_resource_id = AAZStrArg( + options=["storage-account-resource-id"], + help="The resource ID of the storage account.", + nullable=True, + ) + _element.table_name = AAZStrArg( + options=["table-name"], + help="The name of the Storage Table.", + nullable=True, + ) + + stream_declarations = cls._args_schema.stream_declarations + stream_declarations.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.stream_declarations.Element + _element.columns = AAZListArg( + options=["columns"], + help="List of columns used by data in this stream.", + nullable=True, + ) + + columns = cls._args_schema.stream_declarations.Element.columns + columns.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.stream_declarations.Element.columns.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of the column.", + nullable=True, + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of the column data.", + nullable=True, + enum={"boolean": "boolean", "datetime": "datetime", "dynamic": "dynamic", "int": "int", "long": "long", "real": "real", "string": "string"}, + ) + return cls._args_schema + + _args_storage_blob_destination_update = None + + @classmethod + def _build_args_storage_blob_destination_update(cls, _schema): + if cls._args_storage_blob_destination_update is not None: + _schema.container_name = cls._args_storage_blob_destination_update.container_name + _schema.name = cls._args_storage_blob_destination_update.name + _schema.storage_account_resource_id = cls._args_storage_blob_destination_update.storage_account_resource_id + return + + cls._args_storage_blob_destination_update = AAZObjectArg( + nullable=True, + ) + + storage_blob_destination_update = cls._args_storage_blob_destination_update + storage_blob_destination_update.container_name = AAZStrArg( + options=["container-name"], + help="The container name of the Storage Blob.", + nullable=True, + ) + storage_blob_destination_update.name = AAZStrArg( + options=["name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + nullable=True, + ) + storage_blob_destination_update.storage_account_resource_id = AAZStrArg( + options=["storage-account-resource-id"], + help="The resource ID of the storage account.", + nullable=True, + ) + + _schema.container_name = cls._args_storage_blob_destination_update.container_name + _schema.name = cls._args_storage_blob_destination_update.name + _schema.storage_account_resource_id = cls._args_storage_blob_destination_update.storage_account_resource_id + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("identity", AAZIdentityObjectType, ".identity") + _builder.set_prop("kind", AAZStrType, ".kind") + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".", typ_kwargs={"nullable": True}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("dataCollectionEndpointId", AAZStrType, ".data_collection_endpoint_id") + properties.set_prop("dataFlows", AAZListType, ".data_flows_raw") + properties.set_prop("dataSources", AAZObjectType, ".data_sources") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("destinations", AAZObjectType, ".destinations") + properties.set_prop("streamDeclarations", AAZDictType, ".stream_declarations") + + data_flows = _builder.get(".properties.dataFlows") + if data_flows is not None: + data_flows.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataFlows[]") + if _elements is not None: + _elements.set_prop("builtInTransform", AAZStrType, ".built_in_transform") + _elements.set_prop("destinations", AAZListType, ".destinations") + _elements.set_prop("outputStream", AAZStrType, ".output_stream") + _elements.set_prop("streams", AAZListType, ".streams") + _elements.set_prop("transformKql", AAZStrType, ".transform_kql") + + destinations = _builder.get(".properties.dataFlows[].destinations") + if destinations is not None: + destinations.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataFlows[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + data_sources = _builder.get(".properties.dataSources") + if data_sources is not None: + data_sources.set_prop("dataImports", AAZObjectType, ".data_imports") + data_sources.set_prop("extensions", AAZListType, ".extensions") + data_sources.set_prop("iisLogs", AAZListType, ".iis_logs") + data_sources.set_prop("logFiles", AAZListType, ".log_files") + data_sources.set_prop("performanceCounters", AAZListType, ".performance_counters") + data_sources.set_prop("platformTelemetry", AAZListType, ".platform_telemetry") + data_sources.set_prop("prometheusForwarder", AAZListType, ".prometheus_forwarder") + data_sources.set_prop("syslog", AAZListType, ".syslog") + data_sources.set_prop("windowsEventLogs", AAZListType, ".windows_event_logs") + data_sources.set_prop("windowsFirewallLogs", AAZListType, ".windows_firewall_logs") + + data_imports = _builder.get(".properties.dataSources.dataImports") + if data_imports is not None: + data_imports.set_prop("eventHub", AAZObjectType, ".event_hub") + + event_hub = _builder.get(".properties.dataSources.dataImports.eventHub") + if event_hub is not None: + event_hub.set_prop("consumerGroup", AAZStrType, ".consumer_group") + event_hub.set_prop("name", AAZStrType, ".name") + event_hub.set_prop("stream", AAZStrType, ".stream") + + extensions = _builder.get(".properties.dataSources.extensions") + if extensions is not None: + extensions.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.extensions[]") + if _elements is not None: + _elements.set_prop("extensionName", AAZStrType, ".extension_name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("extensionSettings", AAZObjectType, ".extension_settings") + _elements.set_prop("inputDataSources", AAZListType, ".input_data_sources") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + + input_data_sources = _builder.get(".properties.dataSources.extensions[].inputDataSources") + if input_data_sources is not None: + input_data_sources.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.extensions[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + iis_logs = _builder.get(".properties.dataSources.iisLogs") + if iis_logs is not None: + iis_logs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.iisLogs[]") + if _elements is not None: + _elements.set_prop("logDirectories", AAZListType, ".log_directories") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + log_directories = _builder.get(".properties.dataSources.iisLogs[].logDirectories") + if log_directories is not None: + log_directories.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.iisLogs[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + log_files = _builder.get(".properties.dataSources.logFiles") + if log_files is not None: + log_files.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.logFiles[]") + if _elements is not None: + _elements.set_prop("filePatterns", AAZListType, ".file_patterns", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("format", AAZStrType, ".format", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("settings", AAZObjectType, ".settings") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + file_patterns = _builder.get(".properties.dataSources.logFiles[].filePatterns") + if file_patterns is not None: + file_patterns.set_elements(AAZStrType, ".") + + settings = _builder.get(".properties.dataSources.logFiles[].settings") + if settings is not None: + settings.set_prop("text", AAZObjectType, ".text") + + text = _builder.get(".properties.dataSources.logFiles[].settings.text") + if text is not None: + text.set_prop("recordStartTimestampFormat", AAZStrType, ".record_start_timestamp_format", typ_kwargs={"flags": {"required": True}}) + + streams = _builder.get(".properties.dataSources.logFiles[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + performance_counters = _builder.get(".properties.dataSources.performanceCounters") + if performance_counters is not None: + performance_counters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.performanceCounters[]") + if _elements is not None: + _elements.set_prop("counterSpecifiers", AAZListType, ".counter_specifiers") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("samplingFrequencyInSeconds", AAZIntType, ".sampling_frequency_in_seconds") + _elements.set_prop("streams", AAZListType, ".streams") + + counter_specifiers = _builder.get(".properties.dataSources.performanceCounters[].counterSpecifiers") + if counter_specifiers is not None: + counter_specifiers.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.performanceCounters[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + platform_telemetry = _builder.get(".properties.dataSources.platformTelemetry") + if platform_telemetry is not None: + platform_telemetry.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.platformTelemetry[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + streams = _builder.get(".properties.dataSources.platformTelemetry[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + prometheus_forwarder = _builder.get(".properties.dataSources.prometheusForwarder") + if prometheus_forwarder is not None: + prometheus_forwarder.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.prometheusForwarder[]") + if _elements is not None: + _elements.set_prop("labelIncludeFilter", AAZDictType, ".label_include_filter") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + + label_include_filter = _builder.get(".properties.dataSources.prometheusForwarder[].labelIncludeFilter") + if label_include_filter is not None: + label_include_filter.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.prometheusForwarder[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + syslog = _builder.get(".properties.dataSources.syslog") + if syslog is not None: + syslog.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.syslog[]") + if _elements is not None: + _elements.set_prop("facilityNames", AAZListType, ".facility_names") + _elements.set_prop("logLevels", AAZListType, ".log_levels") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + + facility_names = _builder.get(".properties.dataSources.syslog[].facilityNames") + if facility_names is not None: + facility_names.set_elements(AAZStrType, ".") + + log_levels = _builder.get(".properties.dataSources.syslog[].logLevels") + if log_levels is not None: + log_levels.set_elements(AAZStrType, ".") + + streams = _builder.get(".properties.dataSources.syslog[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + windows_event_logs = _builder.get(".properties.dataSources.windowsEventLogs") + if windows_event_logs is not None: + windows_event_logs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.windowsEventLogs[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams") + _elements.set_prop("xPathQueries", AAZListType, ".x_path_queries") + + streams = _builder.get(".properties.dataSources.windowsEventLogs[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + x_path_queries = _builder.get(".properties.dataSources.windowsEventLogs[].xPathQueries") + if x_path_queries is not None: + x_path_queries.set_elements(AAZStrType, ".") + + windows_firewall_logs = _builder.get(".properties.dataSources.windowsFirewallLogs") + if windows_firewall_logs is not None: + windows_firewall_logs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.dataSources.windowsFirewallLogs[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("streams", AAZListType, ".streams", typ_kwargs={"flags": {"required": True}}) + + streams = _builder.get(".properties.dataSources.windowsFirewallLogs[].streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + destinations = _builder.get(".properties.destinations") + if destinations is not None: + destinations.set_prop("azureMonitorMetrics", AAZObjectType, ".azure_monitor_metrics") + destinations.set_prop("eventHubs", AAZListType, ".event_hubs") + destinations.set_prop("eventHubsDirect", AAZListType, ".event_hubs_direct") + destinations.set_prop("logAnalytics", AAZListType, ".log_analytics") + destinations.set_prop("monitoringAccounts", AAZListType, ".monitoring_accounts") + destinations.set_prop("storageAccounts", AAZListType, ".storage_accounts") + destinations.set_prop("storageBlobsDirect", AAZListType, ".storage_blobs_direct") + destinations.set_prop("storageTablesDirect", AAZListType, ".storage_tables_direct") + + azure_monitor_metrics = _builder.get(".properties.destinations.azureMonitorMetrics") + if azure_monitor_metrics is not None: + azure_monitor_metrics.set_prop("name", AAZStrType, ".name") + + event_hubs = _builder.get(".properties.destinations.eventHubs") + if event_hubs is not None: + event_hubs.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.eventHubs[]") + if _elements is not None: + _elements.set_prop("eventHubResourceId", AAZStrType, ".event_hub_resource_id") + _elements.set_prop("name", AAZStrType, ".name") + + event_hubs_direct = _builder.get(".properties.destinations.eventHubsDirect") + if event_hubs_direct is not None: + event_hubs_direct.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.eventHubsDirect[]") + if _elements is not None: + _elements.set_prop("eventHubResourceId", AAZStrType, ".event_hub_resource_id") + _elements.set_prop("name", AAZStrType, ".name") + + log_analytics = _builder.get(".properties.destinations.logAnalytics") + if log_analytics is not None: + log_analytics.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.logAnalytics[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("workspaceResourceId", AAZStrType, ".workspace_resource_id") + + monitoring_accounts = _builder.get(".properties.destinations.monitoringAccounts") + if monitoring_accounts is not None: + monitoring_accounts.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.monitoringAccounts[]") + if _elements is not None: + _elements.set_prop("accountResourceId", AAZStrType, ".account_resource_id") + _elements.set_prop("name", AAZStrType, ".name") + + storage_accounts = _builder.get(".properties.destinations.storageAccounts") + if storage_accounts is not None: + _UpdateHelper._build_schema_storage_blob_destination_update(storage_accounts.set_elements(AAZObjectType, ".")) + + storage_blobs_direct = _builder.get(".properties.destinations.storageBlobsDirect") + if storage_blobs_direct is not None: + _UpdateHelper._build_schema_storage_blob_destination_update(storage_blobs_direct.set_elements(AAZObjectType, ".")) + + storage_tables_direct = _builder.get(".properties.destinations.storageTablesDirect") + if storage_tables_direct is not None: + storage_tables_direct.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.destinations.storageTablesDirect[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("storageAccountResourceId", AAZStrType, ".storage_account_resource_id") + _elements.set_prop("tableName", AAZStrType, ".table_name") + + stream_declarations = _builder.get(".properties.streamDeclarations") + if stream_declarations is not None: + stream_declarations.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.streamDeclarations{}") + if _elements is not None: + _elements.set_prop("columns", AAZListType, ".columns") + + columns = _builder.get(".properties.streamDeclarations{}.columns") + if columns is not None: + columns.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.streamDeclarations{}.columns[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("type", AAZStrType, ".type") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + @classmethod + def _build_schema_storage_blob_destination_update(cls, _builder): + if _builder is None: + return + _builder.set_prop("containerName", AAZStrType, ".container_name") + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("storageAccountResourceId", AAZStrType, ".storage_account_resource_id") + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZObjectType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/__cmd_group.py new file mode 100644 index 00000000000..89afcd423a4 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection rule association", +) +class __CMDGroup(AAZCommandGroup): + """Manage data collection rule association for monitor control service. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/__init__.py new file mode 100644 index 00000000000..f1921df162e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._list_by_resource import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_create.py new file mode 100644 index 00000000000..ea6f7c23193 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_create.py @@ -0,0 +1,262 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule association create", +) +class Create(AAZCommand): + """Create an association. + + :example: Create association + az monitor data-collection rule association create --name "myAssociation" --rule-id "/subscriptions/703362b3-f278-4e4b-9179- c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules/myCollectionRule" --resource "subscriptions/703362b3-f278-4e4b-9179- c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm " + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/{resourceuri}/providers/microsoft.insights/datacollectionruleassociations/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the association. The name is case insensitive.", + required=True, + ) + _args_schema.resource_uri = AAZStrArg( + options=["--resource", "--resource-uri"], + help="The identifier of the resource.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.data_collection_endpoint_id = AAZStrArg( + options=["--endpoint-id", "--data-collection-endpoint-id"], + help="The resource ID of the data collection endpoint that is to be associated.", + ) + _args_schema.data_collection_rule_id = AAZStrArg( + options=["--rule-id", "--data-collection-rule-id"], + help="The resource ID of the data collection rule that is to be associated.", + ) + _args_schema.description = AAZStrArg( + options=["--description"], + help="Description of the association.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRuleAssociationsCreate(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 DataCollectionRuleAssociationsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "resourceUri", self.ctx.args.resource_uri, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("dataCollectionEndpointId", AAZStrType, ".data_collection_endpoint_id") + properties.set_prop("dataCollectionRuleId", AAZStrType, ".data_collection_rule_id") + properties.set_prop("description", AAZStrType, ".description") + + 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.etag = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_collection_rule_id = AAZStrType( + serialized_name="dataCollectionRuleId", + ) + properties.description = AAZStrType() + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200_201.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_delete.py new file mode 100644 index 00000000000..5f1f99b7600 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_delete.py @@ -0,0 +1,140 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule association delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an association. + + :example: Delete association + az monitor data-collection rule association delete --name "myAssociation" --resource "subscr iptions/703362b3-f278-4e4b-9179- c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm " + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/{resourceuri}/providers/microsoft.insights/datacollectionruleassociations/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the association. The name is case insensitive.", + required=True, + ) + _args_schema.resource_uri = AAZStrArg( + options=["--resource", "--resource-uri"], + help="The identifier of the resource.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRuleAssociationsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DataCollectionRuleAssociationsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "resourceUri", self.ctx.args.resource_uri, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_list.py new file mode 100644 index 00000000000..cdd303e5ffd --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_list.py @@ -0,0 +1,238 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule association list", +) +class List(AAZCommand): + """List associations for the specified data collection rule. + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}/associations", "2022-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRuleAssociationsListByRule(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 DataCollectionRuleAssociationsListByRule(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType( + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_collection_rule_id = AAZStrType( + serialized_name="dataCollectionRuleId", + ) + properties.description = AAZStrType() + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_list_by_resource.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_list_by_resource.py new file mode 100644 index 00000000000..826ec898fe2 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_list_by_resource.py @@ -0,0 +1,231 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule association list-by-resource", +) +class ListByResource(AAZCommand): + """List associations for the specified resource. + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/{resourceuri}/providers/microsoft.insights/datacollectionruleassociations", "2022-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_uri = AAZStrArg( + options=["--resource", "--resource-uri"], + help="The identifier of the resource.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRuleAssociationsListByResource(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 DataCollectionRuleAssociationsListByResource(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations", + **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( + "resourceUri", self.ctx.args.resource_uri, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.etag = AAZStrType( + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_collection_rule_id = AAZStrType( + serialized_name="dataCollectionRuleId", + ) + properties.description = AAZStrType() + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListByResourceHelper: + """Helper class for ListByResource""" + + +__all__ = ["ListByResource"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_show.py new file mode 100644 index 00000000000..7702e37e3cf --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_show.py @@ -0,0 +1,230 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule association show", +) +class Show(AAZCommand): + """Get the specified association. + + :example: Get association + az monitor data-collection rule association show --name "myAssociation" --resource "subscrip tions/703362b3-f278-4e4b-9179- c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm " + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/{resourceuri}/providers/microsoft.insights/datacollectionruleassociations/{}", "2022-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the association. The name is case insensitive.", + required=True, + ) + _args_schema.resource_uri = AAZStrArg( + options=["--resource", "--resource-uri"], + help="The identifier of the resource.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRuleAssociationsGet(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 DataCollectionRuleAssociationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "resourceUri", self.ctx.args.resource_uri, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.etag = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_collection_rule_id = AAZStrType( + serialized_name="dataCollectionRuleId", + ) + properties.description = AAZStrType() + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_update.py new file mode 100644 index 00000000000..3bee886b95c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/association/_update.py @@ -0,0 +1,404 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule association update", +) +class Update(AAZCommand): + """Update an association. + + :example: Update association + az monitor data-collection rule association update --name "myAssociation" --rule-id "/subscr iptions/703362b3-f278-4e4b-9179- c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules /myCollectionRule" --resource "subscriptions/703362b3-f278-4e4b-9179- c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm " + """ + + _aaz_info = { + "version": "2022-06-01", + "resources": [ + ["mgmt-plane", "/{resourceuri}/providers/microsoft.insights/datacollectionruleassociations/{}", "2022-06-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the association. The name is case insensitive.", + required=True, + ) + _args_schema.resource_uri = AAZStrArg( + options=["--resource", "--resource-uri"], + help="The identifier of the resource.", + required=True, + fmt=AAZStrArgFormat( + min_length=1, + ), + ) + _args_schema.data_collection_endpoint_id = AAZStrArg( + options=["--endpoint-id", "--data-collection-endpoint-id"], + help="The resource ID of the data collection endpoint that is to be associated.", + nullable=True, + ) + _args_schema.data_collection_rule_id = AAZStrArg( + options=["--rule-id", "--data-collection-rule-id"], + help="The resource ID of the data collection rule that is to be associated.", + nullable=True, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + help="Description of the association.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRuleAssociationsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.DataCollectionRuleAssociationsCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DataCollectionRuleAssociationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "resourceUri", self.ctx.args.resource_uri, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_association_proxy_only_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRuleAssociationsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "resourceUri", self.ctx.args.resource_uri, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2022-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_association_proxy_only_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("dataCollectionEndpointId", AAZStrType, ".data_collection_endpoint_id") + properties.set_prop("dataCollectionRuleId", AAZStrType, ".data_collection_rule_id") + properties.set_prop("description", AAZStrType, ".description") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_collection_rule_association_proxy_only_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_association_proxy_only_resource_read(cls, _schema): + if cls._schema_data_collection_rule_association_proxy_only_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_association_proxy_only_resource_read.etag + _schema.id = cls._schema_data_collection_rule_association_proxy_only_resource_read.id + _schema.name = cls._schema_data_collection_rule_association_proxy_only_resource_read.name + _schema.properties = cls._schema_data_collection_rule_association_proxy_only_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_association_proxy_only_resource_read.system_data + _schema.type = cls._schema_data_collection_rule_association_proxy_only_resource_read.type + return + + cls._schema_data_collection_rule_association_proxy_only_resource_read = _schema_data_collection_rule_association_proxy_only_resource_read = AAZObjectType() + + data_collection_rule_association_proxy_only_resource_read = _schema_data_collection_rule_association_proxy_only_resource_read + data_collection_rule_association_proxy_only_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_association_proxy_only_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_association_proxy_only_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_association_proxy_only_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_association_proxy_only_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_association_proxy_only_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_association_proxy_only_resource_read.properties + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_collection_rule_id = AAZStrType( + serialized_name="dataCollectionRuleId", + ) + properties.description = AAZStrType() + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_association_proxy_only_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + system_data = _schema_data_collection_rule_association_proxy_only_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.etag = cls._schema_data_collection_rule_association_proxy_only_resource_read.etag + _schema.id = cls._schema_data_collection_rule_association_proxy_only_resource_read.id + _schema.name = cls._schema_data_collection_rule_association_proxy_only_resource_read.name + _schema.properties = cls._schema_data_collection_rule_association_proxy_only_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_association_proxy_only_resource_read.system_data + _schema.type = cls._schema_data_collection_rule_association_proxy_only_resource_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/__cmd_group.py new file mode 100644 index 00000000000..b7a59813c79 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection rule data-flow", +) +class __CMDGroup(AAZCommandGroup): + """Manage data flows. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/__init__.py new file mode 100644 index 00000000000..a48ea3a919f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._add import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_add.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_add.py new file mode 100644 index 00000000000..4e652d4b775 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_add.py @@ -0,0 +1,991 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule data-flow add", +) +class Add(AAZCommand): + """Add a data flow. + + :example: Add a data flow + az monitor data-collection rule data-flow add --rule-name myCollectionRule --resource-group myResourceGroup --destinations XX3 XX4 --streams Microsoft-Perf Microsoft-WindowsEvent + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataFlows[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.data_flow_index = AAZIntArg( + options=["--data-flow-index"], + help="data flow ind", + ) + _args_schema.built_in_transform = AAZStrArg( + options=["--built-in-transform"], + help="The builtIn transform to transform stream data", + ) + _args_schema.capture_overflow = AAZBoolArg( + options=["--capture-overflow"], + help="Flag to enable overflow column in LA destinations", + ) + _args_schema.destinations = AAZListArg( + options=["--destinations"], + help="List of destinations for this data flow.", + ) + _args_schema.output_stream = AAZStrArg( + options=["--output-stream"], + help="The output stream of the transform. Only required if the transform changes data to a different stream.", + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams for this data flow.", + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + help="The KQL query to transform stream data.", + ) + + destinations = cls._args_schema.destinations + destinations.Element = AAZStrArg() + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf", "Microsoft-Syslog": "Microsoft-Syslog", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + enum_support_extension=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_create() + self.InstanceCreateByJson(ctx=self.ctx)() + self.post_instance_create(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_create(self): + pass + + @register_callback + def post_instance_create(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters, [len(result)])[0] + self.ctx.args.data_flow_index = idx + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceCreateByJson(AAZJsonInstanceCreateOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._create_instance()) + + def _create_instance(self): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType + ) + _builder.set_prop("builtInTransform", AAZStrType, ".built_in_transform") + _builder.set_prop("captureOverflow", AAZBoolType, ".capture_overflow") + _builder.set_prop("destinations", AAZListType, ".destinations") + _builder.set_prop("outputStream", AAZStrType, ".output_stream") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + + destinations = _builder.get(".destinations") + if destinations is not None: + destinations.set_elements(AAZStrType, ".") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + return _instance_value + + +class _AddHelper: + """Helper class for Add""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Add"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_delete.py new file mode 100644 index 00000000000..622d4135a8f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_delete.py @@ -0,0 +1,930 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule data-flow delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """monitor data-collection rule data-flow delete + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataFlows[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.data_flow_index = AAZIntArg( + options=["--data-flow-index"], + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_delete() + self.InstanceDeleteByJson(ctx=self.ctx)() + self.post_instance_delete() + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_delete(self): + pass + + @register_callback + def post_instance_delete(self): + pass + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters, [len(result)])[0] + self.ctx.args.data_flow_index = idx + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceDeleteByJson(AAZJsonInstanceDeleteOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._delete_instance()) + + +class _DeleteHelper: + """Helper class for Delete""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_list.py new file mode 100644 index 00000000000..68bace6b654 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_list.py @@ -0,0 +1,805 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule data-flow list", +) +class List(AAZCommand): + """List data flows. + + :example: List data flows + az monitor data-collection rule data-flow list --rule-name myCollectionRule --resource-group myResourceGroup + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataFlows"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.properties.dataFlows + + def _set(self, value): + result = self.ctx.vars.instance + result.properties.dataFlows = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _ListHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_show.py new file mode 100644 index 00000000000..d91ed8fd59f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_show.py @@ -0,0 +1,821 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule data-flow show", +) +class Show(AAZCommand): + """monitor data-collection rule data-flow show + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataFlows[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.data_flow_index = AAZIntArg( + options=["--data-flow-index"], + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters, [len(result)])[0] + self.ctx.args.data_flow_index = idx + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_update.py new file mode 100644 index 00000000000..16f4199b5f4 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/data_flow/_update.py @@ -0,0 +1,1017 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule data-flow update", +) +class Update(AAZCommand): + """monitor data-collection rule data-flow update + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataFlows[]"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.data_flow_index = AAZIntArg( + options=["--data-flow-index"], + required=True, + ) + _args_schema.output_stream = AAZStrArg( + options=["--output-stream"], + help="The output stream of the transform. Only required if the transform changes data to a different stream.", + nullable=True, + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams for this data flow.", + nullable=True, + ) + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf", "Microsoft-Syslog": "Microsoft-Syslog", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + enum_support_extension=True, + ) + + # define Arg Group "Body.properties.dataFlows[]" + + _args_schema = cls._args_schema + _args_schema.built_in_transform = AAZStrArg( + options=["--built-in-transform"], + arg_group="Body.properties.dataFlows[]", + help="The builtIn transform to transform stream data", + nullable=True, + ) + _args_schema.capture_overflow = AAZBoolArg( + options=["--capture-overflow"], + arg_group="Body.properties.dataFlows[]", + help="Flag to enable overflow column in LA destinations", + nullable=True, + ) + _args_schema.destinations = AAZListArg( + options=["--destinations"], + arg_group="Body.properties.dataFlows[]", + help="List of destinations for this data flow.", + nullable=True, + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + arg_group="Body.properties.dataFlows[]", + help="The KQL query to transform stream data.", + nullable=True, + ) + + destinations = cls._args_schema.destinations + destinations.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataFlows + filters = enumerate(result) + filters = filter( + lambda e: e[0] == self.ctx.args.data_flow_index, + filters + ) + idx = next(filters, [len(result)])[0] + self.ctx.args.data_flow_index = idx + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("builtInTransform", AAZStrType, ".built_in_transform") + _builder.set_prop("captureOverflow", AAZBoolType, ".capture_overflow") + _builder.set_prop("destinations", AAZListType, ".destinations") + _builder.set_prop("outputStream", AAZStrType, ".output_stream") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + + destinations = _builder.get(".destinations") + if destinations is not None: + destinations.set_elements(AAZStrType, ".") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.selectors.subresource.get(), + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/__cmd_group.py new file mode 100644 index 00000000000..891e9b18311 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection rule log-analytics", +) +class __CMDGroup(AAZCommandGroup): + """Manage Log Analytics destinations. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/__init__.py new file mode 100644 index 00000000000..a48ea3a919f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._add import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_add.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_add.py new file mode 100644 index 00000000000..79932159b8a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_add.py @@ -0,0 +1,950 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule log-analytics add", +) +class Add(AAZCommand): + """Add Log Analytics destinations of a data collection rule. + + :example: Add Log Analytics destinations of a data collection rule + az monitor data-collection rule log-analytics add --rule-name myCollectionRule --resource-group myResourceGroup --name workspace2 --resource-id /subscriptions/703362b3-f2784e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/workspace2 + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.destinations.logAnalytics[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.workspace_resource_id = AAZStrArg( + options=["--resource-id", "--workspace-resource-id"], + help="The resource ID of the Log Analytics workspace.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_create() + self.InstanceCreateByJson(ctx=self.ctx)() + self.post_instance_create(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_create(self): + pass + + @register_callback + def post_instance_create(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceCreateByJson(AAZJsonInstanceCreateOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._create_instance()) + + def _create_instance(self): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType + ) + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("workspaceResourceId", AAZStrType, ".workspace_resource_id") + + return _instance_value + + +class _AddHelper: + """Helper class for Add""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Add"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_delete.py new file mode 100644 index 00000000000..88219049b9e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_delete.py @@ -0,0 +1,932 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule log-analytics delete", +) +class Delete(AAZCommand): + """Delete a Log Analytics destinations of a data collection rule. + + :example: Delete a Log Analytics destinations of a data collection rule + az monitor data-collection rule log-analytics delete --rule-name myCollectionRule --resource-group myResourceGroup --name workspace2 + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.destinations.logAnalytics[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_delete() + self.InstanceDeleteByJson(ctx=self.ctx)() + self.post_instance_delete() + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_delete(self): + pass + + @register_callback + def post_instance_delete(self): + pass + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceDeleteByJson(AAZJsonInstanceDeleteOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._delete_instance()) + + +class _DeleteHelper: + """Helper class for Delete""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_list.py new file mode 100644 index 00000000000..7cf24310845 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_list.py @@ -0,0 +1,805 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule log-analytics list", +) +class List(AAZCommand): + """List Log Analytics destinations of a data collection rule. + + :example: List Log Analytics destinations of a data collection rule + az monitor data-collection rule log-analytics list --rule-name myCollectionRule --resource-group myResourceGroup + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.destinations.logAnalytics"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.properties.destinations.logAnalytics + + def _set(self, value): + result = self.ctx.vars.instance + result.properties.destinations.logAnalytics = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _ListHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_show.py new file mode 100644 index 00000000000..26b47a9ebe1 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_show.py @@ -0,0 +1,824 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule log-analytics show", +) +class Show(AAZCommand): + """Show a Log Analytics destination of a data collection rule. + + :example: Show a Log Analytics destination of a data collection rule + az monitor data-collection rule log-analytics show --rule-name myCollectionRule --resource-group myResourceGroup --name centralWorkspace + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.destinations.logAnalytics[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_update.py new file mode 100644 index 00000000000..f50c98ef024 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/log_analytics/_update.py @@ -0,0 +1,963 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule log-analytics update", +) +class Update(AAZCommand): + """Update a Log Analytics destination of a data collection rule. + + :example: Update a Log Analytics destination of a data collection rule + az monitor data-collection rule log-analytics update --rule-name myCollectionRule --resource-group myResourceGroup --name workspace2 --resource-id "/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/anotherWorkspace" + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.destinations.logAnalytics[]"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.workspace_resource_id = AAZStrArg( + options=["--resource-id", "--workspace-resource-id"], + help="The resource ID of the Log Analytics workspace.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.destinations.logAnalytics + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("workspaceResourceId", AAZStrType, ".workspace_resource_id") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.selectors.subresource.get(), + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/__cmd_group.py new file mode 100644 index 00000000000..4eb1453d8d8 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection rule performance-counter", +) +class __CMDGroup(AAZCommandGroup): + """Manage Log performance counter data source. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/__init__.py new file mode 100644 index 00000000000..a48ea3a919f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._add import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_add.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_add.py new file mode 100644 index 00000000000..ef6388261ca --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_add.py @@ -0,0 +1,982 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule performance-counter add", +) +class Add(AAZCommand): + """Add a Log performance counter data source. + + :example: Add a Log performance counter data source + az monitor data-collection rule performance-counter add --rule-name myCollectionRule --resource-group myResourceGroup --name team2ExtraCounters --streams Microsoft-Perf --counter-specifiers "\\\\Process(_Total)\\\\Thread Count" "\\\\LogicalDisk(_Total)\\\\FreeMegabytes" --sampling-frequency 30 + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.performanceCounters[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.counter_specifiers = AAZListArg( + options=["--counter-specifiers"], + help="A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'.", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.sampling_frequency_in_seconds = AAZIntArg( + options=["--sampling-frequency", "--sampling-frequency-in-seconds"], + help="The number of seconds between consecutive counter measurements (samples).", + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + help="The KQL query to transform the data source.", + ) + + counter_specifiers = cls._args_schema.counter_specifiers + counter_specifiers.Element = AAZStrArg() + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + enum={"Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf"}, + enum_support_extension=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_create() + self.InstanceCreateByJson(ctx=self.ctx)() + self.post_instance_create(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_create(self): + pass + + @register_callback + def post_instance_create(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceCreateByJson(AAZJsonInstanceCreateOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._create_instance()) + + def _create_instance(self): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType + ) + _builder.set_prop("counterSpecifiers", AAZListType, ".counter_specifiers") + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("samplingFrequencyInSeconds", AAZIntType, ".sampling_frequency_in_seconds") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + + counter_specifiers = _builder.get(".counterSpecifiers") + if counter_specifiers is not None: + counter_specifiers.set_elements(AAZStrType, ".") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + return _instance_value + + +class _AddHelper: + """Helper class for Add""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Add"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_delete.py new file mode 100644 index 00000000000..0b822744f04 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_delete.py @@ -0,0 +1,932 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule performance-counter delete", +) +class Delete(AAZCommand): + """Delete a Log performance counter data source. + + :example: Delete a Log performance counter data source + az monitor data-collection rule performance-counter delete --rule-name myCollectionRule --resource-group myResourceGroup --name team2ExtraCounters + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.performanceCounters[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_delete() + self.InstanceDeleteByJson(ctx=self.ctx)() + self.post_instance_delete() + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_delete(self): + pass + + @register_callback + def post_instance_delete(self): + pass + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceDeleteByJson(AAZJsonInstanceDeleteOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._delete_instance()) + + +class _DeleteHelper: + """Helper class for Delete""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_list.py new file mode 100644 index 00000000000..887048ca3f6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_list.py @@ -0,0 +1,805 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule performance-counter list", +) +class List(AAZCommand): + """List Log performance counter data sources. + + :example: List Log performance counter data sources + az monitor data-collection rule performance-counter list --rule-name myCollectionRule --resource-group myResourceGroup + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.performanceCounters"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.properties.dataSources.performanceCounters + + def _set(self, value): + result = self.ctx.vars.instance + result.properties.dataSources.performanceCounters = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _ListHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_show.py new file mode 100644 index 00000000000..2fc35320962 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_show.py @@ -0,0 +1,824 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule performance-counter show", +) +class Show(AAZCommand): + """Show a Log performance counter data source. + + :example: Show a Log performance counter data source + az monitor data-collection rule performance-counter show --rule-name myCollectionRule --resource-group myResourceGroup --name appTeamExtraCounters + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.performanceCounters[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_update.py new file mode 100644 index 00000000000..35207848c62 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/performance_counter/_update.py @@ -0,0 +1,1001 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule performance-counter update", +) +class Update(AAZCommand): + """Update a Log performance counter data source. + + :example: Update a Log performance counter data source + az monitor data-collection rule performance-counter update --rule-name myCollectionRule --resource-group myResourceGroup --name team2ExtraCounters + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.performanceCounters[]"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.counter_specifiers = AAZListArg( + options=["--counter-specifiers"], + help="A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'.", + nullable=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.sampling_frequency_in_seconds = AAZIntArg( + options=["--sampling-frequency", "--sampling-frequency-in-seconds"], + help="The number of seconds between consecutive counter measurements (samples).", + nullable=True, + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + nullable=True, + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + help="The KQL query to transform the data source.", + nullable=True, + ) + + counter_specifiers = cls._args_schema.counter_specifiers + counter_specifiers.Element = AAZStrArg( + nullable=True, + ) + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-InsightsMetrics": "Microsoft-InsightsMetrics", "Microsoft-Perf": "Microsoft-Perf"}, + enum_support_extension=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.performanceCounters + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("counterSpecifiers", AAZListType, ".counter_specifiers") + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("samplingFrequencyInSeconds", AAZIntType, ".sampling_frequency_in_seconds") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + + counter_specifiers = _builder.get(".counterSpecifiers") + if counter_specifiers is not None: + counter_specifiers.set_elements(AAZStrType, ".") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.selectors.subresource.get(), + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/__cmd_group.py new file mode 100644 index 00000000000..1ef9073837e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection rule syslog", +) +class __CMDGroup(AAZCommandGroup): + """Manage Syslog data source. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/__init__.py new file mode 100644 index 00000000000..a48ea3a919f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._add import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_add.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_add.py new file mode 100644 index 00000000000..a6d23afce28 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_add.py @@ -0,0 +1,995 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule syslog add", +) +class Add(AAZCommand): + """Add a Syslog data source. + + :example: Add a Syslog data source + az monitor data-collection rule syslog add --rule-name myCollectionRule --resource-group myResourceGroup --name syslogBase --facility-names syslog --log-levels Alert Critical --streams Microsoft-Syslog + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.syslog[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.facility_names = AAZListArg( + options=["--facility-names"], + help="The list of facility names.", + ) + _args_schema.log_levels = AAZListArg( + options=["--log-levels"], + help="The log levels to collect.", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + help="The KQL query to transform the data source.", + ) + + facility_names = cls._args_schema.facility_names + facility_names.Element = AAZStrArg( + enum={"*": "*", "alert": "alert", "audit": "audit", "auth": "auth", "authpriv": "authpriv", "clock": "clock", "cron": "cron", "daemon": "daemon", "ftp": "ftp", "kern": "kern", "local0": "local0", "local1": "local1", "local2": "local2", "local3": "local3", "local4": "local4", "local5": "local5", "local6": "local6", "local7": "local7", "lpr": "lpr", "mail": "mail", "mark": "mark", "news": "news", "nopri": "nopri", "ntp": "ntp", "syslog": "syslog", "user": "user", "uucp": "uucp"}, + enum_support_extension=True, + ) + + log_levels = cls._args_schema.log_levels + log_levels.Element = AAZStrArg( + enum={"*": "*", "Alert": "Alert", "Critical": "Critical", "Debug": "Debug", "Emergency": "Emergency", "Error": "Error", "Info": "Info", "Notice": "Notice", "Warning": "Warning"}, + enum_support_extension=True, + ) + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + enum={"Microsoft-Syslog": "Microsoft-Syslog"}, + enum_support_extension=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_create() + self.InstanceCreateByJson(ctx=self.ctx)() + self.post_instance_create(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_create(self): + pass + + @register_callback + def post_instance_create(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceCreateByJson(AAZJsonInstanceCreateOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._create_instance()) + + def _create_instance(self): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType + ) + _builder.set_prop("facilityNames", AAZListType, ".facility_names") + _builder.set_prop("logLevels", AAZListType, ".log_levels") + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + + facility_names = _builder.get(".facilityNames") + if facility_names is not None: + facility_names.set_elements(AAZStrType, ".") + + log_levels = _builder.get(".logLevels") + if log_levels is not None: + log_levels.set_elements(AAZStrType, ".") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + return _instance_value + + +class _AddHelper: + """Helper class for Add""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Add"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_delete.py new file mode 100644 index 00000000000..d24405afc7e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_delete.py @@ -0,0 +1,932 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule syslog delete", +) +class Delete(AAZCommand): + """Delete a Syslog data source. + + :example: Delete a Syslog data source + az monitor data-collection rule syslog delete --rule-name myCollectionRule --resource-group myResourceGroup --name syslogBase + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.syslog[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_delete() + self.InstanceDeleteByJson(ctx=self.ctx)() + self.post_instance_delete() + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_delete(self): + pass + + @register_callback + def post_instance_delete(self): + pass + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceDeleteByJson(AAZJsonInstanceDeleteOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._delete_instance()) + + +class _DeleteHelper: + """Helper class for Delete""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_list.py new file mode 100644 index 00000000000..9ad062a018b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_list.py @@ -0,0 +1,805 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule syslog list", +) +class List(AAZCommand): + """List Syslog data sources. + + :example: List Syslog data sources + az monitor data-collection rule syslog list --rule-name myCollectionRule --resource-group myResourceGroup + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.syslog"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.properties.dataSources.syslog + + def _set(self, value): + result = self.ctx.vars.instance + result.properties.dataSources.syslog = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _ListHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_show.py new file mode 100644 index 00000000000..d6fc7d3b42e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_show.py @@ -0,0 +1,824 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule syslog show", +) +class Show(AAZCommand): + """Show a Syslog data source. + + :example: Show a Syslog data source + az monitor data-collection rule syslog show --rule-name myCollectionRule --resource-group myResourceGroup --name syslogBase + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.syslog[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_update.py new file mode 100644 index 00000000000..a77ff25a1d0 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/syslog/_update.py @@ -0,0 +1,1014 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule syslog update", +) +class Update(AAZCommand): + """Update a Syslog data source. + + :example: Update a Syslog data source + az monitor data-collection rule syslog update --rule-name myCollectionRule --resource-group myResourceGroup --name syslogBase --facility-names syslog --log-levels Emergency Critical + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.syslog[]"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.facility_names = AAZListArg( + options=["--facility-names"], + help="The list of facility names.", + nullable=True, + ) + _args_schema.log_levels = AAZListArg( + options=["--log-levels"], + help="The log levels to collect.", + nullable=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + nullable=True, + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + help="The KQL query to transform the data source.", + nullable=True, + ) + + facility_names = cls._args_schema.facility_names + facility_names.Element = AAZStrArg( + nullable=True, + enum={"*": "*", "alert": "alert", "audit": "audit", "auth": "auth", "authpriv": "authpriv", "clock": "clock", "cron": "cron", "daemon": "daemon", "ftp": "ftp", "kern": "kern", "local0": "local0", "local1": "local1", "local2": "local2", "local3": "local3", "local4": "local4", "local5": "local5", "local6": "local6", "local7": "local7", "lpr": "lpr", "mail": "mail", "mark": "mark", "news": "news", "nopri": "nopri", "ntp": "ntp", "syslog": "syslog", "user": "user", "uucp": "uucp"}, + enum_support_extension=True, + ) + + log_levels = cls._args_schema.log_levels + log_levels.Element = AAZStrArg( + nullable=True, + enum={"*": "*", "Alert": "Alert", "Critical": "Critical", "Debug": "Debug", "Emergency": "Emergency", "Error": "Error", "Info": "Info", "Notice": "Notice", "Warning": "Warning"}, + enum_support_extension=True, + ) + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-Syslog": "Microsoft-Syslog"}, + enum_support_extension=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.syslog + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("facilityNames", AAZListType, ".facility_names") + _builder.set_prop("logLevels", AAZListType, ".log_levels") + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + + facility_names = _builder.get(".facilityNames") + if facility_names is not None: + facility_names.set_elements(AAZStrType, ".") + + log_levels = _builder.get(".logLevels") + if log_levels is not None: + log_levels.set_elements(AAZStrType, ".") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.selectors.subresource.get(), + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/__cmd_group.py new file mode 100644 index 00000000000..ccf1a248f80 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor data-collection rule windows-event-log", +) +class __CMDGroup(AAZCommandGroup): + """Manage Windows Event Log data source. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/__init__.py new file mode 100644 index 00000000000..a48ea3a919f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._add import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_add.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_add.py new file mode 100644 index 00000000000..4816f12250e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_add.py @@ -0,0 +1,977 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule windows-event-log add", +) +class Add(AAZCommand): + """Add a Windows Event Log data source. + + :example: Add a Windows Event Log data source + az monitor data-collection rule windows-event-log add --rule-name myCollectionRule --resource-group myResourceGroup --name appTeam1AppEvents --streams Microsoft-WindowsEvent --x-path-queries "Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]" "System![System[(Level = 1 or Level = 2 or Level = 3)]]" + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.windowsEventLogs[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + help="The KQL query to transform the data source.", + ) + _args_schema.x_path_queries = AAZListArg( + options=["--x-path-queries"], + help="A list of Windows Event Log queries in XPATH format.", + ) + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + enum_support_extension=True, + ) + + x_path_queries = cls._args_schema.x_path_queries + x_path_queries.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_create() + self.InstanceCreateByJson(ctx=self.ctx)() + self.post_instance_create(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_create(self): + pass + + @register_callback + def post_instance_create(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _AddHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceCreateByJson(AAZJsonInstanceCreateOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._create_instance()) + + def _create_instance(self): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType + ) + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + _builder.set_prop("xPathQueries", AAZListType, ".x_path_queries") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + x_path_queries = _builder.get(".xPathQueries") + if x_path_queries is not None: + x_path_queries.set_elements(AAZStrType, ".") + + return _instance_value + + +class _AddHelper: + """Helper class for Add""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Add"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_delete.py new file mode 100644 index 00000000000..eead17a1799 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_delete.py @@ -0,0 +1,932 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule windows-event-log delete", +) +class Delete(AAZCommand): + """Delete a Windows Event Log data source. + + :example: Delete a Windows Event Log data source + az monitor data-collection rule windows-event-log delete --rule-name myCollectionRule --resource-group myResourceGroup --name appTeam1AppEvents + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.windowsEventLogs[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_delete() + self.InstanceDeleteByJson(ctx=self.ctx)() + self.post_instance_delete() + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_delete(self): + pass + + @register_callback + def post_instance_delete(self): + pass + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _DeleteHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceDeleteByJson(AAZJsonInstanceDeleteOperation): + + def __call__(self, *args, **kwargs): + self.ctx.selectors.subresource.set(self._delete_instance()) + + +class _DeleteHelper: + """Helper class for Delete""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_list.py new file mode 100644 index 00000000000..92ef5c956bf --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_list.py @@ -0,0 +1,805 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule windows-event-log list", +) +class List(AAZCommand): + """List Windows Event Log data sources + + :example: List Windows Event Log data sources + az monitor data-collection rule windows-event-log list --rule-name myCollectionRule --resource-group myResourceGroup + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.windowsEventLogs"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.properties.dataSources.windowsEventLogs + + def _set(self, value): + result = self.ctx.vars.instance + result.properties.dataSources.windowsEventLogs = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + 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() + _ListHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_show.py new file mode 100644 index 00000000000..b8903bd356d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_show.py @@ -0,0 +1,824 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule windows-event-log show", +) +class Show(AAZCommand): + """Show a Windows Event Log data source. + + :example: Show a Windows Event Log data source + az monitor data-collection rule windows-event-log show --rule-name myCollectionRule --resource-group myResourceGroup --name appTeam1AppEvents + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.windowsEventLogs[]"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_update.py new file mode 100644 index 00000000000..265693b02b5 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/data_collection/rule/windows_event_log/_update.py @@ -0,0 +1,995 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor data-collection rule windows-event-log update", +) +class Update(AAZCommand): + """Update a Windows Event Log data source. + + :example: Update a Windows Event Log data source + az monitor data-collection rule windows-event-log update --rule-name myCollectionRule --resource-group myResourceGroup --name appTeam1AppEvents --x-path-queries "Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]" + """ + + _aaz_info = { + "version": "2023-03-11", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/datacollectionrules/{}", "2023-03-11", "properties.dataSources.windowsEventLogs[]"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.data_collection_rule_name = AAZStrArg( + options=["--rule-name", "--data-collection-rule-name"], + help="The name of the data collection rule. The name is case insensitive.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule.", + required=True, + ) + _args_schema.streams = AAZListArg( + options=["--streams"], + help="List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to.", + nullable=True, + ) + _args_schema.transform_kql = AAZStrArg( + options=["--transform-kql"], + help="The KQL query to transform the data source.", + nullable=True, + ) + _args_schema.x_path_queries = AAZListArg( + options=["--x-path-queries"], + help="A list of Windows Event Log queries in XPATH format.", + nullable=True, + ) + + streams = cls._args_schema.streams + streams.Element = AAZStrArg( + nullable=True, + enum={"Microsoft-Event": "Microsoft-Event", "Microsoft-WindowsEvent": "Microsoft-WindowsEvent"}, + enum_support_extension=True, + ) + + x_path_queries = cls._args_schema.x_path_queries + x_path_queries.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DataCollectionRulesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.DataCollectionRulesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters)[0] + return result[idx] + + def _set(self, value): + result = self.ctx.vars.instance + result = result.properties.dataSources.windowsEventLogs + filters = enumerate(result) + filters = filter( + lambda e: e[1].name == self.ctx.args.name, + filters + ) + idx = next(filters, [len(result)])[0] + result[idx] = value + return + + class DataCollectionRulesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DataCollectionRulesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + **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( + "dataCollectionRuleName", self.ctx.args.data_collection_rule_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-03-11", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_data_collection_rule_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("name", AAZStrType, ".name") + _builder.set_prop("streams", AAZListType, ".streams") + _builder.set_prop("transformKql", AAZStrType, ".transform_kql") + _builder.set_prop("xPathQueries", AAZListType, ".x_path_queries") + + streams = _builder.get(".streams") + if streams is not None: + streams.set_elements(AAZStrType, ".") + + x_path_queries = _builder.get(".xPathQueries") + if x_path_queries is not None: + x_path_queries.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.selectors.subresource.get(), + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_collection_rule_resource_read = None + + @classmethod + def _build_schema_data_collection_rule_resource_read(cls, _schema): + if cls._schema_data_collection_rule_resource_read is not None: + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + return + + cls._schema_data_collection_rule_resource_read = _schema_data_collection_rule_resource_read = AAZObjectType() + + data_collection_rule_resource_read = _schema_data_collection_rule_resource_read + data_collection_rule_resource_read.etag = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.identity = AAZIdentityObjectType() + data_collection_rule_resource_read.kind = AAZStrType() + data_collection_rule_resource_read.location = AAZStrType( + flags={"required": True}, + ) + data_collection_rule_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_collection_rule_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + data_collection_rule_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + data_collection_rule_resource_read.tags = AAZDictType() + data_collection_rule_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_data_collection_rule_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_data_collection_rule_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_data_collection_rule_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_data_collection_rule_resource_read.properties + properties.agent_settings = AAZObjectType( + serialized_name="agentSettings", + ) + properties.data_collection_endpoint_id = AAZStrType( + serialized_name="dataCollectionEndpointId", + ) + properties.data_flows = AAZListType( + serialized_name="dataFlows", + ) + properties.data_sources = AAZObjectType( + serialized_name="dataSources", + ) + properties.description = AAZStrType() + properties.destinations = AAZObjectType() + properties.endpoints = AAZObjectType( + flags={"read_only": True}, + ) + properties.immutable_id = AAZStrType( + serialized_name="immutableId", + flags={"read_only": True}, + ) + properties.metadata = AAZObjectType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.references = AAZObjectType() + properties.stream_declarations = AAZDictType( + serialized_name="streamDeclarations", + ) + + agent_settings = _schema_data_collection_rule_resource_read.properties.agent_settings + agent_settings.logs = AAZListType() + + logs = _schema_data_collection_rule_resource_read.properties.agent_settings.logs + logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.agent_settings.logs.Element + _element.name = AAZStrType() + _element.value = AAZStrType() + + data_flows = _schema_data_collection_rule_resource_read.properties.data_flows + data_flows.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_flows.Element + _element.built_in_transform = AAZStrType( + serialized_name="builtInTransform", + ) + _element.capture_overflow = AAZBoolType( + serialized_name="captureOverflow", + ) + _element.destinations = AAZListType() + _element.output_stream = AAZStrType( + serialized_name="outputStream", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + destinations = _schema_data_collection_rule_resource_read.properties.data_flows.Element.destinations + destinations.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_flows.Element.streams + streams.Element = AAZStrType() + + data_sources = _schema_data_collection_rule_resource_read.properties.data_sources + data_sources.data_imports = AAZObjectType( + serialized_name="dataImports", + ) + data_sources.extensions = AAZListType() + data_sources.iis_logs = AAZListType( + serialized_name="iisLogs", + ) + data_sources.log_files = AAZListType( + serialized_name="logFiles", + ) + data_sources.performance_counters = AAZListType( + serialized_name="performanceCounters", + ) + data_sources.platform_telemetry = AAZListType( + serialized_name="platformTelemetry", + ) + data_sources.prometheus_forwarder = AAZListType( + serialized_name="prometheusForwarder", + ) + data_sources.syslog = AAZListType() + data_sources.windows_event_logs = AAZListType( + serialized_name="windowsEventLogs", + ) + data_sources.windows_firewall_logs = AAZListType( + serialized_name="windowsFirewallLogs", + ) + + data_imports = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports + data_imports.event_hub = AAZObjectType( + serialized_name="eventHub", + ) + + event_hub = _schema_data_collection_rule_resource_read.properties.data_sources.data_imports.event_hub + event_hub.consumer_group = AAZStrType( + serialized_name="consumerGroup", + ) + event_hub.name = AAZStrType() + event_hub.stream = AAZStrType() + + extensions = _schema_data_collection_rule_resource_read.properties.data_sources.extensions + extensions.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element + _element.extension_name = AAZStrType( + serialized_name="extensionName", + flags={"required": True}, + ) + _element.extension_settings = AAZFreeFormDictType( + serialized_name="extensionSettings", + ) + _element.input_data_sources = AAZListType( + serialized_name="inputDataSources", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + input_data_sources = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.input_data_sources + input_data_sources.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.extensions.Element.streams + streams.Element = AAZStrType() + + iis_logs = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs + iis_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element + _element.log_directories = AAZListType( + serialized_name="logDirectories", + ) + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + log_directories = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.log_directories + log_directories.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.iis_logs.Element.streams + streams.Element = AAZStrType() + + log_files = _schema_data_collection_rule_resource_read.properties.data_sources.log_files + log_files.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element + _element.file_patterns = AAZListType( + serialized_name="filePatterns", + flags={"required": True}, + ) + _element.format = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.settings = AAZObjectType() + _element.streams = AAZListType( + flags={"required": True}, + ) + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + file_patterns = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.file_patterns + file_patterns.Element = AAZStrType() + + settings = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings + settings.text = AAZObjectType() + + text = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.settings.text + text.record_start_timestamp_format = AAZStrType( + serialized_name="recordStartTimestampFormat", + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.log_files.Element.streams + streams.Element = AAZStrType() + + performance_counters = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters + performance_counters.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element + _element.counter_specifiers = AAZListType( + serialized_name="counterSpecifiers", + ) + _element.name = AAZStrType() + _element.sampling_frequency_in_seconds = AAZIntType( + serialized_name="samplingFrequencyInSeconds", + ) + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + counter_specifiers = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.counter_specifiers + counter_specifiers.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.performance_counters.Element.streams + streams.Element = AAZStrType() + + platform_telemetry = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry + platform_telemetry.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element + _element.name = AAZStrType() + _element.streams = AAZListType( + flags={"required": True}, + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.platform_telemetry.Element.streams + streams.Element = AAZStrType() + + prometheus_forwarder = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder + prometheus_forwarder.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element + _element.label_include_filter = AAZDictType( + serialized_name="labelIncludeFilter", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + + label_include_filter = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.label_include_filter + label_include_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.prometheus_forwarder.Element.streams + streams.Element = AAZStrType() + + syslog = _schema_data_collection_rule_resource_read.properties.data_sources.syslog + syslog.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element + _element.facility_names = AAZListType( + serialized_name="facilityNames", + ) + _element.log_levels = AAZListType( + serialized_name="logLevels", + ) + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + + facility_names = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.facility_names + facility_names.Element = AAZStrType() + + log_levels = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.log_levels + log_levels.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.syslog.Element.streams + streams.Element = AAZStrType() + + windows_event_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs + windows_event_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element + _element.name = AAZStrType() + _element.streams = AAZListType() + _element.transform_kql = AAZStrType( + serialized_name="transformKql", + ) + _element.x_path_queries = AAZListType( + serialized_name="xPathQueries", + ) + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.streams + streams.Element = AAZStrType() + + x_path_queries = _schema_data_collection_rule_resource_read.properties.data_sources.windows_event_logs.Element.x_path_queries + x_path_queries.Element = AAZStrType() + + windows_firewall_logs = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs + windows_firewall_logs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element + _element.name = AAZStrType() + _element.profile_filter = AAZListType( + serialized_name="profileFilter", + ) + _element.streams = AAZListType( + flags={"required": True}, + ) + + profile_filter = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.profile_filter + profile_filter.Element = AAZStrType() + + streams = _schema_data_collection_rule_resource_read.properties.data_sources.windows_firewall_logs.Element.streams + streams.Element = AAZStrType() + + destinations = _schema_data_collection_rule_resource_read.properties.destinations + destinations.azure_data_explorer = AAZListType( + serialized_name="azureDataExplorer", + ) + destinations.azure_monitor_metrics = AAZObjectType( + serialized_name="azureMonitorMetrics", + ) + destinations.event_hubs = AAZListType( + serialized_name="eventHubs", + ) + destinations.event_hubs_direct = AAZListType( + serialized_name="eventHubsDirect", + ) + destinations.log_analytics = AAZListType( + serialized_name="logAnalytics", + ) + destinations.microsoft_fabric = AAZListType( + serialized_name="microsoftFabric", + ) + destinations.monitoring_accounts = AAZListType( + serialized_name="monitoringAccounts", + ) + destinations.storage_accounts = AAZListType( + serialized_name="storageAccounts", + ) + destinations.storage_blobs_direct = AAZListType( + serialized_name="storageBlobsDirect", + ) + destinations.storage_tables_direct = AAZListType( + serialized_name="storageTablesDirect", + ) + + azure_data_explorer = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer + azure_data_explorer.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.azure_data_explorer.Element + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + azure_monitor_metrics = _schema_data_collection_rule_resource_read.properties.destinations.azure_monitor_metrics + azure_monitor_metrics.name = AAZStrType() + + event_hubs = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs + event_hubs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + event_hubs_direct = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct + event_hubs_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.event_hubs_direct.Element + _element.event_hub_resource_id = AAZStrType( + serialized_name="eventHubResourceId", + ) + _element.name = AAZStrType() + + log_analytics = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics + log_analytics.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.log_analytics.Element + _element.name = AAZStrType() + _element.workspace_id = AAZStrType( + serialized_name="workspaceId", + flags={"read_only": True}, + ) + _element.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + ) + + microsoft_fabric = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric + microsoft_fabric.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.microsoft_fabric.Element + _element.artifact_id = AAZStrType( + serialized_name="artifactId", + ) + _element.database_name = AAZStrType( + serialized_name="databaseName", + ) + _element.ingestion_uri = AAZStrType( + serialized_name="ingestionUri", + ) + _element.name = AAZStrType() + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + + monitoring_accounts = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts + monitoring_accounts.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.monitoring_accounts.Element + _element.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + _element.account_resource_id = AAZStrType( + serialized_name="accountResourceId", + ) + _element.name = AAZStrType() + + storage_accounts = _schema_data_collection_rule_resource_read.properties.destinations.storage_accounts + storage_accounts.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_accounts.Element) + + storage_blobs_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_blobs_direct + storage_blobs_direct.Element = AAZObjectType() + cls._build_schema_storage_blob_destination_read(storage_blobs_direct.Element) + + storage_tables_direct = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct + storage_tables_direct.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.destinations.storage_tables_direct.Element + _element.name = AAZStrType() + _element.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + _element.table_name = AAZStrType( + serialized_name="tableName", + ) + + endpoints = _schema_data_collection_rule_resource_read.properties.endpoints + endpoints.logs_ingestion = AAZStrType( + serialized_name="logsIngestion", + flags={"read_only": True}, + ) + endpoints.metrics_ingestion = AAZStrType( + serialized_name="metricsIngestion", + flags={"read_only": True}, + ) + + metadata = _schema_data_collection_rule_resource_read.properties.metadata + metadata.provisioned_by = AAZStrType( + serialized_name="provisionedBy", + flags={"read_only": True}, + ) + metadata.provisioned_by_immutable_id = AAZStrType( + serialized_name="provisionedByImmutableId", + flags={"read_only": True}, + ) + metadata.provisioned_by_resource_id = AAZStrType( + serialized_name="provisionedByResourceId", + flags={"read_only": True}, + ) + + references = _schema_data_collection_rule_resource_read.properties.references + references.enrichment_data = AAZObjectType( + serialized_name="enrichmentData", + ) + + enrichment_data = _schema_data_collection_rule_resource_read.properties.references.enrichment_data + enrichment_data.storage_blobs = AAZListType( + serialized_name="storageBlobs", + ) + + storage_blobs = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs + storage_blobs.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.references.enrichment_data.storage_blobs.Element + _element.blob_url = AAZStrType( + serialized_name="blobUrl", + ) + _element.lookup_type = AAZStrType( + serialized_name="lookupType", + ) + _element.name = AAZStrType() + _element.resource_id = AAZStrType( + serialized_name="resourceId", + ) + + stream_declarations = _schema_data_collection_rule_resource_read.properties.stream_declarations + stream_declarations.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element + _element.columns = AAZListType() + + columns = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns + columns.Element = AAZObjectType() + + _element = _schema_data_collection_rule_resource_read.properties.stream_declarations.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + system_data = _schema_data_collection_rule_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_data_collection_rule_resource_read.tags + tags.Element = AAZStrType() + + _schema.etag = cls._schema_data_collection_rule_resource_read.etag + _schema.id = cls._schema_data_collection_rule_resource_read.id + _schema.identity = cls._schema_data_collection_rule_resource_read.identity + _schema.kind = cls._schema_data_collection_rule_resource_read.kind + _schema.location = cls._schema_data_collection_rule_resource_read.location + _schema.name = cls._schema_data_collection_rule_resource_read.name + _schema.properties = cls._schema_data_collection_rule_resource_read.properties + _schema.system_data = cls._schema_data_collection_rule_resource_read.system_data + _schema.tags = cls._schema_data_collection_rule_resource_read.tags + _schema.type = cls._schema_data_collection_rule_resource_read.type + + _schema_storage_blob_destination_read = None + + @classmethod + def _build_schema_storage_blob_destination_read(cls, _schema): + if cls._schema_storage_blob_destination_read is not None: + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + return + + cls._schema_storage_blob_destination_read = _schema_storage_blob_destination_read = AAZObjectType() + + storage_blob_destination_read = _schema_storage_blob_destination_read + storage_blob_destination_read.container_name = AAZStrType( + serialized_name="containerName", + ) + storage_blob_destination_read.name = AAZStrType() + storage_blob_destination_read.storage_account_resource_id = AAZStrType( + serialized_name="storageAccountResourceId", + ) + + _schema.container_name = cls._schema_storage_blob_destination_read.container_name + _schema.name = cls._schema_storage_blob_destination_read.name + _schema.storage_account_resource_id = cls._schema_storage_blob_destination_read.storage_account_resource_id + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_create.py index dff43b84760..4d4e42c31c5 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_create.py @@ -63,7 +63,7 @@ def _build_arguments_schema(cls, *args, **kwargs): ) _args_schema.logs = AAZListArg( options=["--logs"], - help="JSON encoded list of logs settings. Use '@{file}' to load from a file. For more information, visit: https://learn.microsoft.com/rest/api/monitor/diagnosticsettings/createorupdate#logsettings.", + help="JSON encoded list of logs settings. Use '@{file}' to load from a file.For more information, visit: https://learn.microsoft.com/rest/api/monitor/diagnosticsettings/createorupdate#logsettings.", ) _args_schema.marketplace_partner_id = AAZStrArg( options=["--marketplace-partner-id"], @@ -100,12 +100,12 @@ def _build_arguments_schema(cls, *args, **kwargs): ) _element.enabled = AAZBoolArg( options=["enabled"], - help="A value indicating whether this log is enabled.", + help="a value indicating whether this log is enabled.", required=True, ) _element.retention_policy = AAZObjectArg( options=["retention-policy"], - help="The retention policy for this log.", + help="the retention policy for this log.", ) cls._build_args_retention_policy_create(_element.retention_policy) @@ -119,17 +119,17 @@ def _build_arguments_schema(cls, *args, **kwargs): ) _element.enabled = AAZBoolArg( options=["enabled"], - help="A value indicating whether this category is enabled.", + help="a value indicating whether this category is enabled.", required=True, ) _element.retention_policy = AAZObjectArg( options=["retention-policy"], - help="The retention policy for this category.", + help="the retention policy for this category.", ) cls._build_args_retention_policy_create(_element.retention_policy) _element.time_grain = AAZDurationArg( options=["time-grain"], - help="The timegrain of the metric in ISO8601 format.", + help="the timegrain of the metric in ISO8601 format.", ) # define Arg Group "Target Resource" @@ -157,7 +157,7 @@ def _build_args_retention_policy_create(cls, _schema): retention_policy_create = cls._args_retention_policy_create retention_policy_create.days = AAZIntArg( options=["days"], - help="The number of days for the retention. A value of 0 will retain the events indefinitely.", + help="the number of days for the retention in days. A value of 0 will retain the events indefinitely.", required=True, fmt=AAZIntArgFormat( minimum=0, @@ -165,7 +165,7 @@ def _build_args_retention_policy_create(cls, _schema): ) retention_policy_create.enabled = AAZBoolArg( options=["enabled"], - help="A value indicating whether the retention policy is enabled.", + help="a value indicating whether the retention policy is enabled.", required=True, ) @@ -282,7 +282,7 @@ def content(self): _elements.set_prop("category", AAZStrType, ".category") _elements.set_prop("categoryGroup", AAZStrType, ".category_group") _elements.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) - _build_schema_retention_policy_create(_elements.set_prop("retentionPolicy", AAZObjectType, ".retention_policy")) + _CreateHelper._build_schema_retention_policy_create(_elements.set_prop("retentionPolicy", AAZObjectType, ".retention_policy")) metrics = _builder.get(".properties.metrics") if metrics is not None: @@ -292,7 +292,7 @@ def content(self): if _elements is not None: _elements.set_prop("category", AAZStrType, ".category") _elements.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) - _build_schema_retention_policy_create(_elements.set_prop("retentionPolicy", AAZObjectType, ".retention_policy")) + _CreateHelper._build_schema_retention_policy_create(_elements.set_prop("retentionPolicy", AAZObjectType, ".retention_policy")) _elements.set_prop("timeGrain", AAZStrType, ".time_grain") return self.serialize_content(_content_value) @@ -371,7 +371,7 @@ def _build_schema_on_200(cls): _element.retention_policy = AAZObjectType( serialized_name="retentionPolicy", ) - _build_schema_retention_policy_read(_element.retention_policy) + _CreateHelper._build_schema_retention_policy_read(_element.retention_policy) metrics = cls._schema_on_200.properties.metrics metrics.Element = AAZObjectType() @@ -384,7 +384,7 @@ def _build_schema_on_200(cls): _element.retention_policy = AAZObjectType( serialized_name="retentionPolicy", ) - _build_schema_retention_policy_read(_element.retention_policy) + _CreateHelper._build_schema_retention_policy_read(_element.retention_policy) _element.time_grain = AAZStrType( serialized_name="timeGrain", ) @@ -412,35 +412,37 @@ def _build_schema_on_200(cls): return cls._schema_on_200 -def _build_schema_retention_policy_create(_builder): - if _builder is None: - return - _builder.set_prop("days", AAZIntType, ".days", typ_kwargs={"flags": {"required": True}}) - _builder.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) +class _CreateHelper: + """Helper class for Create""" + @classmethod + def _build_schema_retention_policy_create(cls, _builder): + if _builder is None: + return + _builder.set_prop("days", AAZIntType, ".days", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) -_schema_retention_policy_read = None - + _schema_retention_policy_read = None -def _build_schema_retention_policy_read(_schema): - global _schema_retention_policy_read - if _schema_retention_policy_read is not None: - _schema.days = _schema_retention_policy_read.days - _schema.enabled = _schema_retention_policy_read.enabled - return + @classmethod + def _build_schema_retention_policy_read(cls, _schema): + if cls._schema_retention_policy_read is not None: + _schema.days = cls._schema_retention_policy_read.days + _schema.enabled = cls._schema_retention_policy_read.enabled + return - _schema_retention_policy_read = AAZObjectType() + cls._schema_retention_policy_read = _schema_retention_policy_read = AAZObjectType() - retention_policy_read = _schema_retention_policy_read - retention_policy_read.days = AAZIntType( - flags={"required": True}, - ) - retention_policy_read.enabled = AAZBoolType( - flags={"required": True}, - ) + retention_policy_read = _schema_retention_policy_read + retention_policy_read.days = AAZIntType( + flags={"required": True}, + ) + retention_policy_read.enabled = AAZBoolType( + flags={"required": True}, + ) - _schema.days = _schema_retention_policy_read.days - _schema.enabled = _schema_retention_policy_read.enabled + _schema.days = cls._schema_retention_policy_read.days + _schema.enabled = cls._schema_retention_policy_read.enabled __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_delete.py index 43694f639b3..5e6743a1f81 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_delete.py @@ -131,4 +131,8 @@ def on_204(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_list.py index 8c3ba3de383..fb65ac767e6 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_list.py @@ -201,7 +201,7 @@ def _build_schema_on_200(cls): _element.retention_policy = AAZObjectType( serialized_name="retentionPolicy", ) - _build_schema_retention_policy_read(_element.retention_policy) + _ListHelper._build_schema_retention_policy_read(_element.retention_policy) metrics = cls._schema_on_200.value.Element.properties.metrics metrics.Element = AAZObjectType() @@ -214,7 +214,7 @@ def _build_schema_on_200(cls): _element.retention_policy = AAZObjectType( serialized_name="retentionPolicy", ) - _build_schema_retention_policy_read(_element.retention_policy) + _ListHelper._build_schema_retention_policy_read(_element.retention_policy) _element.time_grain = AAZStrType( serialized_name="timeGrain", ) @@ -242,28 +242,30 @@ def _build_schema_on_200(cls): return cls._schema_on_200 -_schema_retention_policy_read = None +class _ListHelper: + """Helper class for List""" + _schema_retention_policy_read = None -def _build_schema_retention_policy_read(_schema): - global _schema_retention_policy_read - if _schema_retention_policy_read is not None: - _schema.days = _schema_retention_policy_read.days - _schema.enabled = _schema_retention_policy_read.enabled - return + @classmethod + def _build_schema_retention_policy_read(cls, _schema): + if cls._schema_retention_policy_read is not None: + _schema.days = cls._schema_retention_policy_read.days + _schema.enabled = cls._schema_retention_policy_read.enabled + return - _schema_retention_policy_read = AAZObjectType() + cls._schema_retention_policy_read = _schema_retention_policy_read = AAZObjectType() - retention_policy_read = _schema_retention_policy_read - retention_policy_read.days = AAZIntType( - flags={"required": True}, - ) - retention_policy_read.enabled = AAZBoolType( - flags={"required": True}, - ) + retention_policy_read = _schema_retention_policy_read + retention_policy_read.days = AAZIntType( + flags={"required": True}, + ) + retention_policy_read.enabled = AAZBoolType( + flags={"required": True}, + ) - _schema.days = _schema_retention_policy_read.days - _schema.enabled = _schema_retention_policy_read.enabled + _schema.days = cls._schema_retention_policy_read.days + _schema.enabled = cls._schema_retention_policy_read.enabled __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_show.py index f4b66276caf..25be86a0b4a 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_show.py @@ -209,7 +209,7 @@ def _build_schema_on_200(cls): _element.retention_policy = AAZObjectType( serialized_name="retentionPolicy", ) - _build_schema_retention_policy_read(_element.retention_policy) + _ShowHelper._build_schema_retention_policy_read(_element.retention_policy) metrics = cls._schema_on_200.properties.metrics metrics.Element = AAZObjectType() @@ -222,7 +222,7 @@ def _build_schema_on_200(cls): _element.retention_policy = AAZObjectType( serialized_name="retentionPolicy", ) - _build_schema_retention_policy_read(_element.retention_policy) + _ShowHelper._build_schema_retention_policy_read(_element.retention_policy) _element.time_grain = AAZStrType( serialized_name="timeGrain", ) @@ -250,28 +250,30 @@ def _build_schema_on_200(cls): return cls._schema_on_200 -_schema_retention_policy_read = None +class _ShowHelper: + """Helper class for Show""" + _schema_retention_policy_read = None -def _build_schema_retention_policy_read(_schema): - global _schema_retention_policy_read - if _schema_retention_policy_read is not None: - _schema.days = _schema_retention_policy_read.days - _schema.enabled = _schema_retention_policy_read.enabled - return + @classmethod + def _build_schema_retention_policy_read(cls, _schema): + if cls._schema_retention_policy_read is not None: + _schema.days = cls._schema_retention_policy_read.days + _schema.enabled = cls._schema_retention_policy_read.enabled + return - _schema_retention_policy_read = AAZObjectType() + cls._schema_retention_policy_read = _schema_retention_policy_read = AAZObjectType() - retention_policy_read = _schema_retention_policy_read - retention_policy_read.days = AAZIntType( - flags={"required": True}, - ) - retention_policy_read.enabled = AAZBoolType( - flags={"required": True}, - ) + retention_policy_read = _schema_retention_policy_read + retention_policy_read.days = AAZIntType( + flags={"required": True}, + ) + retention_policy_read.enabled = AAZBoolType( + flags={"required": True}, + ) - _schema.days = _schema_retention_policy_read.days - _schema.enabled = _schema_retention_policy_read.enabled + _schema.days = cls._schema_retention_policy_read.days + _schema.enabled = cls._schema_retention_policy_read.enabled __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_update.py index 7ca9eb45851..8c2a125d447 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/_update.py @@ -48,6 +48,11 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the diagnostic setting. Required.", required=True, ) + _args_schema.resource = AAZStrArg( + options=["--resource"], + help="Name or ID of the target resource.", + required=True, + ) # define Arg Group "Properties" @@ -65,7 +70,7 @@ def _build_arguments_schema(cls, *args, **kwargs): nullable=True, ) _args_schema.log_analytics_destination_type = AAZStrArg( - options=["--log-ana-dtype", "--log-analytics-destination-type"], + options=["--log-analytics-destination-type"], arg_group="Properties", help="A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: `_`. Possible values are: Dedicated and null (null is default.)", nullable=True, @@ -160,16 +165,6 @@ def _build_arguments_schema(cls, *args, **kwargs): help="the timegrain of the metric in ISO8601 format.", nullable=True, ) - - # define Arg Group "Target Resource" - - _args_schema = cls._args_schema - _args_schema.resource = AAZStrArg( - options=["--resource"], - arg_group="Target Resource", - help="Name or ID of the target resource.", - required=True, - ) return cls._args_schema _args_retention_policy_update = None diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_list.py index 2ff8b01a564..0ad84b5eb53 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_list.py @@ -172,4 +172,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_show.py index dfdaf67a07b..a477d808fb1 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/categories/_show.py @@ -169,4 +169,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_create.py index 90a20a59e42..a1999188c53 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_create.py @@ -18,7 +18,7 @@ class Create(AAZCommand): """Create subscription diagnostic settings for the specified resource. :example: Create diagnostic settings for a subscription with EventHub. - az monitor diagnostic-settings subscription create -n {name} --location westus --event-hub-auth-rule {eventHubRuleID} --storage-account {storageAccount} --logs "[{category:Security,enabled:true},{category:Administrative,enabled:true},{category:ServiceHealth,enabled:true},{category:Alert,enabled:true},{category:Recommendation,enabled:true},{category:Policy,enabled:true},{category:Autoscale,enabled:true},{category:ResourceHealth,enabled:true}]" + az monitor diagnostic-settings subscription create -n {name} --location westus --event-hub- auth-rule {eventHubRuleID} --storage-account {storageAccount} \\ --logs "[{category:Security,enabled:true},{category:Administrative,enabled:true},{category:ServiceHealth,enabled:true},{category:Alert,enabled:true},{category:Recommendation,enabled:true},{category:Policy,enabled:true},{category:Autoscale,enabled:true},{category:ResourceHealth,enabled:true}]" """ _aaz_info = { @@ -48,7 +48,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["-n", "--name"], help="The name of the diagnostic setting.", required=True, - id_part="name", ) _args_schema.location = AAZResourceLocationArg( help="Location of the resource", @@ -264,4 +263,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _CreateHelper: + """Helper class for Create""" + + __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_delete.py index cd269eec66d..27390ef6842 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_delete.py @@ -122,4 +122,8 @@ def on_204(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_list.py index 0ed3f275781..06d16b3e801 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_list.py @@ -181,4 +181,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_show.py index 767be61e567..d56b5de36e9 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_show.py @@ -187,4 +187,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_update.py index 41fa987de45..5c34cbc7854 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/diagnostic_settings/subscription/_update.py @@ -206,7 +206,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_subscription_diagnostic_settings_resource_read(cls._schema_on_200) + _UpdateHelper._build_schema_subscription_diagnostic_settings_resource_read(cls._schema_on_200) return cls._schema_on_200 @@ -297,7 +297,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_subscription_diagnostic_settings_resource_read(cls._schema_on_200) + _UpdateHelper._build_schema_subscription_diagnostic_settings_resource_read(cls._schema_on_200) return cls._schema_on_200 @@ -344,68 +344,70 @@ def __call__(self, *args, **kwargs): ) -_schema_subscription_diagnostic_settings_resource_read = None - - -def _build_schema_subscription_diagnostic_settings_resource_read(_schema): - global _schema_subscription_diagnostic_settings_resource_read - if _schema_subscription_diagnostic_settings_resource_read is not None: - _schema.id = _schema_subscription_diagnostic_settings_resource_read.id - _schema.location = _schema_subscription_diagnostic_settings_resource_read.location - _schema.name = _schema_subscription_diagnostic_settings_resource_read.name - _schema.properties = _schema_subscription_diagnostic_settings_resource_read.properties - _schema.type = _schema_subscription_diagnostic_settings_resource_read.type - return - - _schema_subscription_diagnostic_settings_resource_read = AAZObjectType() - - subscription_diagnostic_settings_resource_read = _schema_subscription_diagnostic_settings_resource_read - subscription_diagnostic_settings_resource_read.id = AAZStrType( - flags={"read_only": True}, - ) - subscription_diagnostic_settings_resource_read.location = AAZStrType() - subscription_diagnostic_settings_resource_read.name = AAZStrType( - flags={"read_only": True}, - ) - subscription_diagnostic_settings_resource_read.properties = AAZObjectType( - flags={"client_flatten": True}, - ) - subscription_diagnostic_settings_resource_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_subscription_diagnostic_settings_resource_read.properties - properties.event_hub_authorization_rule_id = AAZStrType( - serialized_name="eventHubAuthorizationRuleId", - ) - properties.event_hub_name = AAZStrType( - serialized_name="eventHubName", - ) - properties.logs = AAZListType() - properties.service_bus_rule_id = AAZStrType( - serialized_name="serviceBusRuleId", - ) - properties.storage_account_id = AAZStrType( - serialized_name="storageAccountId", - ) - properties.workspace_id = AAZStrType( - serialized_name="workspaceId", - ) - - logs = _schema_subscription_diagnostic_settings_resource_read.properties.logs - logs.Element = AAZObjectType() - - _element = _schema_subscription_diagnostic_settings_resource_read.properties.logs.Element - _element.category = AAZStrType() - _element.enabled = AAZBoolType( - flags={"required": True}, - ) - - _schema.id = _schema_subscription_diagnostic_settings_resource_read.id - _schema.location = _schema_subscription_diagnostic_settings_resource_read.location - _schema.name = _schema_subscription_diagnostic_settings_resource_read.name - _schema.properties = _schema_subscription_diagnostic_settings_resource_read.properties - _schema.type = _schema_subscription_diagnostic_settings_resource_read.type +class _UpdateHelper: + """Helper class for Update""" + + _schema_subscription_diagnostic_settings_resource_read = None + + @classmethod + def _build_schema_subscription_diagnostic_settings_resource_read(cls, _schema): + if cls._schema_subscription_diagnostic_settings_resource_read is not None: + _schema.id = cls._schema_subscription_diagnostic_settings_resource_read.id + _schema.location = cls._schema_subscription_diagnostic_settings_resource_read.location + _schema.name = cls._schema_subscription_diagnostic_settings_resource_read.name + _schema.properties = cls._schema_subscription_diagnostic_settings_resource_read.properties + _schema.type = cls._schema_subscription_diagnostic_settings_resource_read.type + return + + cls._schema_subscription_diagnostic_settings_resource_read = _schema_subscription_diagnostic_settings_resource_read = AAZObjectType() + + subscription_diagnostic_settings_resource_read = _schema_subscription_diagnostic_settings_resource_read + subscription_diagnostic_settings_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + subscription_diagnostic_settings_resource_read.location = AAZStrType() + subscription_diagnostic_settings_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + subscription_diagnostic_settings_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + subscription_diagnostic_settings_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_subscription_diagnostic_settings_resource_read.properties + properties.event_hub_authorization_rule_id = AAZStrType( + serialized_name="eventHubAuthorizationRuleId", + ) + properties.event_hub_name = AAZStrType( + serialized_name="eventHubName", + ) + properties.logs = AAZListType() + properties.service_bus_rule_id = AAZStrType( + serialized_name="serviceBusRuleId", + ) + properties.storage_account_id = AAZStrType( + serialized_name="storageAccountId", + ) + properties.workspace_id = AAZStrType( + serialized_name="workspaceId", + ) + + logs = _schema_subscription_diagnostic_settings_resource_read.properties.logs + logs.Element = AAZObjectType() + + _element = _schema_subscription_diagnostic_settings_resource_read.properties.logs.Element + _element.category = AAZStrType() + _element.enabled = AAZBoolType( + flags={"required": True}, + ) + + _schema.id = cls._schema_subscription_diagnostic_settings_resource_read.id + _schema.location = cls._schema_subscription_diagnostic_settings_resource_read.location + _schema.name = cls._schema_subscription_diagnostic_settings_resource_read.name + _schema.properties = cls._schema_subscription_diagnostic_settings_resource_read.properties + _schema.type = cls._schema_subscription_diagnostic_settings_resource_read.type __all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/__init__.py index 5a9d61963d6..2daebea437f 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/__init__.py @@ -9,3 +9,5 @@ # flake8: noqa from .__cmd_group import * +from ._query import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/_query.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/_query.py new file mode 100644 index 00000000000..006226b2870 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/_query.py @@ -0,0 +1,270 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics query", +) +class Query(AAZCommand): + """Query a Log Analytics workspace + """ + + _aaz_info = { + "version": "2022-10-27", + "resources": [ + ["data-plane:microsoft.operationalinsights", "/workspaces/{}/query", "2022-10-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.prefer = AAZStrArg( + options=["--prefer"], + help="Optional. The prefer header to set server timeout, query statistics and visualization information.", + ) + _args_schema.workspace = AAZStrArg( + options=["-w", "--workspace"], + help="ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal.", + required=True, + ) + _args_schema.analytics_query = AAZStrArg( + options=["--analytics-query"], + help="The query to execute.", + required=True, + ) + _args_schema.timespan = AAZStrArg( + options=["-t", "--timespan"], + help="Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression.", + ) + _args_schema.workspaces = AAZListArg( + options=["--workspaces"], + help="A list of workspaces that are included in the query.", + ) + + workspaces = cls._args_schema.workspaces + workspaces.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.QueryExecute(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 QueryExecute(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftOperationalinsightsDataPlaneClient_monitor" + + def __call__(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( + "/workspaces/{workspaceId}/query", + **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( + "workspaceId", self.ctx.args.workspace, + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Prefer", self.ctx.args.prefer, + ), + **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("query", AAZStrType, ".analytics_query", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("timespan", AAZStrType, ".timespan") + _builder.set_prop("workspaces", AAZListType, ".workspaces") + + workspaces = _builder.get(".workspaces") + if workspaces is not None: + workspaces.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.error = AAZObjectType() + _QueryHelper._build_schema_error_info_read(_schema_on_200.error) + _schema_on_200.render = AAZObjectType() + _schema_on_200.statistics = AAZObjectType() + _schema_on_200.tables = AAZListType( + flags={"required": True}, + ) + + tables = cls._schema_on_200.tables + tables.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element + _element.columns = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.rows = AAZListType( + flags={"required": True}, + ) + + columns = cls._schema_on_200.tables.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + rows = cls._schema_on_200.tables.Element.rows + rows.Element = AAZListType() + + _element = cls._schema_on_200.tables.Element.rows.Element + _element.Element = AAZFreeFormDictType() + + return cls._schema_on_200 + + +class _QueryHelper: + """Helper class for Query""" + + _schema_error_info_read = None + + @classmethod + def _build_schema_error_info_read(cls, _schema): + if cls._schema_error_info_read is not None: + _schema.additional_info = cls._schema_error_info_read.additional_info + _schema.code = cls._schema_error_info_read.code + _schema.details = cls._schema_error_info_read.details + _schema.innererror = cls._schema_error_info_read.innererror + _schema.message = cls._schema_error_info_read.message + return + + cls._schema_error_info_read = _schema_error_info_read = AAZObjectType() + + error_info_read = _schema_error_info_read + error_info_read.additional_info = AAZFreeFormDictType( + serialized_name="additionalInfo", + ) + error_info_read.code = AAZStrType( + flags={"required": True}, + ) + error_info_read.details = AAZListType() + error_info_read.innererror = AAZObjectType() + cls._build_schema_error_info_read(error_info_read.innererror) + error_info_read.message = AAZStrType( + flags={"required": True}, + ) + + details = _schema_error_info_read.details + details.Element = AAZObjectType() + + _element = _schema_error_info_read.details.Element + _element.additional_properties = AAZFreeFormDictType( + serialized_name="additionalProperties", + ) + _element.code = AAZStrType( + flags={"required": True}, + ) + _element.message = AAZStrType( + flags={"required": True}, + ) + _element.resources = AAZListType() + _element.target = AAZStrType() + _element.value = AAZStrType() + + resources = _schema_error_info_read.details.Element.resources + resources.Element = AAZStrType() + + _schema.additional_info = cls._schema_error_info_read.additional_info + _schema.code = cls._schema_error_info_read.code + _schema.details = cls._schema_error_info_read.details + _schema.innererror = cls._schema_error_info_read.innererror + _schema.message = cls._schema_error_info_read.message + + +__all__ = ["Query"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/_show.py new file mode 100644 index 00000000000..1660a71f089 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/_show.py @@ -0,0 +1,249 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics show", +) +class Show(AAZCommand): + """Get an Analytics query for data + """ + + _aaz_info = { + "version": "2022-10-27", + "resources": [ + ["data-plane:microsoft.operationalinsights", "/workspaces/{}/query", "2022-10-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.workspace = AAZStrArg( + options=["-w", "--workspace"], + help="ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal.", + required=True, + ) + _args_schema.analytics_query = AAZStrArg( + options=["--analytics-query"], + help="The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/)", + required=True, + ) + _args_schema.timespan = AAZDurationArg( + options=["--timespan"], + help="Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.QueryGet(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 QueryGet(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftOperationalinsightsDataPlaneClient_monitor" + + def __call__(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( + "/workspaces/{workspaceId}/query", + **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( + "workspaceId", self.ctx.args.workspace, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "query", self.ctx.args.analytics_query, + required=True, + ), + **self.serialize_query_param( + "timespan", self.ctx.args.timespan, + ), + } + 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.error = AAZObjectType() + _ShowHelper._build_schema_error_info_read(_schema_on_200.error) + _schema_on_200.render = AAZObjectType() + _schema_on_200.statistics = AAZObjectType() + _schema_on_200.tables = AAZListType( + flags={"required": True}, + ) + + tables = cls._schema_on_200.tables + tables.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element + _element.columns = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.rows = AAZListType( + flags={"required": True}, + ) + + columns = cls._schema_on_200.tables.Element.columns + columns.Element = AAZObjectType() + + _element = cls._schema_on_200.tables.Element.columns.Element + _element.name = AAZStrType() + _element.type = AAZStrType() + + rows = cls._schema_on_200.tables.Element.rows + rows.Element = AAZListType() + + _element = cls._schema_on_200.tables.Element.rows.Element + _element.Element = AAZFreeFormDictType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_error_info_read = None + + @classmethod + def _build_schema_error_info_read(cls, _schema): + if cls._schema_error_info_read is not None: + _schema.additional_info = cls._schema_error_info_read.additional_info + _schema.code = cls._schema_error_info_read.code + _schema.details = cls._schema_error_info_read.details + _schema.innererror = cls._schema_error_info_read.innererror + _schema.message = cls._schema_error_info_read.message + return + + cls._schema_error_info_read = _schema_error_info_read = AAZObjectType() + + error_info_read = _schema_error_info_read + error_info_read.additional_info = AAZFreeFormDictType( + serialized_name="additionalInfo", + ) + error_info_read.code = AAZStrType( + flags={"required": True}, + ) + error_info_read.details = AAZListType() + error_info_read.innererror = AAZObjectType() + cls._build_schema_error_info_read(error_info_read.innererror) + error_info_read.message = AAZStrType( + flags={"required": True}, + ) + + details = _schema_error_info_read.details + details.Element = AAZObjectType() + + _element = _schema_error_info_read.details.Element + _element.additional_properties = AAZFreeFormDictType( + serialized_name="additionalProperties", + ) + _element.code = AAZStrType( + flags={"required": True}, + ) + _element.message = AAZStrType( + flags={"required": True}, + ) + _element.resources = AAZListType() + _element.target = AAZStrType() + _element.value = AAZStrType() + + resources = _schema_error_info_read.details.Element.resources + resources.Element = AAZStrType() + + _schema.additional_info = cls._schema_error_info_read.additional_info + _schema.code = cls._schema_error_info_read.code + _schema.details = cls._schema_error_info_read.details + _schema.innererror = cls._schema_error_info_read.innererror + _schema.message = cls._schema_error_info_read.message + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_create.py index 8ff96f823b7..2ecb0fb6e11 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_create.py @@ -60,7 +60,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["-n", "--name", "--query-pack-name"], help="The name of the log analytics query pack.", required=True, - id_part="name", ) _args_schema.resource_group = AAZResourceGroupNameArg( required=True, @@ -75,11 +74,11 @@ def _execute_operations(self): self.QueryPacksCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -229,4 +228,8 @@ def _build_schema_on_200_201(cls): return cls._schema_on_200_201 +class _CreateHelper: + """Helper class for Create""" + + __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_delete.py index f218a47e8cc..28042d4922d 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_delete.py @@ -62,11 +62,11 @@ def _execute_operations(self): self.QueryPacksDelete(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -133,4 +133,8 @@ def on_204(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_list.py index 691038eeec1..cfcc8725b51 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_list.py @@ -33,6 +33,8 @@ class List(AAZCommand): ] } + AZ_SUPPORT_PAGINATION = True + def _handler(self, command_args): super()._handler(command_args) return self.build_paging(self._execute_operations, self._output) @@ -61,11 +63,11 @@ def _execute_operations(self): self.QueryPacksList(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -327,4 +329,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_show.py index 567d4f41703..c91c1b278a7 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_show.py @@ -61,11 +61,11 @@ def _execute_operations(self): self.QueryPacksGet(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -195,4 +195,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_update.py index 76487d9405c..915fb9ec92b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/_update.py @@ -78,19 +78,19 @@ def _execute_operations(self): self.QueryPacksCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass - # @register_callback + @register_callback def pre_instance_update(self, instance): pass - # @register_callback + @register_callback def post_instance_update(self, instance): pass @@ -177,7 +177,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_log_analytics_query_pack_read(cls._schema_on_200) + _UpdateHelper._build_schema_log_analytics_query_pack_read(cls._schema_on_200) return cls._schema_on_200 @@ -272,7 +272,7 @@ def _build_schema_on_200_201(cls): return cls._schema_on_200_201 cls._schema_on_200_201 = AAZObjectType() - _build_schema_log_analytics_query_pack_read(cls._schema_on_200_201) + _UpdateHelper._build_schema_log_analytics_query_pack_read(cls._schema_on_200_201) return cls._schema_on_200_201 @@ -304,67 +304,69 @@ def __call__(self, *args, **kwargs): ) -_schema_log_analytics_query_pack_read = None - - -def _build_schema_log_analytics_query_pack_read(_schema): - global _schema_log_analytics_query_pack_read - if _schema_log_analytics_query_pack_read is not None: - _schema.id = _schema_log_analytics_query_pack_read.id - _schema.location = _schema_log_analytics_query_pack_read.location - _schema.name = _schema_log_analytics_query_pack_read.name - _schema.properties = _schema_log_analytics_query_pack_read.properties - _schema.tags = _schema_log_analytics_query_pack_read.tags - _schema.type = _schema_log_analytics_query_pack_read.type - return - - _schema_log_analytics_query_pack_read = AAZObjectType() - - log_analytics_query_pack_read = _schema_log_analytics_query_pack_read - log_analytics_query_pack_read.id = AAZStrType( - flags={"read_only": True}, - ) - log_analytics_query_pack_read.location = AAZStrType( - flags={"required": True}, - ) - log_analytics_query_pack_read.name = AAZStrType( - flags={"read_only": True}, - ) - log_analytics_query_pack_read.properties = AAZObjectType( - flags={"required": True, "client_flatten": True}, - ) - log_analytics_query_pack_read.tags = AAZDictType() - log_analytics_query_pack_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_log_analytics_query_pack_read.properties - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.query_pack_id = AAZStrType( - serialized_name="queryPackId", - flags={"read_only": True}, - ) - properties.time_created = AAZStrType( - serialized_name="timeCreated", - flags={"read_only": True}, - ) - properties.time_modified = AAZStrType( - serialized_name="timeModified", - flags={"read_only": True}, - ) - - tags = _schema_log_analytics_query_pack_read.tags - tags.Element = AAZStrType() - - _schema.id = _schema_log_analytics_query_pack_read.id - _schema.location = _schema_log_analytics_query_pack_read.location - _schema.name = _schema_log_analytics_query_pack_read.name - _schema.properties = _schema_log_analytics_query_pack_read.properties - _schema.tags = _schema_log_analytics_query_pack_read.tags - _schema.type = _schema_log_analytics_query_pack_read.type +class _UpdateHelper: + """Helper class for Update""" + + _schema_log_analytics_query_pack_read = None + + @classmethod + def _build_schema_log_analytics_query_pack_read(cls, _schema): + if cls._schema_log_analytics_query_pack_read is not None: + _schema.id = cls._schema_log_analytics_query_pack_read.id + _schema.location = cls._schema_log_analytics_query_pack_read.location + _schema.name = cls._schema_log_analytics_query_pack_read.name + _schema.properties = cls._schema_log_analytics_query_pack_read.properties + _schema.tags = cls._schema_log_analytics_query_pack_read.tags + _schema.type = cls._schema_log_analytics_query_pack_read.type + return + + cls._schema_log_analytics_query_pack_read = _schema_log_analytics_query_pack_read = AAZObjectType() + + log_analytics_query_pack_read = _schema_log_analytics_query_pack_read + log_analytics_query_pack_read.id = AAZStrType( + flags={"read_only": True}, + ) + log_analytics_query_pack_read.location = AAZStrType( + flags={"required": True}, + ) + log_analytics_query_pack_read.name = AAZStrType( + flags={"read_only": True}, + ) + log_analytics_query_pack_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + log_analytics_query_pack_read.tags = AAZDictType() + log_analytics_query_pack_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_log_analytics_query_pack_read.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.query_pack_id = AAZStrType( + serialized_name="queryPackId", + flags={"read_only": True}, + ) + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + + tags = _schema_log_analytics_query_pack_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_log_analytics_query_pack_read.id + _schema.location = cls._schema_log_analytics_query_pack_read.location + _schema.name = cls._schema_log_analytics_query_pack_read.name + _schema.properties = cls._schema_log_analytics_query_pack_read.properties + _schema.tags = cls._schema_log_analytics_query_pack_read.tags + _schema.type = cls._schema_log_analytics_query_pack_read.type __all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_create.py index b1064dbe769..18ea54ffc3b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_create.py @@ -49,13 +49,11 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["-n", "--name", "--query-id"], help="The id name of a specific query defined in the log analytics query pack. It must be of type GUID.", required=True, - id_part="child_name_1", ) _args_schema.query_pack_name = AAZStrArg( options=["--query-pack-name"], help="The name of the log analytics query pack.", required=True, - id_part="name", ) _args_schema.resource_group = AAZResourceGroupNameArg( required=True, @@ -127,11 +125,11 @@ def _execute_operations(self): self.QueriesPut(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -366,4 +364,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _CreateHelper: + """Helper class for Create""" + + __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_delete.py index c541c126ce8..2316076a30c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_delete.py @@ -68,11 +68,11 @@ def _execute_operations(self): self.QueriesDelete(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -143,4 +143,8 @@ def on_204(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_list.py index e0172b68f23..3e4e095e775 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_list.py @@ -32,6 +32,8 @@ class List(AAZCommand): ] } + AZ_SUPPORT_PAGINATION = True + def _handler(self, command_args): super()._handler(command_args) return self.build_paging(self._execute_operations, self._output) @@ -66,11 +68,11 @@ def _execute_operations(self): self.QueriesList(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -268,4 +270,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_search.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_search.py index 5fa70af39fc..aff3c8bd0f9 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_search.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_search.py @@ -32,6 +32,8 @@ class Search(AAZCommand): ] } + AZ_SUPPORT_PAGINATION = True + def _handler(self, command_args): super()._handler(command_args) return self.build_paging(self._execute_operations, self._output) @@ -51,7 +53,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--query-pack-name"], help="The name of the log analytics query pack.", required=True, - id_part="name", ) _args_schema.resource_group = AAZResourceGroupNameArg( required=True, @@ -106,11 +107,11 @@ def _execute_operations(self): self.QueriesSearch(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -349,4 +350,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _SearchHelper: + """Helper class for Search""" + + __all__ = ["Search"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_show.py index 0ee7113bf01..9bae4585d0b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_show.py @@ -67,11 +67,11 @@ def _execute_operations(self): self.QueriesGet(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -258,4 +258,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_update.py index 8ddc7fe9462..897f807d28e 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/query_pack/query/_update.py @@ -147,19 +147,19 @@ def _execute_operations(self): self.QueriesPut(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass - # @register_callback + @register_callback def pre_instance_update(self, instance): pass - # @register_callback + @register_callback def post_instance_update(self, instance): pass @@ -250,7 +250,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_log_analytics_query_pack_query_read(cls._schema_on_200) + _UpdateHelper._build_schema_log_analytics_query_pack_query_read(cls._schema_on_200) return cls._schema_on_200 @@ -349,7 +349,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_log_analytics_query_pack_query_read(cls._schema_on_200) + _UpdateHelper._build_schema_log_analytics_query_pack_query_read(cls._schema_on_200) return cls._schema_on_200 @@ -411,118 +411,120 @@ def __call__(self, *args, **kwargs): ) -_schema_log_analytics_query_pack_query_read = None - - -def _build_schema_log_analytics_query_pack_query_read(_schema): - global _schema_log_analytics_query_pack_query_read - if _schema_log_analytics_query_pack_query_read is not None: - _schema.id = _schema_log_analytics_query_pack_query_read.id - _schema.name = _schema_log_analytics_query_pack_query_read.name - _schema.properties = _schema_log_analytics_query_pack_query_read.properties - _schema.system_data = _schema_log_analytics_query_pack_query_read.system_data - _schema.type = _schema_log_analytics_query_pack_query_read.type - return - - _schema_log_analytics_query_pack_query_read = AAZObjectType() - - log_analytics_query_pack_query_read = _schema_log_analytics_query_pack_query_read - log_analytics_query_pack_query_read.id = AAZStrType( - flags={"read_only": True}, - ) - log_analytics_query_pack_query_read.name = AAZStrType( - flags={"read_only": True}, - ) - log_analytics_query_pack_query_read.properties = AAZObjectType( - flags={"required": True}, - ) - log_analytics_query_pack_query_read.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - log_analytics_query_pack_query_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_log_analytics_query_pack_query_read.properties - properties.author = AAZStrType( - flags={"read_only": True}, - ) - properties.body = AAZStrType( - flags={"required": True}, - ) - properties.description = AAZStrType() - properties.display_name = AAZStrType( - serialized_name="displayName", - flags={"required": True}, - ) - properties.id = AAZStrType( - flags={"read_only": True}, - ) - properties.related = AAZObjectType() - properties.tags = AAZDictType() - properties.time_created = AAZStrType( - serialized_name="timeCreated", - flags={"read_only": True}, - ) - properties.time_modified = AAZStrType( - serialized_name="timeModified", - flags={"read_only": True}, - ) - - related = _schema_log_analytics_query_pack_query_read.properties.related - related.categories = AAZListType() - related.resource_types = AAZListType( - serialized_name="resourceTypes", - ) - related.solutions = AAZListType() - - categories = _schema_log_analytics_query_pack_query_read.properties.related.categories - categories.Element = AAZStrType() - - resource_types = _schema_log_analytics_query_pack_query_read.properties.related.resource_types - resource_types.Element = AAZStrType() - - solutions = _schema_log_analytics_query_pack_query_read.properties.related.solutions - solutions.Element = AAZStrType() - - tags = _schema_log_analytics_query_pack_query_read.properties.tags - tags.Element = AAZListType() - - _element = _schema_log_analytics_query_pack_query_read.properties.tags.Element - _element.Element = AAZStrType() - - system_data = _schema_log_analytics_query_pack_query_read.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - flags={"read_only": True}, - ) - system_data.created_by = AAZStrType( - serialized_name="createdBy", - flags={"read_only": True}, - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - flags={"read_only": True}, - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - flags={"read_only": True}, - ) - system_data.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - flags={"read_only": True}, - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - flags={"read_only": True}, - ) - - _schema.id = _schema_log_analytics_query_pack_query_read.id - _schema.name = _schema_log_analytics_query_pack_query_read.name - _schema.properties = _schema_log_analytics_query_pack_query_read.properties - _schema.system_data = _schema_log_analytics_query_pack_query_read.system_data - _schema.type = _schema_log_analytics_query_pack_query_read.type +class _UpdateHelper: + """Helper class for Update""" + + _schema_log_analytics_query_pack_query_read = None + + @classmethod + def _build_schema_log_analytics_query_pack_query_read(cls, _schema): + if cls._schema_log_analytics_query_pack_query_read is not None: + _schema.id = cls._schema_log_analytics_query_pack_query_read.id + _schema.name = cls._schema_log_analytics_query_pack_query_read.name + _schema.properties = cls._schema_log_analytics_query_pack_query_read.properties + _schema.system_data = cls._schema_log_analytics_query_pack_query_read.system_data + _schema.type = cls._schema_log_analytics_query_pack_query_read.type + return + + cls._schema_log_analytics_query_pack_query_read = _schema_log_analytics_query_pack_query_read = AAZObjectType() + + log_analytics_query_pack_query_read = _schema_log_analytics_query_pack_query_read + log_analytics_query_pack_query_read.id = AAZStrType( + flags={"read_only": True}, + ) + log_analytics_query_pack_query_read.name = AAZStrType( + flags={"read_only": True}, + ) + log_analytics_query_pack_query_read.properties = AAZObjectType( + flags={"required": True}, + ) + log_analytics_query_pack_query_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + log_analytics_query_pack_query_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_log_analytics_query_pack_query_read.properties + properties.author = AAZStrType( + flags={"read_only": True}, + ) + properties.body = AAZStrType( + flags={"required": True}, + ) + properties.description = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.id = AAZStrType( + flags={"read_only": True}, + ) + properties.related = AAZObjectType() + properties.tags = AAZDictType() + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.time_modified = AAZStrType( + serialized_name="timeModified", + flags={"read_only": True}, + ) + + related = _schema_log_analytics_query_pack_query_read.properties.related + related.categories = AAZListType() + related.resource_types = AAZListType( + serialized_name="resourceTypes", + ) + related.solutions = AAZListType() + + categories = _schema_log_analytics_query_pack_query_read.properties.related.categories + categories.Element = AAZStrType() + + resource_types = _schema_log_analytics_query_pack_query_read.properties.related.resource_types + resource_types.Element = AAZStrType() + + solutions = _schema_log_analytics_query_pack_query_read.properties.related.solutions + solutions.Element = AAZStrType() + + tags = _schema_log_analytics_query_pack_query_read.properties.tags + tags.Element = AAZListType() + + _element = _schema_log_analytics_query_pack_query_read.properties.tags.Element + _element.Element = AAZStrType() + + system_data = _schema_log_analytics_query_pack_query_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + flags={"read_only": True}, + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + flags={"read_only": True}, + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + flags={"read_only": True}, + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + flags={"read_only": True}, + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + flags={"read_only": True}, + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + flags={"read_only": True}, + ) + + _schema.id = cls._schema_log_analytics_query_pack_query_read.id + _schema.name = cls._schema_log_analytics_query_pack_query_read.name + _schema.properties = cls._schema_log_analytics_query_pack_query_read.properties + _schema.system_data = cls._schema_log_analytics_query_pack_query_read.system_data + _schema.type = cls._schema_log_analytics_query_pack_query_read.type __all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/__cmd_group.py new file mode 100644 index 00000000000..4f701d4233a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor log-analytics solution", +) +class __CMDGroup(AAZCommandGroup): + """Commands to manage monitor log-analytics solution. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/__init__.py new file mode 100644 index 00000000000..db73033039b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_create.py new file mode 100644 index 00000000000..7dce884b0a8 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_create.py @@ -0,0 +1,299 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics solution create", +) +class Create(AAZCommand): + """Create the Solution. + + :example: Create a log-analytics solution of type Containers + az monitor log-analytics solution create --resource-group MyResourceGroup --solution-type Containers --tags key=value --workspace "/subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/ Microsoft.OperationalInsights/workspaces/{WorkspaceName}" + """ + + _aaz_info = { + "version": "2015-11-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.operationsmanagement/solutions/{}", "2015-11-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the log-analytics solution. It should be in the format of solutionType(workspaceName). SolutionType part is case sensitive.", + required=True, + ) + _args_schema.location = AAZResourceLocationArg( + help="Resource location", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.plan = AAZObjectArg( + options=["--plan"], + help="Plan for solution object supported by the OperationsManagement resource provider.", + ) + _args_schema.workspace_id = AAZStrArg( + options=["--workspace-id"], + help="The azure resourceId for the workspace where the solution will be deployed/enabled.", + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Space-separated tags: key[=value] [key[=value] ...]. Use \"\" to clear existing tags.", + ) + + plan = cls._args_schema.plan + plan.name = AAZStrArg( + options=["name"], + help="name of the solution to be created. For Microsoft published solution it should be in the format of solutionType(workspaceName). SolutionType part is case sensitive. For third party solution, it can be anything.", + ) + plan.product = AAZStrArg( + options=["product"], + help="name of the solution to enabled/add. For Microsoft published gallery solution it should be in the format of OMSGallery/. This is case sensitive", + ) + plan.promotion_code = AAZStrArg( + options=["promotion-code"], + help="promotionCode, Not really used now, can you left as empty", + ) + plan.publisher = AAZStrArg( + options=["publisher"], + help="Publisher name. For gallery solution, it is Microsoft.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.SolutionsCreateOrUpdate(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 SolutionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("location", AAZStrType, ".location") + _builder.set_prop("plan", AAZObjectType, ".plan") + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + plan = _builder.get(".plan") + if plan is not None: + plan.set_prop("name", AAZStrType, ".name") + plan.set_prop("product", AAZStrType, ".product") + plan.set_prop("promotionCode", AAZStrType, ".promotion_code") + plan.set_prop("publisher", AAZStrType, ".publisher") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("workspaceResourceId", AAZStrType, ".workspace_id", typ_kwargs={"flags": {"required": True}}) + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_201 + ) + + _schema_on_201 = None + + @classmethod + def _build_schema_on_201(cls): + if cls._schema_on_201 is not None: + return cls._schema_on_201 + + cls._schema_on_201 = AAZObjectType() + + _schema_on_201 = cls._schema_on_201 + _schema_on_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_201.location = AAZStrType() + _schema_on_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_201.plan = AAZObjectType() + _schema_on_201.properties = AAZObjectType() + _schema_on_201.tags = AAZDictType() + _schema_on_201.type = AAZStrType( + flags={"read_only": True}, + ) + + plan = cls._schema_on_201.plan + plan.name = AAZStrType() + plan.product = AAZStrType() + plan.promotion_code = AAZStrType( + serialized_name="promotionCode", + ) + plan.publisher = AAZStrType() + + properties = cls._schema_on_201.properties + properties.contained_resources = AAZListType( + serialized_name="containedResources", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.referenced_resources = AAZListType( + serialized_name="referencedResources", + ) + properties.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + flags={"required": True}, + ) + + contained_resources = cls._schema_on_201.properties.contained_resources + contained_resources.Element = AAZStrType() + + referenced_resources = cls._schema_on_201.properties.referenced_resources + referenced_resources.Element = AAZStrType() + + tags = cls._schema_on_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_delete.py new file mode 100644 index 00000000000..93f92010844 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_delete.py @@ -0,0 +1,151 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics solution delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete the solution in the subscription. + + :example: Delete a log-analytics solution + az monitor log-analytics solution delete --resource-group MyResourceGroup --name SolutionName + """ + + _aaz_info = { + "version": "2015-11-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.operationsmanagement/solutions/{}", "2015-11-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the log-analytics solution. It should be in the format of solutionType(workspaceName). SolutionType part is case sensitive.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.SolutionsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class SolutionsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-11-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_list.py new file mode 100644 index 00000000000..bda67badb59 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_list.py @@ -0,0 +1,344 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics solution list", +) +class List(AAZCommand): + """List the solution list. It will retrieve both first party and third party solutions + + :example: List all log-analytics solutions in the current subscription + az monitor log-analytics solution list + + :example: List all log-analytics solutions in a subscription + az monitor log-analytics solution list --subscription MySubscription + + :example: List all log-analytics solutions in a resource group + az monitor log-analytics solution list --resource-group MyResourceGroup + """ + + _aaz_info = { + "version": "2015-11-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.operationsmanagement/solutions", "2015-11-01-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.operationsmanagement/solutions", "2015-11-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + if condition_0: + self.SolutionsListBySubscription(ctx=self.ctx)() + if condition_1: + self.SolutionsListByResourceGroup(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 SolutionsListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.plan = AAZObjectType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + plan = cls._schema_on_200.value.Element.plan + plan.name = AAZStrType() + plan.product = AAZStrType() + plan.promotion_code = AAZStrType( + serialized_name="promotionCode", + ) + plan.publisher = AAZStrType() + + properties = cls._schema_on_200.value.Element.properties + properties.contained_resources = AAZListType( + serialized_name="containedResources", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.referenced_resources = AAZListType( + serialized_name="referencedResources", + ) + properties.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + flags={"required": True}, + ) + + contained_resources = cls._schema_on_200.value.Element.properties.contained_resources + contained_resources.Element = AAZStrType() + + referenced_resources = cls._schema_on_200.value.Element.properties.referenced_resources + referenced_resources.Element = AAZStrType() + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class SolutionsListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.plan = AAZObjectType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + plan = cls._schema_on_200.value.Element.plan + plan.name = AAZStrType() + plan.product = AAZStrType() + plan.promotion_code = AAZStrType( + serialized_name="promotionCode", + ) + plan.publisher = AAZStrType() + + properties = cls._schema_on_200.value.Element.properties + properties.contained_resources = AAZListType( + serialized_name="containedResources", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.referenced_resources = AAZListType( + serialized_name="referencedResources", + ) + properties.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + flags={"required": True}, + ) + + contained_resources = cls._schema_on_200.value.Element.properties.contained_resources + contained_resources.Element = AAZStrType() + + referenced_resources = cls._schema_on_200.value.Element.properties.referenced_resources + referenced_resources.Element = AAZStrType() + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_show.py new file mode 100644 index 00000000000..be91d0765a5 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_show.py @@ -0,0 +1,210 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics solution show", +) +class Show(AAZCommand): + """Get the user solution. + + :example: Show a log-analytics solution + az monitor log-analytics solution show --resource-group MyResourceGroup --name SolutionName + """ + + _aaz_info = { + "version": "2015-11-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.operationsmanagement/solutions/{}", "2015-11-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the log-analytics solution. It should be in the format of solutionType(workspaceName). SolutionType part is case sensitive.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SolutionsGet(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 SolutionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.plan = AAZObjectType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + plan = cls._schema_on_200.plan + plan.name = AAZStrType() + plan.product = AAZStrType() + plan.promotion_code = AAZStrType( + serialized_name="promotionCode", + ) + plan.publisher = AAZStrType() + + properties = cls._schema_on_200.properties + properties.contained_resources = AAZListType( + serialized_name="containedResources", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.referenced_resources = AAZListType( + serialized_name="referencedResources", + ) + properties.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + flags={"required": True}, + ) + + contained_resources = cls._schema_on_200.properties.contained_resources + contained_resources.Element = AAZStrType() + + referenced_resources = cls._schema_on_200.properties.referenced_resources + referenced_resources.Element = AAZStrType() + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_update.py new file mode 100644 index 00000000000..43b9dd0cfa6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_update.py @@ -0,0 +1,252 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics solution update", +) +class Update(AAZCommand): + """Update a Solution. Only updating tags supported. + + :example: Update a log-analytics solution + az monitor log-analytics solution update --resource-group MyResourceGroup --name SolutionName --tags key=value + """ + + _aaz_info = { + "version": "2015-11-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.operationsmanagement/solutions/{}", "2015-11-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the log-analytics solution. It should be in the format of solutionType(workspaceName). SolutionType part is case sensitive.", + required=True, + id_part="name", + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Space-separated tags: key[=value] [key[=value] ...]. Use \"\" to clear existing tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.SolutionsUpdate(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 SolutionsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("tags", AAZDictType, ".tags") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.plan = AAZObjectType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + plan = cls._schema_on_200.plan + plan.name = AAZStrType() + plan.product = AAZStrType() + plan.promotion_code = AAZStrType( + serialized_name="promotionCode", + ) + plan.publisher = AAZStrType() + + properties = cls._schema_on_200.properties + properties.contained_resources = AAZListType( + serialized_name="containedResources", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.referenced_resources = AAZListType( + serialized_name="referencedResources", + ) + properties.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + flags={"required": True}, + ) + + contained_resources = cls._schema_on_200.properties.contained_resources + contained_resources.Element = AAZStrType() + + referenced_resources = cls._schema_on_200.properties.referenced_resources + referenced_resources.Element = AAZStrType() + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_wait.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_wait.py new file mode 100644 index 00000000000..2d911d09c7b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/solution/_wait.py @@ -0,0 +1,206 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor log-analytics solution wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.operationsmanagement/solutions/{}", "2015-11-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the log-analytics solution. It should be in the format of solutionType(workspaceName). SolutionType part is case sensitive.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SolutionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class SolutionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2015-11-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.plan = AAZObjectType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + plan = cls._schema_on_200.plan + plan.name = AAZStrType() + plan.product = AAZStrType() + plan.promotion_code = AAZStrType( + serialized_name="promotionCode", + ) + plan.publisher = AAZStrType() + + properties = cls._schema_on_200.properties + properties.contained_resources = AAZListType( + serialized_name="containedResources", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.referenced_resources = AAZListType( + serialized_name="referencedResources", + ) + properties.workspace_resource_id = AAZStrType( + serialized_name="workspaceResourceId", + flags={"required": True}, + ) + + contained_resources = cls._schema_on_200.properties.contained_resources + contained_resources.Element = AAZStrType() + + referenced_resources = cls._schema_on_200.properties.referenced_resources + referenced_resources.Element = AAZStrType() + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_create.py index d4410374b39..da7b0b0f97c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_create.py @@ -51,7 +51,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["-n", "--name", "--data-export-name"], help="The data export rule name.", required=True, - id_part="child_name_1", fmt=AAZStrArgFormat( pattern="^[A-Za-z][A-Za-z0-9-]+[A-Za-z0-9]$", max_length=63, @@ -65,7 +64,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--workspace-name"], help="The name of the workspace.", required=True, - id_part="name", fmt=AAZStrArgFormat( pattern="^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$", max_length=63, @@ -112,11 +110,11 @@ def _execute_operations(self): self.DataExportsCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -298,4 +296,8 @@ def _build_schema_on_200_201(cls): return cls._schema_on_200_201 +class _CreateHelper: + """Helper class for Create""" + + __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_delete.py index 172db49f8a7..5d1cbde5805 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_delete.py @@ -69,11 +69,11 @@ def _execute_operations(self): self.DataExportsDelete(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -139,4 +139,8 @@ def on_200(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_list.py index 6297e4d147b..f8e8e9dfb06 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_list.py @@ -61,11 +61,11 @@ def _execute_operations(self): self.DataExportsListByWorkspace(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -216,4 +216,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_show.py index c5bd98e4235..aa34ad35835 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_show.py @@ -68,11 +68,11 @@ def _execute_operations(self): self.DataExportsGet(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -221,4 +221,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_update.py index d7a44bceeee..bcc5a2c1b98 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/data_export/_update.py @@ -116,19 +116,19 @@ def _execute_operations(self): self.DataExportsCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass - # @register_callback + @register_callback def pre_instance_update(self, instance): pass - # @register_callback + @register_callback def post_instance_update(self, instance): pass @@ -219,7 +219,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_data_export_read(cls._schema_on_200) + _UpdateHelper._build_schema_data_export_read(cls._schema_on_200) return cls._schema_on_200 @@ -318,7 +318,7 @@ def _build_schema_on_200_201(cls): return cls._schema_on_200_201 cls._schema_on_200_201 = AAZObjectType() - _build_schema_data_export_read(cls._schema_on_200_201) + _UpdateHelper._build_schema_data_export_read(cls._schema_on_200_201) return cls._schema_on_200_201 @@ -365,78 +365,80 @@ def __call__(self, *args, **kwargs): ) -_schema_data_export_read = None - - -def _build_schema_data_export_read(_schema): - global _schema_data_export_read - if _schema_data_export_read is not None: - _schema.id = _schema_data_export_read.id - _schema.name = _schema_data_export_read.name - _schema.properties = _schema_data_export_read.properties - _schema.type = _schema_data_export_read.type - return - - _schema_data_export_read = AAZObjectType() - - data_export_read = _schema_data_export_read - data_export_read.id = AAZStrType( - flags={"read_only": True}, - ) - data_export_read.name = AAZStrType( - flags={"read_only": True}, - ) - data_export_read.properties = AAZObjectType( - flags={"required": True, "client_flatten": True}, - ) - data_export_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_data_export_read.properties - properties.created_date = AAZStrType( - serialized_name="createdDate", - ) - properties.data_export_id = AAZStrType( - serialized_name="dataExportId", - ) - properties.destination = AAZObjectType( - flags={"required": True}, - ) - properties.enable = AAZBoolType() - properties.last_modified_date = AAZStrType( - serialized_name="lastModifiedDate", - ) - properties.table_names = AAZListType( - serialized_name="tableNames", - flags={"required": True}, - ) - - destination = _schema_data_export_read.properties.destination - destination.meta_data = AAZObjectType( - serialized_name="metaData", - flags={"client_flatten": True}, - ) - destination.resource_id = AAZStrType( - serialized_name="resourceId", - flags={"required": True}, - ) - destination.type = AAZStrType( - flags={"read_only": True}, - ) - - meta_data = _schema_data_export_read.properties.destination.meta_data - meta_data.event_hub_name = AAZStrType( - serialized_name="eventHubName", - ) - - table_names = _schema_data_export_read.properties.table_names - table_names.Element = AAZStrType() - - _schema.id = _schema_data_export_read.id - _schema.name = _schema_data_export_read.name - _schema.properties = _schema_data_export_read.properties - _schema.type = _schema_data_export_read.type +class _UpdateHelper: + """Helper class for Update""" + + _schema_data_export_read = None + + @classmethod + def _build_schema_data_export_read(cls, _schema): + if cls._schema_data_export_read is not None: + _schema.id = cls._schema_data_export_read.id + _schema.name = cls._schema_data_export_read.name + _schema.properties = cls._schema_data_export_read.properties + _schema.type = cls._schema_data_export_read.type + return + + cls._schema_data_export_read = _schema_data_export_read = AAZObjectType() + + data_export_read = _schema_data_export_read + data_export_read.id = AAZStrType( + flags={"read_only": True}, + ) + data_export_read.name = AAZStrType( + flags={"read_only": True}, + ) + data_export_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + data_export_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_data_export_read.properties + properties.created_date = AAZStrType( + serialized_name="createdDate", + ) + properties.data_export_id = AAZStrType( + serialized_name="dataExportId", + ) + properties.destination = AAZObjectType( + flags={"required": True}, + ) + properties.enable = AAZBoolType() + properties.last_modified_date = AAZStrType( + serialized_name="lastModifiedDate", + ) + properties.table_names = AAZListType( + serialized_name="tableNames", + flags={"required": True}, + ) + + destination = _schema_data_export_read.properties.destination + destination.meta_data = AAZObjectType( + serialized_name="metaData", + flags={"client_flatten": True}, + ) + destination.resource_id = AAZStrType( + serialized_name="resourceId", + flags={"required": True}, + ) + destination.type = AAZStrType( + flags={"read_only": True}, + ) + + meta_data = _schema_data_export_read.properties.destination.meta_data + meta_data.event_hub_name = AAZStrType( + serialized_name="eventHubName", + ) + + table_names = _schema_data_export_read.properties.table_names + table_names.Element = AAZStrType() + + _schema.id = cls._schema_data_export_read.id + _schema.name = cls._schema_data_export_read.name + _schema.properties = cls._schema_data_export_read.properties + _schema.type = cls._schema_data_export_read.type __all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_create.py index 1ae15504916..d9406cbc89b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_create.py @@ -49,7 +49,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["-n", "--name", "--linked-service-name"], help="Name of the linkedServices resource. Supported values: cluster, automation.", required=True, - id_part="child_name_1", ) _args_schema.resource_group = AAZResourceGroupNameArg( required=True, @@ -58,7 +57,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--workspace-name"], help="The name of the workspace.", required=True, - id_part="name", fmt=AAZStrArgFormat( pattern="^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$", max_length=63, @@ -93,11 +91,11 @@ def _execute_operations(self): yield self.LinkedServicesCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -261,4 +259,8 @@ def _build_schema_on_200_201(cls): return cls._schema_on_200_201 +class _CreateHelper: + """Helper class for Create""" + + __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_delete.py index 6d2090537cf..fdde1f077ad 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_delete.py @@ -73,11 +73,11 @@ def _execute_operations(self): yield self.LinkedServicesDelete(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -229,4 +229,8 @@ def on_204(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_list.py index cdfeeec69fe..f0ed0b01860 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_list.py @@ -64,11 +64,11 @@ def _execute_operations(self): self.LinkedServicesListByWorkspace(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -194,4 +194,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_show.py index 4233dca802c..c2a07970c0c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_show.py @@ -71,11 +71,11 @@ def _execute_operations(self): self.LinkedServicesGet(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -199,4 +199,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_update.py index 4d72ae2aee1..bbf981053c8 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_update.py @@ -105,19 +105,19 @@ def _execute_operations(self): yield self.LinkedServicesCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass - # @register_callback + @register_callback def pre_instance_update(self, instance): pass - # @register_callback + @register_callback def post_instance_update(self, instance): pass @@ -208,7 +208,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_linked_service_read(cls._schema_on_200) + _UpdateHelper._build_schema_linked_service_read(cls._schema_on_200) return cls._schema_on_200 @@ -323,7 +323,7 @@ def _build_schema_on_200_201(cls): return cls._schema_on_200_201 cls._schema_on_200_201 = AAZObjectType() - _build_schema_linked_service_read(cls._schema_on_200_201) + _UpdateHelper._build_schema_linked_service_read(cls._schema_on_200_201) return cls._schema_on_200_201 @@ -361,55 +361,57 @@ def __call__(self, *args, **kwargs): ) -_schema_linked_service_read = None - - -def _build_schema_linked_service_read(_schema): - global _schema_linked_service_read - if _schema_linked_service_read is not None: - _schema.id = _schema_linked_service_read.id - _schema.name = _schema_linked_service_read.name - _schema.properties = _schema_linked_service_read.properties - _schema.tags = _schema_linked_service_read.tags - _schema.type = _schema_linked_service_read.type - return - - _schema_linked_service_read = AAZObjectType() - - linked_service_read = _schema_linked_service_read - linked_service_read.id = AAZStrType( - flags={"read_only": True}, - ) - linked_service_read.name = AAZStrType( - flags={"read_only": True}, - ) - linked_service_read.properties = AAZObjectType( - flags={"required": True, "client_flatten": True}, - ) - linked_service_read.tags = AAZDictType() - linked_service_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_linked_service_read.properties - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - ) - properties.resource_id = AAZStrType( - serialized_name="resourceId", - ) - properties.write_access_resource_id = AAZStrType( - serialized_name="writeAccessResourceId", - ) - - tags = _schema_linked_service_read.tags - tags.Element = AAZStrType() - - _schema.id = _schema_linked_service_read.id - _schema.name = _schema_linked_service_read.name - _schema.properties = _schema_linked_service_read.properties - _schema.tags = _schema_linked_service_read.tags - _schema.type = _schema_linked_service_read.type +class _UpdateHelper: + """Helper class for Update""" + + _schema_linked_service_read = None + + @classmethod + def _build_schema_linked_service_read(cls, _schema): + if cls._schema_linked_service_read is not None: + _schema.id = cls._schema_linked_service_read.id + _schema.name = cls._schema_linked_service_read.name + _schema.properties = cls._schema_linked_service_read.properties + _schema.tags = cls._schema_linked_service_read.tags + _schema.type = cls._schema_linked_service_read.type + return + + cls._schema_linked_service_read = _schema_linked_service_read = AAZObjectType() + + linked_service_read = _schema_linked_service_read + linked_service_read.id = AAZStrType( + flags={"read_only": True}, + ) + linked_service_read.name = AAZStrType( + flags={"read_only": True}, + ) + linked_service_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + linked_service_read.tags = AAZDictType() + linked_service_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_linked_service_read.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + ) + properties.resource_id = AAZStrType( + serialized_name="resourceId", + ) + properties.write_access_resource_id = AAZStrType( + serialized_name="writeAccessResourceId", + ) + + tags = _schema_linked_service_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_linked_service_read.id + _schema.name = cls._schema_linked_service_read.name + _schema.properties = cls._schema_linked_service_read.properties + _schema.tags = cls._schema_linked_service_read.tags + _schema.type = cls._schema_linked_service_read.type __all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_wait.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_wait.py index 101b0aaf1a7..0faa3d903e5 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_wait.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_service/_wait.py @@ -67,11 +67,11 @@ def _execute_operations(self): self.LinkedServicesGet(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -195,4 +195,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _WaitHelper: + """Helper class for Wait""" + + __all__ = ["Wait"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_create.py index 6dcc41b90d3..a0375cc2e87 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_create.py @@ -51,7 +51,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--type", "--data-source-type"], help="Data source type for the linked storage account.", required=True, - id_part="child_name_1", enum={"Alerts": "Alerts", "AzureWatson": "AzureWatson", "CustomLogs": "CustomLogs", "Ingestion": "Ingestion", "Query": "Query"}, ) _args_schema.resource_group = AAZResourceGroupNameArg( @@ -61,7 +60,6 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["-n", "--workspace-name"], help="The name of the workspace.", required=True, - id_part="name", fmt=AAZStrArgFormat( pattern="^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$", max_length=63, @@ -88,11 +86,11 @@ def _execute_operations(self): self.LinkedStorageAccountsCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -236,4 +234,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _CreateHelper: + """Helper class for Create""" + + __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_delete.py index e6655935c0c..04abe8dec92 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_delete.py @@ -73,11 +73,11 @@ def _execute_operations(self): self.LinkedStorageAccountsDelete(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -143,4 +143,8 @@ def on_200(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_list.py index 69fd4f9daf3..8e157130d94 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_list.py @@ -64,11 +64,11 @@ def _execute_operations(self): self.LinkedStorageAccountsListByWorkspace(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -192,4 +192,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_show.py index 9d9fc37105f..564a61d87b7 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_show.py @@ -72,11 +72,11 @@ def _execute_operations(self): self.LinkedStorageAccountsGet(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -198,4 +198,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_update.py index 7a98aafdedf..8e9ef5e2b1c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/linked_storage/_update.py @@ -87,19 +87,19 @@ def _execute_operations(self): self.LinkedStorageAccountsCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass - # @register_callback + @register_callback def pre_instance_update(self, instance): pass - # @register_callback + @register_callback def post_instance_update(self, instance): pass @@ -190,7 +190,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_linked_storage_accounts_resource_read(cls._schema_on_200) + _UpdateHelper._build_schema_linked_storage_accounts_resource_read(cls._schema_on_200) return cls._schema_on_200 @@ -289,7 +289,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_linked_storage_accounts_resource_read(cls._schema_on_200) + _UpdateHelper._build_schema_linked_storage_accounts_resource_read(cls._schema_on_200) return cls._schema_on_200 @@ -325,51 +325,53 @@ def __call__(self, *args, **kwargs): ) -_schema_linked_storage_accounts_resource_read = None - - -def _build_schema_linked_storage_accounts_resource_read(_schema): - global _schema_linked_storage_accounts_resource_read - if _schema_linked_storage_accounts_resource_read is not None: - _schema.id = _schema_linked_storage_accounts_resource_read.id - _schema.name = _schema_linked_storage_accounts_resource_read.name - _schema.properties = _schema_linked_storage_accounts_resource_read.properties - _schema.type = _schema_linked_storage_accounts_resource_read.type - return - - _schema_linked_storage_accounts_resource_read = AAZObjectType() - - linked_storage_accounts_resource_read = _schema_linked_storage_accounts_resource_read - linked_storage_accounts_resource_read.id = AAZStrType( - flags={"read_only": True}, - ) - linked_storage_accounts_resource_read.name = AAZStrType( - flags={"read_only": True}, - ) - linked_storage_accounts_resource_read.properties = AAZObjectType( - flags={"required": True, "client_flatten": True}, - ) - linked_storage_accounts_resource_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_linked_storage_accounts_resource_read.properties - properties.data_source_type = AAZStrType( - serialized_name="dataSourceType", - flags={"read_only": True}, - ) - properties.storage_account_ids = AAZListType( - serialized_name="storageAccountIds", - flags={"required": True}, - ) - - storage_account_ids = _schema_linked_storage_accounts_resource_read.properties.storage_account_ids - storage_account_ids.Element = AAZStrType() - - _schema.id = _schema_linked_storage_accounts_resource_read.id - _schema.name = _schema_linked_storage_accounts_resource_read.name - _schema.properties = _schema_linked_storage_accounts_resource_read.properties - _schema.type = _schema_linked_storage_accounts_resource_read.type +class _UpdateHelper: + """Helper class for Update""" + + _schema_linked_storage_accounts_resource_read = None + + @classmethod + def _build_schema_linked_storage_accounts_resource_read(cls, _schema): + if cls._schema_linked_storage_accounts_resource_read is not None: + _schema.id = cls._schema_linked_storage_accounts_resource_read.id + _schema.name = cls._schema_linked_storage_accounts_resource_read.name + _schema.properties = cls._schema_linked_storage_accounts_resource_read.properties + _schema.type = cls._schema_linked_storage_accounts_resource_read.type + return + + cls._schema_linked_storage_accounts_resource_read = _schema_linked_storage_accounts_resource_read = AAZObjectType() + + linked_storage_accounts_resource_read = _schema_linked_storage_accounts_resource_read + linked_storage_accounts_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + linked_storage_accounts_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + linked_storage_accounts_resource_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + linked_storage_accounts_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_linked_storage_accounts_resource_read.properties + properties.data_source_type = AAZStrType( + serialized_name="dataSourceType", + flags={"read_only": True}, + ) + properties.storage_account_ids = AAZListType( + serialized_name="storageAccountIds", + flags={"required": True}, + ) + + storage_account_ids = _schema_linked_storage_accounts_resource_read.properties.storage_account_ids + storage_account_ids.Element = AAZStrType() + + _schema.id = cls._schema_linked_storage_accounts_resource_read.id + _schema.name = cls._schema_linked_storage_accounts_resource_read.name + _schema.properties = cls._schema_linked_storage_accounts_resource_read.properties + _schema.type = cls._schema_linked_storage_accounts_resource_read.type __all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_disable.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_disable.py index 060ec6079a1..1a9fd3607a9 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_disable.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_disable.py @@ -69,11 +69,11 @@ def _execute_operations(self): self.IntelligencePacksDisable(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -139,4 +139,8 @@ def on_200(self, session): pass +class _DisableHelper: + """Helper class for Disable""" + + __all__ = ["Disable"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_enable.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_enable.py index b9902c2d0be..8980b568f89 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_enable.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_enable.py @@ -69,11 +69,11 @@ def _execute_operations(self): self.IntelligencePacksEnable(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -139,4 +139,8 @@ def on_200(self, session): pass +class _EnableHelper: + """Helper class for Enable""" + + __all__ = ["Enable"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_list.py index fbdb08eaca7..817d1f5e5ec 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/pack/_list.py @@ -64,11 +64,11 @@ def _execute_operations(self): self.IntelligencePacksList(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -169,4 +169,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_create.py index cd3e2861328..cf88c3cb1fc 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_create.py @@ -48,13 +48,11 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["-n", "--name", "--saved-search-name"], help="Name of the saved search and it's unique in a given workspace.", required=True, - id_part="child_name_1", ) _args_schema.workspace_name = AAZStrArg( options=["--workspace-name"], help="The name of the workspace.", required=True, - id_part="name", fmt=AAZStrArgFormat( pattern="^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$", max_length=63, @@ -127,11 +125,11 @@ def _execute_operations(self): self.SavedSearchesCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -305,4 +303,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _CreateHelper: + """Helper class for Create""" + + __all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_delete.py index 5bd4568a7fb..ddedd610fa1 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_delete.py @@ -69,11 +69,11 @@ def _execute_operations(self): self.SavedSearchesDelete(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -139,4 +139,8 @@ def on_200(self, session): pass +class _DeleteHelper: + """Helper class for Delete""" + + __all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_list.py index 8488b54ba9c..6a37c412dff 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_list.py @@ -61,11 +61,11 @@ def _execute_operations(self): self.SavedSearchesListByWorkspace(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -208,4 +208,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ListHelper: + """Helper class for List""" + + __all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_show.py index e5f8e1dbab3..e3d164c10fa 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_show.py @@ -68,11 +68,11 @@ def _execute_operations(self): self.SavedSearchesGet(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass @@ -213,4 +213,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 +class _ShowHelper: + """Helper class for Show""" + + __all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_update.py index 7c337c55976..ad13e45dc56 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_analytics/workspace/saved_search/_update.py @@ -135,19 +135,19 @@ def _execute_operations(self): self.SavedSearchesCreateOrUpdate(ctx=self.ctx)() self.post_operations() - # @register_callback + @register_callback def pre_operations(self): pass - # @register_callback + @register_callback def post_operations(self): pass - # @register_callback + @register_callback def pre_instance_update(self, instance): pass - # @register_callback + @register_callback def post_instance_update(self, instance): pass @@ -238,7 +238,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_saved_search_read(cls._schema_on_200) + _UpdateHelper._build_schema_saved_search_read(cls._schema_on_200) return cls._schema_on_200 @@ -337,7 +337,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 cls._schema_on_200 = AAZObjectType() - _build_schema_saved_search_read(cls._schema_on_200) + _UpdateHelper._build_schema_saved_search_read(cls._schema_on_200) return cls._schema_on_200 @@ -384,72 +384,74 @@ def __call__(self, *args, **kwargs): ) -_schema_saved_search_read = None - - -def _build_schema_saved_search_read(_schema): - global _schema_saved_search_read - if _schema_saved_search_read is not None: - _schema.etag = _schema_saved_search_read.etag - _schema.id = _schema_saved_search_read.id - _schema.name = _schema_saved_search_read.name - _schema.properties = _schema_saved_search_read.properties - _schema.type = _schema_saved_search_read.type - return - - _schema_saved_search_read = AAZObjectType() - - saved_search_read = _schema_saved_search_read - saved_search_read.etag = AAZStrType() - saved_search_read.id = AAZStrType( - flags={"read_only": True}, - ) - saved_search_read.name = AAZStrType( - flags={"read_only": True}, - ) - saved_search_read.properties = AAZObjectType( - flags={"required": True, "client_flatten": True}, - ) - saved_search_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_saved_search_read.properties - properties.category = AAZStrType( - flags={"required": True}, - ) - properties.display_name = AAZStrType( - serialized_name="displayName", - flags={"required": True}, - ) - properties.function_alias = AAZStrType( - serialized_name="functionAlias", - ) - properties.function_parameters = AAZStrType( - serialized_name="functionParameters", - ) - properties.query = AAZStrType( - flags={"required": True}, - ) - properties.tags = AAZListType() - properties.version = AAZIntType() - - tags = _schema_saved_search_read.properties.tags - tags.Element = AAZObjectType() - - _element = _schema_saved_search_read.properties.tags.Element - _element.name = AAZStrType( - flags={"required": True}, - ) - _element.value = AAZStrType( - flags={"required": True}, - ) - - _schema.etag = _schema_saved_search_read.etag - _schema.id = _schema_saved_search_read.id - _schema.name = _schema_saved_search_read.name - _schema.properties = _schema_saved_search_read.properties - _schema.type = _schema_saved_search_read.type +class _UpdateHelper: + """Helper class for Update""" + + _schema_saved_search_read = None + + @classmethod + def _build_schema_saved_search_read(cls, _schema): + if cls._schema_saved_search_read is not None: + _schema.etag = cls._schema_saved_search_read.etag + _schema.id = cls._schema_saved_search_read.id + _schema.name = cls._schema_saved_search_read.name + _schema.properties = cls._schema_saved_search_read.properties + _schema.type = cls._schema_saved_search_read.type + return + + cls._schema_saved_search_read = _schema_saved_search_read = AAZObjectType() + + saved_search_read = _schema_saved_search_read + saved_search_read.etag = AAZStrType() + saved_search_read.id = AAZStrType( + flags={"read_only": True}, + ) + saved_search_read.name = AAZStrType( + flags={"read_only": True}, + ) + saved_search_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + saved_search_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_saved_search_read.properties + properties.category = AAZStrType( + flags={"required": True}, + ) + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + properties.function_alias = AAZStrType( + serialized_name="functionAlias", + ) + properties.function_parameters = AAZStrType( + serialized_name="functionParameters", + ) + properties.query = AAZStrType( + flags={"required": True}, + ) + properties.tags = AAZListType() + properties.version = AAZIntType() + + tags = _schema_saved_search_read.properties.tags + tags.Element = AAZObjectType() + + _element = _schema_saved_search_read.properties.tags.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + _schema.etag = cls._schema_saved_search_read.etag + _schema.id = cls._schema_saved_search_read.id + _schema.name = cls._schema_saved_search_read.name + _schema.properties = cls._schema_saved_search_read.properties + _schema.type = cls._schema_saved_search_read.type __all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_profiles/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_profiles/_create.py index d7d6f87cb3c..2e2c3c3769e 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_profiles/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/log_profiles/_create.py @@ -17,7 +17,7 @@ class Create(AAZCommand): """Create a log profile in Azure Monitoring REST API. - :example: Create a log profile. (autogenerated) + :example: Create a log profile. az monitor log-profiles create --categories "Delete" --days 0 --enabled true --location westus2 --locations westus --name MyLogProfile --service-bus-rule-id "/subscriptions/{YOUR SUBSCRIPTION ID}/resourceGroups/{RESOURCE GROUP NAME}/providers/Microsoft.EventHub/namespaces/{EVENT HUB NAME SPACE}/authorizationrules/RootManageSharedAccessKey" """ diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/__init__.py index 92c07af8d7c..d60a7a0f494 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/__init__.py @@ -14,3 +14,4 @@ from ._list_namespaces import * from ._list_sub import * from ._list_sub_definitions import * +from ._list_sub_get import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/_list_sub_get.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/_list_sub_get.py new file mode 100644 index 00000000000..1278c6d1ccf --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/_list_sub_get.py @@ -0,0 +1,329 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor metrics list-sub-get", +) +class ListSubGet(AAZCommand): + """List the metric data for a subscription. + """ + + _aaz_info = { + "version": "2023-10-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/metrics", "2023-10-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.auto_adjust_timegrain = AAZBoolArg( + options=["--auto-adjust-timegrain"], + help="When set to true, if the timespan passed in is not supported by this metric, the API will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan parameters. Defaults to false.", + ) + _args_schema.validate_dimensions = AAZBoolArg( + options=["--validate-dimensions"], + help="When set to false, invalid filter parameter values will be ignored. When set to true, an error is returned for invalid filter parameters. Defaults to true.", + ) + _args_schema.aggregation = AAZStrArg( + options=["--aggregation"], + help="The list of aggregation types (comma separated) to retrieve. *Examples: average, minimum, maximum*", + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="The **$filter** is used to reduce the set of metric data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.", + ) + _args_schema.interval = AAZStrArg( + options=["--interval"], + help="The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special case for 'FULL' value that returns single datapoint for entire time span requested. *Examples: PT15M, PT1H, P1D, FULL*", + ) + _args_schema.metricnames = AAZStrArg( + options=["--metricnames"], + help="The names of the metrics (comma separated) to retrieve.", + ) + _args_schema.metricnamespace = AAZStrArg( + options=["--metricnamespace"], + help="Metric namespace where the metrics you want reside.", + ) + _args_schema.orderby = AAZStrArg( + options=["--orderby"], + help="The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. *Examples: sum asc*", + ) + _args_schema.region = AAZStrArg( + options=["--region"], + help="The region where the metrics you want reside.", + required=True, + ) + _args_schema.result_type = AAZStrArg( + options=["--result-type"], + help="Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details.", + enum={"Data": "Data", "Metadata": "Metadata"}, + ) + _args_schema.rollupby = AAZStrArg( + options=["--rollupby"], + help="Dimension name(s) to rollup results by. For example if you only want to see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.", + ) + _args_schema.timespan = AAZStrArg( + options=["--timespan"], + help="The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="The maximum number of records to retrieve per resource ID in the request. Valid only if filter is specified. Defaults to 10.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricsListAtSubscriptionScope(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 MetricsListAtSubscriptionScope(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "AutoAdjustTimegrain", self.ctx.args.auto_adjust_timegrain, + ), + **self.serialize_query_param( + "ValidateDimensions", self.ctx.args.validate_dimensions, + ), + **self.serialize_query_param( + "aggregation", self.ctx.args.aggregation, + ), + **self.serialize_query_param( + "interval", self.ctx.args.interval, + ), + **self.serialize_query_param( + "metricnames", self.ctx.args.metricnames, + ), + **self.serialize_query_param( + "metricnamespace", self.ctx.args.metricnamespace, + ), + **self.serialize_query_param( + "orderby", self.ctx.args.orderby, + ), + **self.serialize_query_param( + "region", self.ctx.args.region, + required=True, + ), + **self.serialize_query_param( + "resultType", self.ctx.args.result_type, + ), + **self.serialize_query_param( + "rollupby", self.ctx.args.rollupby, + ), + **self.serialize_query_param( + "timespan", self.ctx.args.timespan, + ), + **self.serialize_query_param( + "top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2023-10-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.cost = AAZIntType() + _schema_on_200.interval = AAZStrType() + _schema_on_200.namespace = AAZStrType() + _schema_on_200.resourceregion = AAZStrType() + _schema_on_200.timespan = AAZStrType( + flags={"required": True}, + ) + _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.display_description = AAZStrType( + serialized_name="displayDescription", + ) + _element.error_code = AAZStrType( + serialized_name="errorCode", + ) + _element.error_message = AAZStrType( + serialized_name="errorMessage", + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZObjectType( + flags={"required": True}, + ) + _ListSubGetHelper._build_schema_localizable_string_read(_element.name) + _element.timeseries = AAZListType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.unit = AAZStrType( + flags={"required": True}, + ) + + timeseries = cls._schema_on_200.value.Element.timeseries + timeseries.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.timeseries.Element + _element.data = AAZListType() + _element.metadatavalues = AAZListType() + + data = cls._schema_on_200.value.Element.timeseries.Element.data + data.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.timeseries.Element.data.Element + _element.average = AAZFloatType() + _element.count = AAZFloatType() + _element.maximum = AAZFloatType() + _element.minimum = AAZFloatType() + _element.time_stamp = AAZStrType( + serialized_name="timeStamp", + flags={"required": True}, + ) + _element.total = AAZFloatType() + + metadatavalues = cls._schema_on_200.value.Element.timeseries.Element.metadatavalues + metadatavalues.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.timeseries.Element.metadatavalues.Element + _element.name = AAZObjectType() + _ListSubGetHelper._build_schema_localizable_string_read(_element.name) + _element.value = AAZStrType() + + return cls._schema_on_200 + + +class _ListSubGetHelper: + """Helper class for ListSubGet""" + + _schema_localizable_string_read = None + + @classmethod + def _build_schema_localizable_string_read(cls, _schema): + if cls._schema_localizable_string_read is not None: + _schema.localized_value = cls._schema_localizable_string_read.localized_value + _schema.value = cls._schema_localizable_string_read.value + return + + cls._schema_localizable_string_read = _schema_localizable_string_read = AAZObjectType() + + localizable_string_read = _schema_localizable_string_read + localizable_string_read.localized_value = AAZStrType( + serialized_name="localizedValue", + ) + localizable_string_read.value = AAZStrType( + flags={"required": True}, + ) + + _schema.localized_value = cls._schema_localizable_string_read.localized_value + _schema.value = cls._schema_localizable_string_read.value + + +__all__ = ["ListSubGet"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_create.py index 18f45ed89ae..4da9cbd03f0 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_create.py @@ -16,9 +16,9 @@ class Create(AAZCommand): """ _aaz_info = { - "version": "2018-03-01", + "version": "2024-03-01-preview", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2018-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2024-03-01-preview"], ] } @@ -47,6 +47,25 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, ) + # define Arg Group "Identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + # define Arg Group "Parameters" _args_schema = cls._args_schema @@ -70,6 +89,11 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Properties" _args_schema = cls._args_schema + _args_schema.action_properties = AAZDictArg( + options=["--action-properties"], + arg_group="Properties", + help="The properties of an action properties.", + ) _args_schema.actions = AAZListArg( options=["--actions"], arg_group="Properties", @@ -86,6 +110,11 @@ def _build_arguments_schema(cls, *args, **kwargs): help="defines the specific alert criteria information.", required=True, ) + _args_schema.custom_properties = AAZDictArg( + options=["--custom-properties"], + arg_group="Properties", + help="The properties of an alert payload.", + ) _args_schema.description = AAZStrArg( options=["--description"], arg_group="Properties", @@ -103,6 +132,11 @@ def _build_arguments_schema(cls, *args, **kwargs): help="how often the metric alert is evaluated represented in ISO 8601 duration format.", required=True, ) + _args_schema.resolve_configuration = AAZObjectArg( + options=["--resolve-configuration"], + arg_group="Properties", + help="The configuration for how the alert is resolved. Applicable for PromQLCriteria.", + ) _args_schema.scopes = AAZListArg( options=["--scopes"], arg_group="Properties", @@ -129,9 +163,11 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--window-size"], arg_group="Properties", help="the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.", - required=True, ) + action_properties = cls._args_schema.action_properties + action_properties.Element = AAZStrArg() + actions = cls._args_schema.actions actions.Element = AAZObjectArg() @@ -152,6 +188,9 @@ def _build_arguments_schema(cls, *args, **kwargs): criteria.microsoft_azure_monitor_multiple_resource_multiple_metric_criteria = AAZObjectArg( options=["microsoft-azure-monitor-multiple-resource-multiple-metric-criteria"], ) + criteria.microsoft_azure_monitor_prom_ql_criteria = AAZObjectArg( + options=["microsoft-azure-monitor-prom-ql-criteria"], + ) criteria.microsoft_azure_monitor_single_resource_multiple_metric_criteria = AAZObjectArg( options=["microsoft-azure-monitor-single-resource-multiple-metric-criteria"], ) @@ -219,6 +258,9 @@ def _build_arguments_schema(cls, *args, **kwargs): dynamic_threshold_criterion.ignore_data_before = AAZDateTimeArg( options=["ignore-data-before"], help="Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format)", + fmt=AAZDateTimeFormat( + protocol="iso", + ), ) dynamic_threshold_criterion.operator = AAZStrArg( options=["operator"], @@ -256,6 +298,66 @@ def _build_arguments_schema(cls, *args, **kwargs): dimensions.Element = AAZObjectArg() cls._build_args_metric_dimension_create(dimensions.Element) + microsoft_azure_monitor_prom_ql_criteria = cls._args_schema.criteria.microsoft_azure_monitor_prom_ql_criteria + microsoft_azure_monitor_prom_ql_criteria.all_of = AAZListArg( + options=["all-of"], + help="The list of promQL criteria. Alert will be raised when all conditions are met.", + ) + microsoft_azure_monitor_prom_ql_criteria.failing_periods = AAZObjectArg( + options=["failing-periods"], + help="Configuration for failing periods in query-based alerts.", + ) + + all_of = cls._args_schema.criteria.microsoft_azure_monitor_prom_ql_criteria.all_of + all_of.Element = AAZObjectArg() + + _element = cls._args_schema.criteria.microsoft_azure_monitor_prom_ql_criteria.all_of.Element + _element.dynamic_threshold_criterion = AAZObjectArg( + options=["dynamic-threshold-criterion"], + ) + _element.static_threshold_criterion = AAZObjectArg( + options=["static-threshold-criterion"], + blank={}, + ) + _element.name = AAZStrArg( + options=["name"], + help="Name of the criteria.", + required=True, + ) + _element.query = AAZStrArg( + options=["query"], + help="The query used to evaluate the alert rule", + required=True, + ) + + dynamic_threshold_criterion = cls._args_schema.criteria.microsoft_azure_monitor_prom_ql_criteria.all_of.Element.dynamic_threshold_criterion + dynamic_threshold_criterion.alert_sensitivity = AAZStrArg( + options=["alert-sensitivity"], + help="The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Previously undocumented values might be returned", + required=True, + enum={"High": "High", "Low": "Low", "Medium": "Medium"}, + ) + dynamic_threshold_criterion.ignore_data_before = AAZDateTimeArg( + options=["ignore-data-before"], + help="Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format)", + fmt=AAZDateTimeFormat( + protocol="iso", + ), + ) + dynamic_threshold_criterion.operator = AAZStrArg( + options=["operator"], + help="The operator used to compare the metric value against the threshold. Previously undocumented values might be returned", + required=True, + enum={"GreaterOrLessThan": "GreaterOrLessThan", "GreaterThan": "GreaterThan", "LessThan": "LessThan"}, + ) + + failing_periods = cls._args_schema.criteria.microsoft_azure_monitor_prom_ql_criteria.failing_periods + failing_periods.for_ = AAZDurationArg( + options=["for"], + help="The amount of time (in ISO 8601 duration format) alert must be active before firing.", + required=True, + ) + microsoft_azure_monitor_single_resource_multiple_metric_criteria = cls._args_schema.criteria.microsoft_azure_monitor_single_resource_multiple_metric_criteria microsoft_azure_monitor_single_resource_multiple_metric_criteria.all_of = AAZListArg( options=["all-of"], @@ -327,6 +429,20 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, ) + custom_properties = cls._args_schema.custom_properties + custom_properties.Element = AAZStrArg() + + resolve_configuration = cls._args_schema.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolArg( + options=["auto-resolved"], + help="Indicates whether the alert should be auto resolved", + required=True, + ) + resolve_configuration.time_to_resolve = AAZDurationArg( + options=["time-to-resolve"], + help="The time (in ISO 8601 duration format) after which the alert should be auto resolved", + ) + scopes = cls._args_schema.scopes scopes.Element = AAZStrArg() return cls._args_schema @@ -408,7 +524,7 @@ def method(self): @property def error_format(self): - return "ODataV4Format" + return "MgmtErrorFormat" @property def url_parameters(self): @@ -432,7 +548,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2018-03-01", + "api-version", "2024-03-01-preview", required=True, ), } @@ -457,23 +573,40 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) + _builder.set_prop("identity", AAZIdentityObjectType) _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) _builder.set_prop("tags", AAZDictType, ".tags") + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}}) + identity.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "create"}}) + + user_assigned = _builder.get(".identity.userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + properties = _builder.get(".properties") if properties is not None: + properties.set_prop("actionProperties", AAZDictType, ".action_properties") properties.set_prop("actions", AAZListType, ".actions") properties.set_prop("autoMitigate", AAZBoolType, ".auto_mitigate") properties.set_prop("criteria", AAZObjectType, ".criteria", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("customProperties", AAZDictType, ".custom_properties") properties.set_prop("description", AAZStrType, ".description") properties.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) properties.set_prop("evaluationFrequency", AAZStrType, ".evaluation_frequency", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("resolveConfiguration", AAZObjectType, ".resolve_configuration") properties.set_prop("scopes", AAZListType, ".scopes", typ_kwargs={"flags": {"required": True}}) properties.set_prop("severity", AAZIntType, ".severity", typ_kwargs={"flags": {"required": True}}) properties.set_prop("targetResourceRegion", AAZStrType, ".target_resource_region") properties.set_prop("targetResourceType", AAZStrType, ".target_resource_type") - properties.set_prop("windowSize", AAZStrType, ".window_size", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("windowSize", AAZStrType, ".window_size") + + action_properties = _builder.get(".properties.actionProperties") + if action_properties is not None: + action_properties.set_elements(AAZStrType, ".") actions = _builder.get(".properties.actions") if actions is not None: @@ -491,9 +624,11 @@ def content(self): criteria = _builder.get(".properties.criteria") if criteria is not None: criteria.set_const("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", AAZStrType, ".microsoft_azure_monitor_multiple_resource_multiple_metric_criteria", typ_kwargs={"flags": {"required": True}}) + criteria.set_const("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria", AAZStrType, ".microsoft_azure_monitor_prom_ql_criteria", typ_kwargs={"flags": {"required": True}}) criteria.set_const("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", AAZStrType, ".microsoft_azure_monitor_single_resource_multiple_metric_criteria", typ_kwargs={"flags": {"required": True}}) criteria.set_const("odata.type", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria", AAZStrType, ".microsoft_azure_monitor_webtest_location_availability_criteria", typ_kwargs={"flags": {"required": True}}) criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria") + criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria") @@ -539,6 +674,34 @@ def content(self): disc_static_threshold_criterion.set_prop("operator", AAZStrType, ".static_threshold_criterion.operator", typ_kwargs={"flags": {"required": True}}) disc_static_threshold_criterion.set_prop("threshold", AAZFloatType, ".static_threshold_criterion.threshold", typ_kwargs={"flags": {"required": True}}) + disc_microsoft__azure__monitor__prom_ql_criteria = _builder.get(".properties.criteria{odata.type:Microsoft.Azure.Monitor.PromQLCriteria}") + if disc_microsoft__azure__monitor__prom_ql_criteria is not None: + disc_microsoft__azure__monitor__prom_ql_criteria.set_prop("allOf", AAZListType, ".microsoft_azure_monitor_prom_ql_criteria.all_of") + disc_microsoft__azure__monitor__prom_ql_criteria.set_prop("failingPeriods", AAZObjectType, ".microsoft_azure_monitor_prom_ql_criteria.failing_periods") + + all_of = _builder.get(".properties.criteria{odata.type:Microsoft.Azure.Monitor.PromQLCriteria}.allOf") + if all_of is not None: + all_of.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.criteria{odata.type:Microsoft.Azure.Monitor.PromQLCriteria}.allOf[]") + if _elements is not None: + _elements.set_const("criterionType", "DynamicThresholdCriterion", AAZStrType, ".dynamic_threshold_criterion", typ_kwargs={"flags": {"required": True}}) + _elements.set_const("criterionType", "StaticThresholdCriterion", AAZStrType, ".static_threshold_criterion", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("query", AAZStrType, ".query", typ_kwargs={"flags": {"required": True}}) + _elements.discriminate_by("criterionType", "DynamicThresholdCriterion") + _elements.discriminate_by("criterionType", "StaticThresholdCriterion") + + disc_dynamic_threshold_criterion = _builder.get(".properties.criteria{odata.type:Microsoft.Azure.Monitor.PromQLCriteria}.allOf[]{criterionType:DynamicThresholdCriterion}") + if disc_dynamic_threshold_criterion is not None: + disc_dynamic_threshold_criterion.set_prop("alertSensitivity", AAZStrType, ".dynamic_threshold_criterion.alert_sensitivity", typ_kwargs={"flags": {"required": True}}) + disc_dynamic_threshold_criterion.set_prop("ignoreDataBefore", AAZStrType, ".dynamic_threshold_criterion.ignore_data_before") + disc_dynamic_threshold_criterion.set_prop("operator", AAZStrType, ".dynamic_threshold_criterion.operator", typ_kwargs={"flags": {"required": True}}) + + failing_periods = _builder.get(".properties.criteria{odata.type:Microsoft.Azure.Monitor.PromQLCriteria}.failingPeriods") + if failing_periods is not None: + failing_periods.set_prop("for", AAZStrType, ".for_", typ_kwargs={"flags": {"required": True}}) + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = _builder.get(".properties.criteria{odata.type:Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria}") if disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria is not None: disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.set_prop("allOf", AAZListType, ".microsoft_azure_monitor_single_resource_multiple_metric_criteria.all_of") @@ -569,6 +732,15 @@ def content(self): disc_microsoft__azure__monitor__webtest_location_availability_criteria.set_prop("failedLocationCount", AAZFloatType, ".microsoft_azure_monitor_webtest_location_availability_criteria.failed_location_count", typ_kwargs={"flags": {"required": True}}) disc_microsoft__azure__monitor__webtest_location_availability_criteria.set_prop("webTestId", AAZStrType, ".microsoft_azure_monitor_webtest_location_availability_criteria.web_test_id", typ_kwargs={"flags": {"required": True}}) + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_elements(AAZStrType, ".") + + resolve_configuration = _builder.get(".properties.resolveConfiguration") + if resolve_configuration is not None: + resolve_configuration.set_prop("autoResolved", AAZBoolType, ".auto_resolved", typ_kwargs={"flags": {"required": True}}) + resolve_configuration.set_prop("timeToResolve", AAZStrType, ".time_to_resolve") + scopes = _builder.get(".properties.scopes") if scopes is not None: scopes.set_elements(AAZStrType, ".") @@ -600,6 +772,7 @@ def _build_schema_on_200(cls): _schema_on_200.id = AAZStrType( flags={"read_only": True}, ) + _schema_on_200.identity = AAZIdentityObjectType() _schema_on_200.location = AAZStrType( flags={"required": True}, ) @@ -614,7 +787,39 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) properties.actions = AAZListType() properties.auto_mitigate = AAZBoolType( serialized_name="autoMitigate", @@ -622,6 +827,9 @@ def _build_schema_on_200(cls): properties.criteria = AAZObjectType( flags={"required": True}, ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) properties.description = AAZStrType() properties.enabled = AAZBoolType( flags={"required": True}, @@ -638,6 +846,9 @@ def _build_schema_on_200(cls): serialized_name="lastUpdatedTime", flags={"read_only": True}, ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) properties.scopes = AAZListType( flags={"required": True}, ) @@ -652,9 +863,11 @@ def _build_schema_on_200(cls): ) properties.window_size = AAZStrType( serialized_name="windowSize", - flags={"required": True}, ) + action_properties = cls._schema_on_200.properties.action_properties + action_properties.Element = AAZStrType() + actions = cls._schema_on_200.properties.actions actions.Element = AAZObjectType() @@ -744,6 +957,46 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + disc_microsoft__azure__monitor__prom_ql_criteria = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( serialized_name="allOf", @@ -800,6 +1053,18 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + custom_properties = cls._schema_on_200.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = cls._schema_on_200.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + scopes = cls._schema_on_200.properties.scopes scopes.Element = AAZStrType() diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_delete.py index 33c24bea42f..ad32ff6d99c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_delete.py @@ -22,9 +22,9 @@ class Delete(AAZCommand): """ _aaz_info = { - "version": "2018-03-01", + "version": "2024-03-01-preview", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2018-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2024-03-01-preview"], ] } @@ -94,7 +94,7 @@ def method(self): @property def error_format(self): - return "ODataV4Format" + return "MgmtErrorFormat" @property def url_parameters(self): @@ -118,7 +118,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2018-03-01", + "api-version", "2024-03-01-preview", required=True, ), } diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_list.py index 368f9102904..c7a3daf2f13 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_list.py @@ -22,10 +22,10 @@ class List(AAZCommand): """ _aaz_info = { - "version": "2018-03-01", + "version": "2024-03-01-preview", "resources": [ - ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/metricalerts", "2018-03-01"], - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts", "2018-03-01"], + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.insights/metricalerts", "2024-03-01-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts", "2024-03-01-preview"], ] } @@ -50,12 +50,12 @@ def _build_arguments_schema(cls, *args, **kwargs): def _execute_operations(self): self.pre_operations() - condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) - condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) if condition_0: - self.MetricAlertsListByResourceGroup(ctx=self.ctx)() - if condition_1: self.MetricAlertsListBySubscription(ctx=self.ctx)() + if condition_1: + self.MetricAlertsListByResourceGroup(ctx=self.ctx)() self.post_operations() @register_callback @@ -70,7 +70,7 @@ def _output(self, *args, **kwargs): result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) return result - class MetricAlertsListByResourceGroup(AAZHttpOperation): + class MetricAlertsListBySubscription(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -84,7 +84,7 @@ def __call__(self, *args, **kwargs): @property def url(self): return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts", + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts", **self.url_parameters ) @@ -94,15 +94,11 @@ def method(self): @property def error_format(self): - return "ODataV4Format" + return "MgmtErrorFormat" @property def url_parameters(self): parameters = { - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), **self.serialize_url_param( "subscriptionId", self.ctx.subscription_id, required=True, @@ -114,7 +110,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2018-03-01", + "api-version", "2024-03-01-preview", required=True, ), } @@ -156,6 +152,7 @@ def _build_schema_on_200(cls): _element.id = AAZStrType( flags={"read_only": True}, ) + _element.identity = AAZIdentityObjectType() _element.location = AAZStrType( flags={"required": True}, ) @@ -170,7 +167,39 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.value.Element.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) properties.actions = AAZListType() properties.auto_mitigate = AAZBoolType( serialized_name="autoMitigate", @@ -178,6 +207,9 @@ def _build_schema_on_200(cls): properties.criteria = AAZObjectType( flags={"required": True}, ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) properties.description = AAZStrType() properties.enabled = AAZBoolType( flags={"required": True}, @@ -194,6 +226,9 @@ def _build_schema_on_200(cls): serialized_name="lastUpdatedTime", flags={"read_only": True}, ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) properties.scopes = AAZListType( flags={"required": True}, ) @@ -208,9 +243,11 @@ def _build_schema_on_200(cls): ) properties.window_size = AAZStrType( serialized_name="windowSize", - flags={"required": True}, ) + action_properties = cls._schema_on_200.value.Element.properties.action_properties + action_properties.Element = AAZStrType() + actions = cls._schema_on_200.value.Element.properties.actions actions.Element = AAZObjectType() @@ -300,6 +337,46 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + disc_microsoft__azure__monitor__prom_ql_criteria = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( serialized_name="allOf", @@ -356,6 +433,18 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + custom_properties = cls._schema_on_200.value.Element.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = cls._schema_on_200.value.Element.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + scopes = cls._schema_on_200.value.Element.properties.scopes scopes.Element = AAZStrType() @@ -364,7 +453,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 - class MetricAlertsListBySubscription(AAZHttpOperation): + class MetricAlertsListByResourceGroup(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -378,7 +467,7 @@ def __call__(self, *args, **kwargs): @property def url(self): return self.client.format_url( - "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts", **self.url_parameters ) @@ -388,11 +477,15 @@ def method(self): @property def error_format(self): - return "ODataV4Format" + return "MgmtErrorFormat" @property def url_parameters(self): parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), **self.serialize_url_param( "subscriptionId", self.ctx.subscription_id, required=True, @@ -404,7 +497,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2018-03-01", + "api-version", "2024-03-01-preview", required=True, ), } @@ -446,6 +539,7 @@ def _build_schema_on_200(cls): _element.id = AAZStrType( flags={"read_only": True}, ) + _element.identity = AAZIdentityObjectType() _element.location = AAZStrType( flags={"required": True}, ) @@ -460,7 +554,39 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.value.Element.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) properties.actions = AAZListType() properties.auto_mitigate = AAZBoolType( serialized_name="autoMitigate", @@ -468,6 +594,9 @@ def _build_schema_on_200(cls): properties.criteria = AAZObjectType( flags={"required": True}, ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) properties.description = AAZStrType() properties.enabled = AAZBoolType( flags={"required": True}, @@ -484,6 +613,9 @@ def _build_schema_on_200(cls): serialized_name="lastUpdatedTime", flags={"read_only": True}, ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) properties.scopes = AAZListType( flags={"required": True}, ) @@ -498,9 +630,11 @@ def _build_schema_on_200(cls): ) properties.window_size = AAZStrType( serialized_name="windowSize", - flags={"required": True}, ) + action_properties = cls._schema_on_200.value.Element.properties.action_properties + action_properties.Element = AAZStrType() + actions = cls._schema_on_200.value.Element.properties.actions actions.Element = AAZObjectType() @@ -590,6 +724,46 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + disc_microsoft__azure__monitor__prom_ql_criteria = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = cls._schema_on_200.value.Element.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( serialized_name="allOf", @@ -646,6 +820,18 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + custom_properties = cls._schema_on_200.value.Element.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = cls._schema_on_200.value.Element.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + scopes = cls._schema_on_200.value.Element.properties.scopes scopes.Element = AAZStrType() diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_show.py index ffb61f7b3fe..0fb5e647be3 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_show.py @@ -22,9 +22,9 @@ class Show(AAZCommand): """ _aaz_info = { - "version": "2018-03-01", + "version": "2024-03-01-preview", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2018-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2024-03-01-preview"], ] } @@ -96,7 +96,7 @@ def method(self): @property def error_format(self): - return "ODataV4Format" + return "MgmtErrorFormat" @property def url_parameters(self): @@ -120,7 +120,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2018-03-01", + "api-version", "2024-03-01-preview", required=True, ), } @@ -156,6 +156,7 @@ def _build_schema_on_200(cls): _schema_on_200.id = AAZStrType( flags={"read_only": True}, ) + _schema_on_200.identity = AAZIdentityObjectType() _schema_on_200.location = AAZStrType( flags={"required": True}, ) @@ -170,7 +171,39 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) properties.actions = AAZListType() properties.auto_mitigate = AAZBoolType( serialized_name="autoMitigate", @@ -178,6 +211,9 @@ def _build_schema_on_200(cls): properties.criteria = AAZObjectType( flags={"required": True}, ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) properties.description = AAZStrType() properties.enabled = AAZBoolType( flags={"required": True}, @@ -194,6 +230,9 @@ def _build_schema_on_200(cls): serialized_name="lastUpdatedTime", flags={"read_only": True}, ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) properties.scopes = AAZListType( flags={"required": True}, ) @@ -208,9 +247,11 @@ def _build_schema_on_200(cls): ) properties.window_size = AAZStrType( serialized_name="windowSize", - flags={"required": True}, ) + action_properties = cls._schema_on_200.properties.action_properties + action_properties.Element = AAZStrType() + actions = cls._schema_on_200.properties.actions actions.Element = AAZObjectType() @@ -300,6 +341,46 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + disc_microsoft__azure__monitor__prom_ql_criteria = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = cls._schema_on_200.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( serialized_name="allOf", @@ -356,6 +437,18 @@ def _build_schema_on_200(cls): flags={"required": True}, ) + custom_properties = cls._schema_on_200.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = cls._schema_on_200.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + scopes = cls._schema_on_200.properties.scopes scopes.Element = AAZStrType() diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_update.py index 1163c306c27..2c9bd42846c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/_update.py @@ -22,9 +22,9 @@ class Update(AAZCommand): """ _aaz_info = { - "version": "2018-03-01", + "version": "2024-03-01-preview", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2018-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2024-03-01-preview"], ] } @@ -84,6 +84,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.window_size = AAZDurationArg( options=["--window-size"], help="Time over which to aggregate metrics in `##h##m##s` format.", + nullable=True, ) _args_schema.tags = AAZDictArg( options=["--tags"], @@ -101,7 +102,50 @@ def _build_arguments_schema(cls, *args, **kwargs): nullable=True, ) + # define Arg Group "Identity" + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.action_properties = AAZDictArg( + options=["--action-properties"], + arg_group="Properties", + help="The properties of an action properties.", + nullable=True, + ) + _args_schema.custom_properties = AAZDictArg( + options=["--custom-properties"], + arg_group="Properties", + help="The properties of an alert payload.", + nullable=True, + ) + _args_schema.resolve_configuration = AAZObjectArg( + options=["--resolve-configuration"], + arg_group="Properties", + help="The configuration for how the alert is resolved. Applicable for PromQLCriteria.", + nullable=True, + ) + + action_properties = cls._args_schema.action_properties + action_properties.Element = AAZStrArg( + nullable=True, + ) + + custom_properties = cls._args_schema.custom_properties + custom_properties.Element = AAZStrArg( + nullable=True, + ) + + resolve_configuration = cls._args_schema.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolArg( + options=["auto-resolved"], + help="Indicates whether the alert should be auto resolved", + ) + resolve_configuration.time_to_resolve = AAZDurationArg( + options=["time-to-resolve"], + help="The time (in ISO 8601 duration format) after which the alert should be auto resolved", + nullable=True, + ) return cls._args_schema _args_metric_dimension_update = None @@ -195,7 +239,7 @@ def method(self): @property def error_format(self): - return "ODataV4Format" + return "MgmtErrorFormat" @property def url_parameters(self): @@ -219,7 +263,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2018-03-01", + "api-version", "2024-03-01-preview", required=True, ), } @@ -278,7 +322,7 @@ def method(self): @property def error_format(self): - return "ODataV4Format" + return "MgmtErrorFormat" @property def url_parameters(self): @@ -302,7 +346,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2018-03-01", + "api-version", "2024-03-01-preview", required=True, ), } @@ -360,18 +404,35 @@ def _update_instance(self, instance): value=instance, typ=AAZObjectType ) + _builder.set_prop("identity", AAZIdentityObjectType) _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) _builder.set_prop("tags", AAZDictType, ".tags") properties = _builder.get(".properties") if properties is not None: + properties.set_prop("actionProperties", AAZDictType, ".action_properties") properties.set_prop("autoMitigate", AAZBoolType, ".auto_mitigate") + properties.set_prop("customProperties", AAZDictType, ".custom_properties") properties.set_prop("description", AAZStrType, ".description") properties.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) properties.set_prop("evaluationFrequency", AAZStrType, ".evaluation_frequency", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("resolveConfiguration", AAZObjectType, ".resolve_configuration") properties.set_prop("scopes", AAZListType, ".scopes", typ_kwargs={"flags": {"required": True}}) properties.set_prop("severity", AAZIntType, ".severity", typ_kwargs={"flags": {"required": True}}) - properties.set_prop("windowSize", AAZStrType, ".window_size", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("windowSize", AAZStrType, ".window_size") + + action_properties = _builder.get(".properties.actionProperties") + if action_properties is not None: + action_properties.set_elements(AAZStrType, ".") + + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_elements(AAZStrType, ".") + + resolve_configuration = _builder.get(".properties.resolveConfiguration") + if resolve_configuration is not None: + resolve_configuration.set_prop("autoResolved", AAZBoolType, ".auto_resolved", typ_kwargs={"flags": {"required": True}}) + resolve_configuration.set_prop("timeToResolve", AAZStrType, ".time_to_resolve") scopes = _builder.get(".properties.scopes") if scopes is not None: @@ -413,6 +474,7 @@ def _build_schema_metric_dimension_update(cls, _builder): def _build_schema_metric_alert_resource_read(cls, _schema): if cls._schema_metric_alert_resource_read is not None: _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity _schema.location = cls._schema_metric_alert_resource_read.location _schema.name = cls._schema_metric_alert_resource_read.name _schema.properties = cls._schema_metric_alert_resource_read.properties @@ -426,6 +488,7 @@ def _build_schema_metric_alert_resource_read(cls, _schema): metric_alert_resource_read.id = AAZStrType( flags={"read_only": True}, ) + metric_alert_resource_read.identity = AAZIdentityObjectType() metric_alert_resource_read.location = AAZStrType( flags={"required": True}, ) @@ -440,7 +503,39 @@ def _build_schema_metric_alert_resource_read(cls, _schema): flags={"read_only": True}, ) + identity = _schema_metric_alert_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_metric_alert_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = _schema_metric_alert_resource_read.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) properties.actions = AAZListType() properties.auto_mitigate = AAZBoolType( serialized_name="autoMitigate", @@ -448,6 +543,9 @@ def _build_schema_metric_alert_resource_read(cls, _schema): properties.criteria = AAZObjectType( flags={"required": True}, ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) properties.description = AAZStrType() properties.enabled = AAZBoolType( flags={"required": True}, @@ -464,6 +562,9 @@ def _build_schema_metric_alert_resource_read(cls, _schema): serialized_name="lastUpdatedTime", flags={"read_only": True}, ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) properties.scopes = AAZListType( flags={"required": True}, ) @@ -478,9 +579,11 @@ def _build_schema_metric_alert_resource_read(cls, _schema): ) properties.window_size = AAZStrType( serialized_name="windowSize", - flags={"required": True}, ) + action_properties = _schema_metric_alert_resource_read.properties.action_properties + action_properties.Element = AAZStrType() + actions = _schema_metric_alert_resource_read.properties.actions actions.Element = AAZObjectType() @@ -570,6 +673,46 @@ def _build_schema_metric_alert_resource_read(cls, _schema): flags={"required": True}, ) + disc_microsoft__azure__monitor__prom_ql_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( serialized_name="allOf", @@ -626,6 +769,18 @@ def _build_schema_metric_alert_resource_read(cls, _schema): flags={"required": True}, ) + custom_properties = _schema_metric_alert_resource_read.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = _schema_metric_alert_resource_read.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + scopes = _schema_metric_alert_resource_read.properties.scopes scopes.Element = AAZStrType() @@ -633,6 +788,7 @@ def _build_schema_metric_alert_resource_read(cls, _schema): tags.Element = AAZStrType() _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity _schema.location = cls._schema_metric_alert_resource_read.location _schema.name = cls._schema_metric_alert_resource_read.name _schema.properties = cls._schema_metric_alert_resource_read.properties diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/__cmd_group.py new file mode 100644 index 00000000000..dc52e2eea46 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor metrics alert identity", +) +class __CMDGroup(AAZCommandGroup): + """Manage Identity + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/__init__.py new file mode 100644 index 00000000000..6e361c3c498 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/__init__.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._assign import * +from ._remove import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_assign.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_assign.py new file mode 100644 index 00000000000..c5587d098a0 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_assign.py @@ -0,0 +1,674 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor metrics alert identity assign", +) +class Assign(AAZCommand): + """Assign the user or system managed identities. + """ + + _aaz_info = { + "version": "2024-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2024-03-01-preview", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the alert rule.", + required=True, + ) + + # define Arg Group "Parameters.identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Parameters.identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Parameters.identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricAlertsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.MetricAlertsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class MetricAlertsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "ruleName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _AssignHelper._build_schema_metric_alert_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class MetricAlertsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "ruleName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _AssignHelper._build_schema_metric_alert_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZIdentityObjectType + ) + _builder.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "assign"}}) + _builder.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "assign"}}) + + user_assigned = _builder.get(".userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + return _instance_value + + +class _AssignHelper: + """Helper class for Assign""" + + _schema_metric_alert_resource_read = None + + @classmethod + def _build_schema_metric_alert_resource_read(cls, _schema): + if cls._schema_metric_alert_resource_read is not None: + _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity + _schema.location = cls._schema_metric_alert_resource_read.location + _schema.name = cls._schema_metric_alert_resource_read.name + _schema.properties = cls._schema_metric_alert_resource_read.properties + _schema.tags = cls._schema_metric_alert_resource_read.tags + _schema.type = cls._schema_metric_alert_resource_read.type + return + + cls._schema_metric_alert_resource_read = _schema_metric_alert_resource_read = AAZObjectType() + + metric_alert_resource_read = _schema_metric_alert_resource_read + metric_alert_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + metric_alert_resource_read.identity = AAZIdentityObjectType() + metric_alert_resource_read.location = AAZStrType( + flags={"required": True}, + ) + metric_alert_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + metric_alert_resource_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + metric_alert_resource_read.tags = AAZDictType() + metric_alert_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_metric_alert_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_metric_alert_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_metric_alert_resource_read.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) + properties.actions = AAZListType() + properties.auto_mitigate = AAZBoolType( + serialized_name="autoMitigate", + ) + properties.criteria = AAZObjectType( + flags={"required": True}, + ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.evaluation_frequency = AAZStrType( + serialized_name="evaluationFrequency", + flags={"required": True}, + ) + properties.is_migrated = AAZBoolType( + serialized_name="isMigrated", + flags={"read_only": True}, + ) + properties.last_updated_time = AAZStrType( + serialized_name="lastUpdatedTime", + flags={"read_only": True}, + ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.severity = AAZIntType( + flags={"required": True}, + ) + properties.target_resource_region = AAZStrType( + serialized_name="targetResourceRegion", + ) + properties.target_resource_type = AAZStrType( + serialized_name="targetResourceType", + ) + properties.window_size = AAZStrType( + serialized_name="windowSize", + ) + + action_properties = _schema_metric_alert_resource_read.properties.action_properties + action_properties.Element = AAZStrType() + + actions = _schema_metric_alert_resource_read.properties.actions + actions.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.actions.Element + _element.action_group_id = AAZStrType( + serialized_name="actionGroupId", + ) + _element.web_hook_properties = AAZDictType( + serialized_name="webHookProperties", + ) + + web_hook_properties = _schema_metric_alert_resource_read.properties.actions.Element.web_hook_properties + web_hook_properties.Element = AAZStrType() + + criteria = _schema_metric_alert_resource_read.properties.criteria + criteria["odata.type"] = AAZStrType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__multiple_resource_multiple_metric_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria") + disc_microsoft__azure__monitor__multiple_resource_multiple_metric_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.dimensions = AAZListType() + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.skip_metric_validation = AAZBoolType( + serialized_name="skipMetricValidation", + ) + _element.time_aggregation = AAZStrType( + serialized_name="timeAggregation", + flags={"required": True}, + ) + + dimensions = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.dimensions + dimensions.Element = AAZObjectType() + cls._build_schema_metric_dimension_read(dimensions.Element) + + disc_dynamic_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion").failing_periods + failing_periods.min_failing_periods_to_alert = AAZFloatType( + serialized_name="minFailingPeriodsToAlert", + flags={"required": True}, + ) + failing_periods.number_of_evaluation_periods = AAZFloatType( + serialized_name="numberOfEvaluationPeriods", + flags={"required": True}, + ) + + disc_static_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "StaticThresholdCriterion") + disc_static_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + disc_static_threshold_criterion.threshold = AAZFloatType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__prom_ql_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.dimensions = AAZListType() + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.operator = AAZStrType( + flags={"required": True}, + ) + _element.skip_metric_validation = AAZBoolType( + serialized_name="skipMetricValidation", + ) + _element.threshold = AAZFloatType( + flags={"required": True}, + ) + _element.time_aggregation = AAZStrType( + serialized_name="timeAggregation", + flags={"required": True}, + ) + + dimensions = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of.Element.dimensions + dimensions.Element = AAZObjectType() + cls._build_schema_metric_dimension_read(dimensions.Element) + + disc_microsoft__azure__monitor__webtest_location_availability_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria") + disc_microsoft__azure__monitor__webtest_location_availability_criteria.component_id = AAZStrType( + serialized_name="componentId", + flags={"required": True}, + ) + disc_microsoft__azure__monitor__webtest_location_availability_criteria.failed_location_count = AAZFloatType( + serialized_name="failedLocationCount", + flags={"required": True}, + ) + disc_microsoft__azure__monitor__webtest_location_availability_criteria.web_test_id = AAZStrType( + serialized_name="webTestId", + flags={"required": True}, + ) + + custom_properties = _schema_metric_alert_resource_read.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = _schema_metric_alert_resource_read.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + + scopes = _schema_metric_alert_resource_read.properties.scopes + scopes.Element = AAZStrType() + + tags = _schema_metric_alert_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity + _schema.location = cls._schema_metric_alert_resource_read.location + _schema.name = cls._schema_metric_alert_resource_read.name + _schema.properties = cls._schema_metric_alert_resource_read.properties + _schema.tags = cls._schema_metric_alert_resource_read.tags + _schema.type = cls._schema_metric_alert_resource_read.type + + _schema_metric_dimension_read = None + + @classmethod + def _build_schema_metric_dimension_read(cls, _schema): + if cls._schema_metric_dimension_read is not None: + _schema.name = cls._schema_metric_dimension_read.name + _schema.operator = cls._schema_metric_dimension_read.operator + _schema.values = cls._schema_metric_dimension_read.values + return + + cls._schema_metric_dimension_read = _schema_metric_dimension_read = AAZObjectType() + + metric_dimension_read = _schema_metric_dimension_read + metric_dimension_read.name = AAZStrType( + flags={"required": True}, + ) + metric_dimension_read.operator = AAZStrType( + flags={"required": True}, + ) + metric_dimension_read.values = AAZListType( + flags={"required": True}, + ) + + values = _schema_metric_dimension_read.values + values.Element = AAZStrType() + + _schema.name = cls._schema_metric_dimension_read.name + _schema.operator = cls._schema_metric_dimension_read.operator + _schema.values = cls._schema_metric_dimension_read.values + + +__all__ = ["Assign"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_remove.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_remove.py new file mode 100644 index 00000000000..30e7da25c88 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_remove.py @@ -0,0 +1,674 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor metrics alert identity remove", +) +class Remove(AAZCommand): + """Remove the user or system managed identities. + """ + + _aaz_info = { + "version": "2024-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2024-03-01-preview", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the alert rule.", + required=True, + ) + + # define Arg Group "Parameters.identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Parameters.identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Parameters.identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricAlertsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.MetricAlertsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class MetricAlertsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "ruleName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _RemoveHelper._build_schema_metric_alert_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class MetricAlertsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "ruleName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _RemoveHelper._build_schema_metric_alert_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZIdentityObjectType + ) + _builder.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "remove"}}) + _builder.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "remove"}}) + + user_assigned = _builder.get(".userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + return _instance_value + + +class _RemoveHelper: + """Helper class for Remove""" + + _schema_metric_alert_resource_read = None + + @classmethod + def _build_schema_metric_alert_resource_read(cls, _schema): + if cls._schema_metric_alert_resource_read is not None: + _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity + _schema.location = cls._schema_metric_alert_resource_read.location + _schema.name = cls._schema_metric_alert_resource_read.name + _schema.properties = cls._schema_metric_alert_resource_read.properties + _schema.tags = cls._schema_metric_alert_resource_read.tags + _schema.type = cls._schema_metric_alert_resource_read.type + return + + cls._schema_metric_alert_resource_read = _schema_metric_alert_resource_read = AAZObjectType() + + metric_alert_resource_read = _schema_metric_alert_resource_read + metric_alert_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + metric_alert_resource_read.identity = AAZIdentityObjectType() + metric_alert_resource_read.location = AAZStrType( + flags={"required": True}, + ) + metric_alert_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + metric_alert_resource_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + metric_alert_resource_read.tags = AAZDictType() + metric_alert_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_metric_alert_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_metric_alert_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_metric_alert_resource_read.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) + properties.actions = AAZListType() + properties.auto_mitigate = AAZBoolType( + serialized_name="autoMitigate", + ) + properties.criteria = AAZObjectType( + flags={"required": True}, + ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.evaluation_frequency = AAZStrType( + serialized_name="evaluationFrequency", + flags={"required": True}, + ) + properties.is_migrated = AAZBoolType( + serialized_name="isMigrated", + flags={"read_only": True}, + ) + properties.last_updated_time = AAZStrType( + serialized_name="lastUpdatedTime", + flags={"read_only": True}, + ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.severity = AAZIntType( + flags={"required": True}, + ) + properties.target_resource_region = AAZStrType( + serialized_name="targetResourceRegion", + ) + properties.target_resource_type = AAZStrType( + serialized_name="targetResourceType", + ) + properties.window_size = AAZStrType( + serialized_name="windowSize", + ) + + action_properties = _schema_metric_alert_resource_read.properties.action_properties + action_properties.Element = AAZStrType() + + actions = _schema_metric_alert_resource_read.properties.actions + actions.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.actions.Element + _element.action_group_id = AAZStrType( + serialized_name="actionGroupId", + ) + _element.web_hook_properties = AAZDictType( + serialized_name="webHookProperties", + ) + + web_hook_properties = _schema_metric_alert_resource_read.properties.actions.Element.web_hook_properties + web_hook_properties.Element = AAZStrType() + + criteria = _schema_metric_alert_resource_read.properties.criteria + criteria["odata.type"] = AAZStrType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__multiple_resource_multiple_metric_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria") + disc_microsoft__azure__monitor__multiple_resource_multiple_metric_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.dimensions = AAZListType() + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.skip_metric_validation = AAZBoolType( + serialized_name="skipMetricValidation", + ) + _element.time_aggregation = AAZStrType( + serialized_name="timeAggregation", + flags={"required": True}, + ) + + dimensions = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.dimensions + dimensions.Element = AAZObjectType() + cls._build_schema_metric_dimension_read(dimensions.Element) + + disc_dynamic_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion").failing_periods + failing_periods.min_failing_periods_to_alert = AAZFloatType( + serialized_name="minFailingPeriodsToAlert", + flags={"required": True}, + ) + failing_periods.number_of_evaluation_periods = AAZFloatType( + serialized_name="numberOfEvaluationPeriods", + flags={"required": True}, + ) + + disc_static_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "StaticThresholdCriterion") + disc_static_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + disc_static_threshold_criterion.threshold = AAZFloatType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__prom_ql_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.dimensions = AAZListType() + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.operator = AAZStrType( + flags={"required": True}, + ) + _element.skip_metric_validation = AAZBoolType( + serialized_name="skipMetricValidation", + ) + _element.threshold = AAZFloatType( + flags={"required": True}, + ) + _element.time_aggregation = AAZStrType( + serialized_name="timeAggregation", + flags={"required": True}, + ) + + dimensions = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of.Element.dimensions + dimensions.Element = AAZObjectType() + cls._build_schema_metric_dimension_read(dimensions.Element) + + disc_microsoft__azure__monitor__webtest_location_availability_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria") + disc_microsoft__azure__monitor__webtest_location_availability_criteria.component_id = AAZStrType( + serialized_name="componentId", + flags={"required": True}, + ) + disc_microsoft__azure__monitor__webtest_location_availability_criteria.failed_location_count = AAZFloatType( + serialized_name="failedLocationCount", + flags={"required": True}, + ) + disc_microsoft__azure__monitor__webtest_location_availability_criteria.web_test_id = AAZStrType( + serialized_name="webTestId", + flags={"required": True}, + ) + + custom_properties = _schema_metric_alert_resource_read.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = _schema_metric_alert_resource_read.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + + scopes = _schema_metric_alert_resource_read.properties.scopes + scopes.Element = AAZStrType() + + tags = _schema_metric_alert_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity + _schema.location = cls._schema_metric_alert_resource_read.location + _schema.name = cls._schema_metric_alert_resource_read.name + _schema.properties = cls._schema_metric_alert_resource_read.properties + _schema.tags = cls._schema_metric_alert_resource_read.tags + _schema.type = cls._schema_metric_alert_resource_read.type + + _schema_metric_dimension_read = None + + @classmethod + def _build_schema_metric_dimension_read(cls, _schema): + if cls._schema_metric_dimension_read is not None: + _schema.name = cls._schema_metric_dimension_read.name + _schema.operator = cls._schema_metric_dimension_read.operator + _schema.values = cls._schema_metric_dimension_read.values + return + + cls._schema_metric_dimension_read = _schema_metric_dimension_read = AAZObjectType() + + metric_dimension_read = _schema_metric_dimension_read + metric_dimension_read.name = AAZStrType( + flags={"required": True}, + ) + metric_dimension_read.operator = AAZStrType( + flags={"required": True}, + ) + metric_dimension_read.values = AAZListType( + flags={"required": True}, + ) + + values = _schema_metric_dimension_read.values + values.Element = AAZStrType() + + _schema.name = cls._schema_metric_dimension_read.name + _schema.operator = cls._schema_metric_dimension_read.operator + _schema.values = cls._schema_metric_dimension_read.values + + +__all__ = ["Remove"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_show.py new file mode 100644 index 00000000000..5d40a5736fd --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/alert/identity/_show.py @@ -0,0 +1,528 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor metrics alert identity show", +) +class Show(AAZCommand): + """Show the details of managed identities. + """ + + _aaz_info = { + "version": "2024-03-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/metricalerts/{}", "2024-03-01-preview", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the alert rule.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricAlertsGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class MetricAlertsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "ruleName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _ShowHelper._build_schema_metric_alert_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_metric_alert_resource_read = None + + @classmethod + def _build_schema_metric_alert_resource_read(cls, _schema): + if cls._schema_metric_alert_resource_read is not None: + _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity + _schema.location = cls._schema_metric_alert_resource_read.location + _schema.name = cls._schema_metric_alert_resource_read.name + _schema.properties = cls._schema_metric_alert_resource_read.properties + _schema.tags = cls._schema_metric_alert_resource_read.tags + _schema.type = cls._schema_metric_alert_resource_read.type + return + + cls._schema_metric_alert_resource_read = _schema_metric_alert_resource_read = AAZObjectType() + + metric_alert_resource_read = _schema_metric_alert_resource_read + metric_alert_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + metric_alert_resource_read.identity = AAZIdentityObjectType() + metric_alert_resource_read.location = AAZStrType( + flags={"required": True}, + ) + metric_alert_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + metric_alert_resource_read.properties = AAZObjectType( + flags={"required": True, "client_flatten": True}, + ) + metric_alert_resource_read.tags = AAZDictType() + metric_alert_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_metric_alert_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_metric_alert_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_metric_alert_resource_read.properties + properties.action_properties = AAZDictType( + serialized_name="actionProperties", + ) + properties.actions = AAZListType() + properties.auto_mitigate = AAZBoolType( + serialized_name="autoMitigate", + ) + properties.criteria = AAZObjectType( + flags={"required": True}, + ) + properties.custom_properties = AAZDictType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.evaluation_frequency = AAZStrType( + serialized_name="evaluationFrequency", + flags={"required": True}, + ) + properties.is_migrated = AAZBoolType( + serialized_name="isMigrated", + flags={"read_only": True}, + ) + properties.last_updated_time = AAZStrType( + serialized_name="lastUpdatedTime", + flags={"read_only": True}, + ) + properties.resolve_configuration = AAZObjectType( + serialized_name="resolveConfiguration", + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.severity = AAZIntType( + flags={"required": True}, + ) + properties.target_resource_region = AAZStrType( + serialized_name="targetResourceRegion", + ) + properties.target_resource_type = AAZStrType( + serialized_name="targetResourceType", + ) + properties.window_size = AAZStrType( + serialized_name="windowSize", + ) + + action_properties = _schema_metric_alert_resource_read.properties.action_properties + action_properties.Element = AAZStrType() + + actions = _schema_metric_alert_resource_read.properties.actions + actions.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.actions.Element + _element.action_group_id = AAZStrType( + serialized_name="actionGroupId", + ) + _element.web_hook_properties = AAZDictType( + serialized_name="webHookProperties", + ) + + web_hook_properties = _schema_metric_alert_resource_read.properties.actions.Element.web_hook_properties + web_hook_properties.Element = AAZStrType() + + criteria = _schema_metric_alert_resource_read.properties.criteria + criteria["odata.type"] = AAZStrType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__multiple_resource_multiple_metric_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria") + disc_microsoft__azure__monitor__multiple_resource_multiple_metric_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.dimensions = AAZListType() + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.skip_metric_validation = AAZBoolType( + serialized_name="skipMetricValidation", + ) + _element.time_aggregation = AAZStrType( + serialized_name="timeAggregation", + flags={"required": True}, + ) + + dimensions = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.dimensions + dimensions.Element = AAZObjectType() + cls._build_schema_metric_dimension_read(dimensions.Element) + + disc_dynamic_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion").failing_periods + failing_periods.min_failing_periods_to_alert = AAZFloatType( + serialized_name="minFailingPeriodsToAlert", + flags={"required": True}, + ) + failing_periods.number_of_evaluation_periods = AAZFloatType( + serialized_name="numberOfEvaluationPeriods", + flags={"required": True}, + ) + + disc_static_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria").all_of.Element.discriminate_by("criterion_type", "StaticThresholdCriterion") + disc_static_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + disc_static_threshold_criterion.threshold = AAZFloatType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__prom_ql_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria") + disc_microsoft__azure__monitor__prom_ql_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + disc_microsoft__azure__monitor__prom_ql_criteria.failing_periods = AAZObjectType( + serialized_name="failingPeriods", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.query = AAZStrType( + flags={"required": True}, + ) + + disc_dynamic_threshold_criterion = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").all_of.Element.discriminate_by("criterion_type", "DynamicThresholdCriterion") + disc_dynamic_threshold_criterion.alert_sensitivity = AAZStrType( + serialized_name="alertSensitivity", + flags={"required": True}, + ) + disc_dynamic_threshold_criterion.ignore_data_before = AAZStrType( + serialized_name="ignoreDataBefore", + ) + disc_dynamic_threshold_criterion.operator = AAZStrType( + flags={"required": True}, + ) + + failing_periods = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.PromQLCriteria").failing_periods + failing_periods["for"] = AAZStrType( + flags={"required": True}, + ) + + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") + disc_microsoft__azure__monitor__single_resource_multiple_metric_criteria.all_of = AAZListType( + serialized_name="allOf", + ) + + all_of = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of + all_of.Element = AAZObjectType() + + _element = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of.Element + _element.criterion_type = AAZStrType( + serialized_name="criterionType", + flags={"required": True}, + ) + _element.dimensions = AAZListType() + _element.metric_name = AAZStrType( + serialized_name="metricName", + flags={"required": True}, + ) + _element.metric_namespace = AAZStrType( + serialized_name="metricNamespace", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.operator = AAZStrType( + flags={"required": True}, + ) + _element.skip_metric_validation = AAZBoolType( + serialized_name="skipMetricValidation", + ) + _element.threshold = AAZFloatType( + flags={"required": True}, + ) + _element.time_aggregation = AAZStrType( + serialized_name="timeAggregation", + flags={"required": True}, + ) + + dimensions = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria").all_of.Element.dimensions + dimensions.Element = AAZObjectType() + cls._build_schema_metric_dimension_read(dimensions.Element) + + disc_microsoft__azure__monitor__webtest_location_availability_criteria = _schema_metric_alert_resource_read.properties.criteria.discriminate_by("odata.type", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria") + disc_microsoft__azure__monitor__webtest_location_availability_criteria.component_id = AAZStrType( + serialized_name="componentId", + flags={"required": True}, + ) + disc_microsoft__azure__monitor__webtest_location_availability_criteria.failed_location_count = AAZFloatType( + serialized_name="failedLocationCount", + flags={"required": True}, + ) + disc_microsoft__azure__monitor__webtest_location_availability_criteria.web_test_id = AAZStrType( + serialized_name="webTestId", + flags={"required": True}, + ) + + custom_properties = _schema_metric_alert_resource_read.properties.custom_properties + custom_properties.Element = AAZStrType() + + resolve_configuration = _schema_metric_alert_resource_read.properties.resolve_configuration + resolve_configuration.auto_resolved = AAZBoolType( + serialized_name="autoResolved", + flags={"required": True}, + ) + resolve_configuration.time_to_resolve = AAZStrType( + serialized_name="timeToResolve", + ) + + scopes = _schema_metric_alert_resource_read.properties.scopes + scopes.Element = AAZStrType() + + tags = _schema_metric_alert_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_metric_alert_resource_read.id + _schema.identity = cls._schema_metric_alert_resource_read.identity + _schema.location = cls._schema_metric_alert_resource_read.location + _schema.name = cls._schema_metric_alert_resource_read.name + _schema.properties = cls._schema_metric_alert_resource_read.properties + _schema.tags = cls._schema_metric_alert_resource_read.tags + _schema.type = cls._schema_metric_alert_resource_read.type + + _schema_metric_dimension_read = None + + @classmethod + def _build_schema_metric_dimension_read(cls, _schema): + if cls._schema_metric_dimension_read is not None: + _schema.name = cls._schema_metric_dimension_read.name + _schema.operator = cls._schema_metric_dimension_read.operator + _schema.values = cls._schema_metric_dimension_read.values + return + + cls._schema_metric_dimension_read = _schema_metric_dimension_read = AAZObjectType() + + metric_dimension_read = _schema_metric_dimension_read + metric_dimension_read.name = AAZStrType( + flags={"required": True}, + ) + metric_dimension_read.operator = AAZStrType( + flags={"required": True}, + ) + metric_dimension_read.values = AAZListType( + flags={"required": True}, + ) + + values = _schema_metric_dimension_read.values + values.Element = AAZStrType() + + _schema.name = cls._schema_metric_dimension_read.name + _schema.operator = cls._schema_metric_dimension_read.operator + _schema.values = cls._schema_metric_dimension_read.values + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/__cmd_group.py new file mode 100644 index 00000000000..15641a94fb4 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor pipeline-group", +) +class __CMDGroup(AAZCommandGroup): + """Manage Pipeline Groups + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/__init__.py new file mode 100644 index 00000000000..db73033039b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_create.py new file mode 100644 index 00000000000..55fa8dbf58f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_create.py @@ -0,0 +1,1160 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor pipeline-group create", +) +class Create(AAZCommand): + """Create a pipeline group instance. + + :example: Create a PipelineGroup instance using UDP receiver + az monitor pipeline-group create --resource-group myResourceGroup --pipeline-group-name plGroup1 --location eastus2 --extended-location "{name:/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/myTestCustomLocation,type:CustomLocation}" --tags "{tag1:A,tag2:B}" --receivers "[{type:UDP,name:udp-receiver1,udp:{endpoint:'0.0.0.0:518',encoding:utf-8}}]" --processors "[]" --exporters "[{type:AzureMonitorWorkspaceLogs,name:my-workspace-logs-exporter1,azure-monitor-workspace-logs:{api:{data-collection-endpoint-url:'https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com',stream:Custom-MyTableRawData_CL,data-collection-rule:dcr-00000000000000000000000000000000,schema:{record-map:[{from:body,to:Body},{from:severity_text,to:SeverityText},{from:time_unix_nano,to:TimeGenerated}]}},concurrency:{worker-count:4,batch-queue-size:100}}}]" --service "{pipelines:[{name:MyPipelineForLogs1,type:logs,receivers:[udp-receiver1],processors:[],exporters:[my-workspace-logs-exporter1]}]}" + """ + + _aaz_info = { + "version": "2023-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/pipelinegroups/{}", "2023-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pipeline_group_name = AAZStrArg( + options=["-n", "--name", "--pipeline-group-name"], + help="The name of pipeline group. The name is case insensitive.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,10}[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.exporters = AAZListArg( + options=["--exporters"], + arg_group="Properties", + help="The exporters specified for a pipeline group instance.", + ) + _args_schema.network_config = AAZListArg( + options=["--network-config"], + arg_group="Properties", + help="Networking configurations for the pipeline group instance.", + ) + _args_schema.processors = AAZListArg( + options=["--processors"], + arg_group="Properties", + help="The processors specified for a pipeline group instance.", + ) + _args_schema.receivers = AAZListArg( + options=["--receivers"], + arg_group="Properties", + help="The receivers specified for a pipeline group instance.", + ) + _args_schema.replicas = AAZIntArg( + options=["--replicas"], + arg_group="Properties", + help="Defines the amount of replicas of the pipeline group instance.", + ) + _args_schema.service = AAZObjectArg( + options=["--service"], + arg_group="Properties", + help="The service section for a given pipeline group instance.", + ) + + exporters = cls._args_schema.exporters + exporters.Element = AAZObjectArg() + + _element = cls._args_schema.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectArg( + options=["azure-monitor-workspace-logs"], + help="Azure Monitor Workspace Logs specific configurations.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of exporter.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.tcp = AAZObjectArg( + options=["tcp"], + help="TCP based exporter. Used for pipelineGroup exporter.", + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of exporter.", + required=True, + enum={"AzureMonitorWorkspaceLogs": "AzureMonitorWorkspaceLogs", "PipelineGroup": "PipelineGroup"}, + ) + + azure_monitor_workspace_logs = cls._args_schema.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectArg( + options=["api"], + help="API configurations for Azure Monitor workspace exporter.", + required=True, + ) + azure_monitor_workspace_logs.cache = AAZObjectArg( + options=["cache"], + help="Cache configurations.", + ) + azure_monitor_workspace_logs.concurrency = AAZObjectArg( + options=["concurrency"], + help="Concurrency configuration for the exporter.", + ) + + api = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrArg( + options=["data-collection-endpoint-url"], + help="Data collection endpoint ingestion url.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(https?)://[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*$", + ), + ) + api.data_collection_rule = AAZStrArg( + options=["data-collection-rule"], + help="Data Collection Rule (DCR) immutable id.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9.-]{1,1000}[^-]$", + ), + ) + api.schema = AAZObjectArg( + options=["schema"], + help="The schema mapping for incoming data.", + required=True, + ) + api.stream = AAZStrArg( + options=["stream"], + help="Stream name in destination. Azure Monitor stream is related to the destination table.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9._-]{1,1000}[^-]$", + ), + ) + + schema = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListArg( + options=["record-map"], + help="Record Map.", + required=True, + ) + schema.resource_map = AAZListArg( + options=["resource-map"], + help="Resource Map captures information about the entity for which telemetry is recorded. For example, metrics exposed by a Kubernetes container can be linked to a resource that specifies the cluster, namespace, pod, and container name.Resource may capture an entire hierarchy of entity identification. It may describe the host in the cloud and specific container or an application running in the process.", + ) + schema.scope_map = AAZListArg( + options=["scope-map"], + help="A scope map is a logical unit of the application code with which the emitted telemetry can be associated.", + ) + + record_map = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectArg() + + _element = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element.from_ = AAZStrArg( + options=["from"], + help="Record Map Key.", + required=True, + ) + _element.to = AAZStrArg( + options=["to"], + help="Record Map Value.", + required=True, + ) + + resource_map = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectArg() + + _element = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element.from_ = AAZStrArg( + options=["from"], + help="Resource Map Key.", + required=True, + ) + _element.to = AAZStrArg( + options=["to"], + help="Resource Map Value.", + required=True, + ) + + scope_map = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectArg() + + _element = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element.from_ = AAZStrArg( + options=["from"], + help="Scope Map Key.", + required=True, + ) + _element.to = AAZStrArg( + options=["to"], + help="Scope Map Value.", + required=True, + ) + + cache = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntArg( + options=["max-storage-usage"], + help="Max storage usage in megabytes.", + ) + cache.retention_period = AAZIntArg( + options=["retention-period"], + help="Retention period in minutes.", + ) + + concurrency = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntArg( + options=["batch-queue-size"], + help="Size of the queue for log batches.", + default=100, + ) + concurrency.worker_count = AAZIntArg( + options=["worker-count"], + help="Number of parallel workers processing the log queues.", + default=4, + ) + + tcp = cls._args_schema.exporters.Element.tcp + tcp.url = AAZStrArg( + options=["url"], + help="TCP url to export.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(https?)://[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*$", + ), + ) + + network_config = cls._args_schema.network_config + network_config.Element = AAZObjectArg() + + _element = cls._args_schema.network_config.Element + _element.external_networking_mode = AAZStrArg( + options=["external-networking-mode"], + help="External networking mode.", + required=True, + enum={"LoadBalancerOnly": "LoadBalancerOnly"}, + ) + _element.host = AAZStrArg( + options=["host"], + help="The address exposed on the cluster. Example: azuremonitorpipeline.contoso.com.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+$", + ), + ) + _element.routes = AAZListArg( + options=["routes"], + help="Networking routes configuration.", + required=True, + ) + + routes = cls._args_schema.network_config.Element.routes + routes.Element = AAZObjectArg() + + _element = cls._args_schema.network_config.Element.routes.Element + _element.path = AAZStrArg( + options=["path"], + help="Route path.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-/\\.]+$", + ), + ) + _element.port = AAZIntArg( + options=["port"], + help="The port that will be configured externally. If not specified, it will use the port from the receiver definition.", + fmt=AAZIntArgFormat( + maximum=65535, + minimum=1, + ), + ) + _element.receiver = AAZStrArg( + options=["receiver"], + help="The name of the previously defined receiver.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.subdomain = AAZStrArg( + options=["subdomain"], + help="Route subdomain.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+$", + ), + ) + + processors = cls._args_schema.processors + processors.Element = AAZObjectArg() + + _element = cls._args_schema.processors.Element + _element.batch = AAZObjectArg( + options=["batch"], + help="Batch processor configurations.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of processor.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of processor.", + required=True, + enum={"Batch": "Batch"}, + ) + + batch = cls._args_schema.processors.Element.batch + batch.batch_size = AAZIntArg( + options=["batch-size"], + help="Size of the batch.", + default=8192, + fmt=AAZIntArgFormat( + maximum=100000, + minimum=10, + ), + ) + batch.timeout = AAZIntArg( + options=["timeout"], + help="Timeout in milliseconds.", + default=200, + fmt=AAZIntArgFormat( + maximum=60000, + minimum=10, + ), + ) + + receivers = cls._args_schema.receivers + receivers.Element = AAZObjectArg() + + _element = cls._args_schema.receivers.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of receiver.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.otlp = AAZObjectArg( + options=["otlp"], + help="OTLP receiver configurations. This field is mandatory for OTLP and pipelineGroup receivers.", + ) + _element.syslog = AAZObjectArg( + options=["syslog"], + help="Syslog configurations. This field is mandatory for syslog type receivers.", + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of receiver.", + required=True, + enum={"Ama": "Ama", "OTLP": "OTLP", "PipelineGroup": "PipelineGroup", "Syslog": "Syslog", "UDP": "UDP"}, + ) + _element.udp = AAZObjectArg( + options=["udp"], + help="UDP receiver configurations. This field is mandatory for UDP receivers.", + ) + + otlp = cls._args_schema.receivers.Element.otlp + otlp.endpoint = AAZStrArg( + options=["endpoint"], + help="OTLP GRPC endpoint definition. Example: 0.0.0.0:.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+:[0-9]+$", + ), + ) + + syslog = cls._args_schema.receivers.Element.syslog + syslog.endpoint = AAZStrArg( + options=["endpoint"], + help="Syslog receiver endpoint definition. Example: 0.0.0.0:.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+:[0-9]+$", + ), + ) + syslog.protocol = AAZStrArg( + options=["protocol"], + help="Protocol to parse syslog messages. Default rfc3164", + default="rfc3164", + enum={"rfc3164": "rfc3164", "rfc5424": "rfc5424"}, + ) + + udp = cls._args_schema.receivers.Element.udp + udp.encoding = AAZStrArg( + options=["encoding"], + help="The encoding of the stream being received.", + default="nop", + enum={"ascii": "ascii", "big5": "big5", "nop": "nop", "utf-16be": "utf-16be", "utf-16le": "utf-16le", "utf-8": "utf-8"}, + ) + udp.endpoint = AAZStrArg( + options=["endpoint"], + help="TCP endpoint definition. Example: 0.0.0.0:.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+:[0-9]+$", + ), + ) + udp.read_queue_length = AAZIntArg( + options=["read-queue-length"], + help="Max read queue length.", + default=1000, + fmt=AAZIntArgFormat( + maximum=100000, + minimum=100, + ), + ) + + service = cls._args_schema.service + service.persistence = AAZObjectArg( + options=["persistence"], + help="Persistence options to all pipelines in the instance.", + ) + service.pipelines = AAZListArg( + options=["pipelines"], + help="Pipelines belonging to a given pipeline group.", + required=True, + ) + + persistence = cls._args_schema.service.persistence + persistence.persistent_volume_name = AAZStrArg( + options=["persistent-volume-name"], + help="The name of the mounted persistent volume.", + required=True, + ) + + pipelines = cls._args_schema.service.pipelines + pipelines.Element = AAZObjectArg() + + _element = cls._args_schema.service.pipelines.Element + _element.exporters = AAZListArg( + options=["exporters"], + help="Reference to exporters configured for the pipeline.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="Name of the pipeline.", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.processors = AAZListArg( + options=["processors"], + help="Reference to processors configured for the pipeline.", + ) + _element.receivers = AAZListArg( + options=["receivers"], + help="Reference to receivers configured for the pipeline.", + required=True, + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of pipeline", + required=True, + enum={"logs": "logs"}, + ) + + exporters = cls._args_schema.service.pipelines.Element.exporters + exporters.Element = AAZStrArg() + + processors = cls._args_schema.service.pipelines.Element.processors + processors.Element = AAZStrArg() + + receivers = cls._args_schema.service.pipelines.Element.receivers + receivers.Element = AAZStrArg() + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.extended_location = AAZObjectArg( + options=["--extended-location"], + arg_group="Resource", + help="The extended location for given pipeline group.", + ) + _args_schema.location = AAZResourceLocationArg( + arg_group="Resource", + help="The geo-location where the resource lives", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + ) + + extended_location = cls._args_schema.extended_location + extended_location.name = AAZStrArg( + options=["name"], + help="The name of the extended location.", + required=True, + ) + extended_location.type = AAZStrArg( + options=["type"], + help="The type of the extended location.", + required=True, + enum={"CustomLocation": "CustomLocation", "EdgeZone": "EdgeZone"}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PipelineGroupsCreateOrUpdate(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 PipelineGroupsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/pipelineGroups/{pipelineGroupName}", + **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( + "pipelineGroupName", self.ctx.args.pipeline_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("extendedLocation", AAZObjectType, ".extended_location") + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + extended_location = _builder.get(".extendedLocation") + if extended_location is not None: + extended_location.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + extended_location.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("exporters", AAZListType, ".exporters", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("networkingConfigurations", AAZListType, ".network_config") + properties.set_prop("processors", AAZListType, ".processors", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("receivers", AAZListType, ".receivers", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("replicas", AAZIntType, ".replicas") + properties.set_prop("service", AAZObjectType, ".service", typ_kwargs={"flags": {"required": True}}) + + exporters = _builder.get(".properties.exporters") + if exporters is not None: + exporters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[]") + if _elements is not None: + _elements.set_prop("azureMonitorWorkspaceLogs", AAZObjectType, ".azure_monitor_workspace_logs") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("tcp", AAZObjectType, ".tcp") + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + azure_monitor_workspace_logs = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs") + if azure_monitor_workspace_logs is not None: + azure_monitor_workspace_logs.set_prop("api", AAZObjectType, ".api", typ_kwargs={"flags": {"required": True}}) + azure_monitor_workspace_logs.set_prop("cache", AAZObjectType, ".cache") + azure_monitor_workspace_logs.set_prop("concurrency", AAZObjectType, ".concurrency") + + api = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api") + if api is not None: + api.set_prop("dataCollectionEndpointUrl", AAZStrType, ".data_collection_endpoint_url", typ_kwargs={"flags": {"required": True}}) + api.set_prop("dataCollectionRule", AAZStrType, ".data_collection_rule", typ_kwargs={"flags": {"required": True}}) + api.set_prop("schema", AAZObjectType, ".schema", typ_kwargs={"flags": {"required": True}}) + api.set_prop("stream", AAZStrType, ".stream", typ_kwargs={"flags": {"required": True}}) + + schema = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema") + if schema is not None: + schema.set_prop("recordMap", AAZListType, ".record_map", typ_kwargs={"flags": {"required": True}}) + schema.set_prop("resourceMap", AAZListType, ".resource_map") + schema.set_prop("scopeMap", AAZListType, ".scope_map") + + record_map = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.recordMap") + if record_map is not None: + record_map.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.recordMap[]") + if _elements is not None: + _elements.set_prop("from", AAZStrType, ".from_", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("to", AAZStrType, ".to", typ_kwargs={"flags": {"required": True}}) + + resource_map = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.resourceMap") + if resource_map is not None: + resource_map.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.resourceMap[]") + if _elements is not None: + _elements.set_prop("from", AAZStrType, ".from_", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("to", AAZStrType, ".to", typ_kwargs={"flags": {"required": True}}) + + scope_map = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.scopeMap") + if scope_map is not None: + scope_map.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.scopeMap[]") + if _elements is not None: + _elements.set_prop("from", AAZStrType, ".from_", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("to", AAZStrType, ".to", typ_kwargs={"flags": {"required": True}}) + + cache = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.cache") + if cache is not None: + cache.set_prop("maxStorageUsage", AAZIntType, ".max_storage_usage") + cache.set_prop("retentionPeriod", AAZIntType, ".retention_period") + + concurrency = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.concurrency") + if concurrency is not None: + concurrency.set_prop("batchQueueSize", AAZIntType, ".batch_queue_size") + concurrency.set_prop("workerCount", AAZIntType, ".worker_count") + + tcp = _builder.get(".properties.exporters[].tcp") + if tcp is not None: + tcp.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) + + networking_configurations = _builder.get(".properties.networkingConfigurations") + if networking_configurations is not None: + networking_configurations.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.networkingConfigurations[]") + if _elements is not None: + _elements.set_prop("externalNetworkingMode", AAZStrType, ".external_networking_mode", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("host", AAZStrType, ".host") + _elements.set_prop("routes", AAZListType, ".routes", typ_kwargs={"flags": {"required": True}}) + + routes = _builder.get(".properties.networkingConfigurations[].routes") + if routes is not None: + routes.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.networkingConfigurations[].routes[]") + if _elements is not None: + _elements.set_prop("path", AAZStrType, ".path") + _elements.set_prop("port", AAZIntType, ".port") + _elements.set_prop("receiver", AAZStrType, ".receiver", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("subdomain", AAZStrType, ".subdomain") + + processors = _builder.get(".properties.processors") + if processors is not None: + processors.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.processors[]") + if _elements is not None: + _elements.set_prop("batch", AAZObjectType, ".batch") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + batch = _builder.get(".properties.processors[].batch") + if batch is not None: + batch.set_prop("batchSize", AAZIntType, ".batch_size") + batch.set_prop("timeout", AAZIntType, ".timeout") + + receivers = _builder.get(".properties.receivers") + if receivers is not None: + receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.receivers[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("otlp", AAZObjectType, ".otlp") + _elements.set_prop("syslog", AAZObjectType, ".syslog") + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("udp", AAZObjectType, ".udp") + + otlp = _builder.get(".properties.receivers[].otlp") + if otlp is not None: + otlp.set_prop("endpoint", AAZStrType, ".endpoint", typ_kwargs={"flags": {"required": True}}) + + syslog = _builder.get(".properties.receivers[].syslog") + if syslog is not None: + syslog.set_prop("endpoint", AAZStrType, ".endpoint", typ_kwargs={"flags": {"required": True}}) + syslog.set_prop("protocol", AAZStrType, ".protocol") + + udp = _builder.get(".properties.receivers[].udp") + if udp is not None: + udp.set_prop("encoding", AAZStrType, ".encoding") + udp.set_prop("endpoint", AAZStrType, ".endpoint", typ_kwargs={"flags": {"required": True}}) + udp.set_prop("readQueueLength", AAZIntType, ".read_queue_length") + + service = _builder.get(".properties.service") + if service is not None: + service.set_prop("persistence", AAZObjectType, ".persistence") + service.set_prop("pipelines", AAZListType, ".pipelines", typ_kwargs={"flags": {"required": True}}) + + persistence = _builder.get(".properties.service.persistence") + if persistence is not None: + persistence.set_prop("persistentVolumeName", AAZStrType, ".persistent_volume_name", typ_kwargs={"flags": {"required": True}}) + + pipelines = _builder.get(".properties.service.pipelines") + if pipelines is not None: + pipelines.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.service.pipelines[]") + if _elements is not None: + _elements.set_prop("exporters", AAZListType, ".exporters", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("processors", AAZListType, ".processors") + _elements.set_prop("receivers", AAZListType, ".receivers", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + exporters = _builder.get(".properties.service.pipelines[].exporters") + if exporters is not None: + exporters.set_elements(AAZStrType, ".") + + processors = _builder.get(".properties.service.pipelines[].processors") + if processors is not None: + processors.set_elements(AAZStrType, ".") + + receivers = _builder.get(".properties.service.pipelines[].receivers") + if receivers is not None: + receivers.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.extended_location = AAZObjectType( + serialized_name="extendedLocation", + ) + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + extended_location = cls._schema_on_200_201.extended_location + extended_location.name = AAZStrType( + flags={"required": True}, + ) + extended_location.type = AAZStrType( + flags={"required": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.exporters = AAZListType( + flags={"required": True}, + ) + properties.networking_configurations = AAZListType( + serialized_name="networkingConfigurations", + ) + properties.processors = AAZListType( + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.receivers = AAZListType( + flags={"required": True}, + ) + properties.replicas = AAZIntType() + properties.service = AAZObjectType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200_201.properties.exporters + exporters.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectType( + serialized_name="azureMonitorWorkspaceLogs", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.tcp = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + + azure_monitor_workspace_logs = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectType( + flags={"required": True}, + ) + azure_monitor_workspace_logs.cache = AAZObjectType() + azure_monitor_workspace_logs.concurrency = AAZObjectType() + + api = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrType( + serialized_name="dataCollectionEndpointUrl", + flags={"required": True}, + ) + api.data_collection_rule = AAZStrType( + serialized_name="dataCollectionRule", + flags={"required": True}, + ) + api.schema = AAZObjectType( + flags={"required": True}, + ) + api.stream = AAZStrType( + flags={"required": True}, + ) + + schema = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListType( + serialized_name="recordMap", + flags={"required": True}, + ) + schema.resource_map = AAZListType( + serialized_name="resourceMap", + ) + schema.scope_map = AAZListType( + serialized_name="scopeMap", + ) + + record_map = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + resource_map = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + scope_map = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + cache = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntType( + serialized_name="maxStorageUsage", + ) + cache.retention_period = AAZIntType( + serialized_name="retentionPeriod", + ) + + concurrency = cls._schema_on_200_201.properties.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntType( + serialized_name="batchQueueSize", + ) + concurrency.worker_count = AAZIntType( + serialized_name="workerCount", + ) + + tcp = cls._schema_on_200_201.properties.exporters.Element.tcp + tcp.url = AAZStrType( + flags={"required": True}, + ) + + networking_configurations = cls._schema_on_200_201.properties.networking_configurations + networking_configurations.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.networking_configurations.Element + _element.external_networking_mode = AAZStrType( + serialized_name="externalNetworkingMode", + flags={"required": True}, + ) + _element.host = AAZStrType() + _element.routes = AAZListType( + flags={"required": True}, + ) + + routes = cls._schema_on_200_201.properties.networking_configurations.Element.routes + routes.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.networking_configurations.Element.routes.Element + _element.path = AAZStrType() + _element.port = AAZIntType() + _element.receiver = AAZStrType( + flags={"required": True}, + ) + _element.subdomain = AAZStrType() + + processors = cls._schema_on_200_201.properties.processors + processors.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.processors.Element + _element.batch = AAZObjectType() + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + batch = cls._schema_on_200_201.properties.processors.Element.batch + batch.batch_size = AAZIntType( + serialized_name="batchSize", + ) + batch.timeout = AAZIntType() + + receivers = cls._schema_on_200_201.properties.receivers + receivers.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.receivers.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.otlp = AAZObjectType() + _element.syslog = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.udp = AAZObjectType() + + otlp = cls._schema_on_200_201.properties.receivers.Element.otlp + otlp.endpoint = AAZStrType( + flags={"required": True}, + ) + + syslog = cls._schema_on_200_201.properties.receivers.Element.syslog + syslog.endpoint = AAZStrType( + flags={"required": True}, + ) + syslog.protocol = AAZStrType() + + udp = cls._schema_on_200_201.properties.receivers.Element.udp + udp.encoding = AAZStrType() + udp.endpoint = AAZStrType( + flags={"required": True}, + ) + udp.read_queue_length = AAZIntType( + serialized_name="readQueueLength", + ) + + service = cls._schema_on_200_201.properties.service + service.persistence = AAZObjectType() + service.pipelines = AAZListType( + flags={"required": True}, + ) + + persistence = cls._schema_on_200_201.properties.service.persistence + persistence.persistent_volume_name = AAZStrType( + serialized_name="persistentVolumeName", + flags={"required": True}, + ) + + pipelines = cls._schema_on_200_201.properties.service.pipelines + pipelines.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.service.pipelines.Element + _element.exporters = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.processors = AAZListType() + _element.receivers = AAZListType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200_201.properties.service.pipelines.Element.exporters + exporters.Element = AAZStrType() + + processors = cls._schema_on_200_201.properties.service.pipelines.Element.processors + processors.Element = AAZStrType() + + receivers = cls._schema_on_200_201.properties.service.pipelines.Element.receivers + receivers.Element = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_delete.py new file mode 100644 index 00000000000..65448eef5c9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_delete.py @@ -0,0 +1,163 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor pipeline-group delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a pipeline group instance. + """ + + _aaz_info = { + "version": "2023-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/pipelinegroups/{}", "2023-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pipeline_group_name = AAZStrArg( + options=["-n", "--name", "--pipeline-group-name"], + help="The name of pipeline group. The name is case insensitive.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,10}[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PipelineGroupsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class PipelineGroupsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/pipelineGroups/{pipelineGroupName}", + **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( + "pipelineGroupName", self.ctx.args.pipeline_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_list.py new file mode 100644 index 00000000000..3344dcfbd5b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_list.py @@ -0,0 +1,845 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor pipeline-group list", +) +class List(AAZCommand): + """List all workspaces in the specified subscription + """ + + _aaz_info = { + "version": "2023-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.monitor/pipelinegroups", "2023-10-01-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/pipelinegroups", "2023-10-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.PipelineGroupsListByResourceGroup(ctx=self.ctx)() + if condition_1: + self.PipelineGroupsListBySubscription(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 PipelineGroupsListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/pipelineGroups", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _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.extended_location = AAZObjectType( + serialized_name="extendedLocation", + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + extended_location = cls._schema_on_200.value.Element.extended_location + extended_location.name = AAZStrType( + flags={"required": True}, + ) + extended_location.type = AAZStrType( + flags={"required": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.exporters = AAZListType( + flags={"required": True}, + ) + properties.networking_configurations = AAZListType( + serialized_name="networkingConfigurations", + ) + properties.processors = AAZListType( + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.receivers = AAZListType( + flags={"required": True}, + ) + properties.replicas = AAZIntType() + properties.service = AAZObjectType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.value.Element.properties.exporters + exporters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectType( + serialized_name="azureMonitorWorkspaceLogs", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.tcp = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + + azure_monitor_workspace_logs = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectType( + flags={"required": True}, + ) + azure_monitor_workspace_logs.cache = AAZObjectType() + azure_monitor_workspace_logs.concurrency = AAZObjectType() + + api = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrType( + serialized_name="dataCollectionEndpointUrl", + flags={"required": True}, + ) + api.data_collection_rule = AAZStrType( + serialized_name="dataCollectionRule", + flags={"required": True}, + ) + api.schema = AAZObjectType( + flags={"required": True}, + ) + api.stream = AAZStrType( + flags={"required": True}, + ) + + schema = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListType( + serialized_name="recordMap", + flags={"required": True}, + ) + schema.resource_map = AAZListType( + serialized_name="resourceMap", + ) + schema.scope_map = AAZListType( + serialized_name="scopeMap", + ) + + record_map = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + resource_map = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + scope_map = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + cache = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntType( + serialized_name="maxStorageUsage", + ) + cache.retention_period = AAZIntType( + serialized_name="retentionPeriod", + ) + + concurrency = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntType( + serialized_name="batchQueueSize", + ) + concurrency.worker_count = AAZIntType( + serialized_name="workerCount", + ) + + tcp = cls._schema_on_200.value.Element.properties.exporters.Element.tcp + tcp.url = AAZStrType( + flags={"required": True}, + ) + + networking_configurations = cls._schema_on_200.value.Element.properties.networking_configurations + networking_configurations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.networking_configurations.Element + _element.external_networking_mode = AAZStrType( + serialized_name="externalNetworkingMode", + flags={"required": True}, + ) + _element.host = AAZStrType() + _element.routes = AAZListType( + flags={"required": True}, + ) + + routes = cls._schema_on_200.value.Element.properties.networking_configurations.Element.routes + routes.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.networking_configurations.Element.routes.Element + _element.path = AAZStrType() + _element.port = AAZIntType() + _element.receiver = AAZStrType( + flags={"required": True}, + ) + _element.subdomain = AAZStrType() + + processors = cls._schema_on_200.value.Element.properties.processors + processors.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.processors.Element + _element.batch = AAZObjectType() + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + batch = cls._schema_on_200.value.Element.properties.processors.Element.batch + batch.batch_size = AAZIntType( + serialized_name="batchSize", + ) + batch.timeout = AAZIntType() + + receivers = cls._schema_on_200.value.Element.properties.receivers + receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.receivers.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.otlp = AAZObjectType() + _element.syslog = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.udp = AAZObjectType() + + otlp = cls._schema_on_200.value.Element.properties.receivers.Element.otlp + otlp.endpoint = AAZStrType( + flags={"required": True}, + ) + + syslog = cls._schema_on_200.value.Element.properties.receivers.Element.syslog + syslog.endpoint = AAZStrType( + flags={"required": True}, + ) + syslog.protocol = AAZStrType() + + udp = cls._schema_on_200.value.Element.properties.receivers.Element.udp + udp.encoding = AAZStrType() + udp.endpoint = AAZStrType( + flags={"required": True}, + ) + udp.read_queue_length = AAZIntType( + serialized_name="readQueueLength", + ) + + service = cls._schema_on_200.value.Element.properties.service + service.persistence = AAZObjectType() + service.pipelines = AAZListType( + flags={"required": True}, + ) + + persistence = cls._schema_on_200.value.Element.properties.service.persistence + persistence.persistent_volume_name = AAZStrType( + serialized_name="persistentVolumeName", + flags={"required": True}, + ) + + pipelines = cls._schema_on_200.value.Element.properties.service.pipelines + pipelines.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.service.pipelines.Element + _element.exporters = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.processors = AAZListType() + _element.receivers = AAZListType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.value.Element.properties.service.pipelines.Element.exporters + exporters.Element = AAZStrType() + + processors = cls._schema_on_200.value.Element.properties.service.pipelines.Element.processors + processors.Element = AAZStrType() + + receivers = cls._schema_on_200.value.Element.properties.service.pipelines.Element.receivers + receivers.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class PipelineGroupsListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/pipelineGroups", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _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.extended_location = AAZObjectType( + serialized_name="extendedLocation", + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + extended_location = cls._schema_on_200.value.Element.extended_location + extended_location.name = AAZStrType( + flags={"required": True}, + ) + extended_location.type = AAZStrType( + flags={"required": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.exporters = AAZListType( + flags={"required": True}, + ) + properties.networking_configurations = AAZListType( + serialized_name="networkingConfigurations", + ) + properties.processors = AAZListType( + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.receivers = AAZListType( + flags={"required": True}, + ) + properties.replicas = AAZIntType() + properties.service = AAZObjectType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.value.Element.properties.exporters + exporters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectType( + serialized_name="azureMonitorWorkspaceLogs", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.tcp = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + + azure_monitor_workspace_logs = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectType( + flags={"required": True}, + ) + azure_monitor_workspace_logs.cache = AAZObjectType() + azure_monitor_workspace_logs.concurrency = AAZObjectType() + + api = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrType( + serialized_name="dataCollectionEndpointUrl", + flags={"required": True}, + ) + api.data_collection_rule = AAZStrType( + serialized_name="dataCollectionRule", + flags={"required": True}, + ) + api.schema = AAZObjectType( + flags={"required": True}, + ) + api.stream = AAZStrType( + flags={"required": True}, + ) + + schema = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListType( + serialized_name="recordMap", + flags={"required": True}, + ) + schema.resource_map = AAZListType( + serialized_name="resourceMap", + ) + schema.scope_map = AAZListType( + serialized_name="scopeMap", + ) + + record_map = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + resource_map = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + scope_map = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + cache = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntType( + serialized_name="maxStorageUsage", + ) + cache.retention_period = AAZIntType( + serialized_name="retentionPeriod", + ) + + concurrency = cls._schema_on_200.value.Element.properties.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntType( + serialized_name="batchQueueSize", + ) + concurrency.worker_count = AAZIntType( + serialized_name="workerCount", + ) + + tcp = cls._schema_on_200.value.Element.properties.exporters.Element.tcp + tcp.url = AAZStrType( + flags={"required": True}, + ) + + networking_configurations = cls._schema_on_200.value.Element.properties.networking_configurations + networking_configurations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.networking_configurations.Element + _element.external_networking_mode = AAZStrType( + serialized_name="externalNetworkingMode", + flags={"required": True}, + ) + _element.host = AAZStrType() + _element.routes = AAZListType( + flags={"required": True}, + ) + + routes = cls._schema_on_200.value.Element.properties.networking_configurations.Element.routes + routes.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.networking_configurations.Element.routes.Element + _element.path = AAZStrType() + _element.port = AAZIntType() + _element.receiver = AAZStrType( + flags={"required": True}, + ) + _element.subdomain = AAZStrType() + + processors = cls._schema_on_200.value.Element.properties.processors + processors.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.processors.Element + _element.batch = AAZObjectType() + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + batch = cls._schema_on_200.value.Element.properties.processors.Element.batch + batch.batch_size = AAZIntType( + serialized_name="batchSize", + ) + batch.timeout = AAZIntType() + + receivers = cls._schema_on_200.value.Element.properties.receivers + receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.receivers.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.otlp = AAZObjectType() + _element.syslog = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.udp = AAZObjectType() + + otlp = cls._schema_on_200.value.Element.properties.receivers.Element.otlp + otlp.endpoint = AAZStrType( + flags={"required": True}, + ) + + syslog = cls._schema_on_200.value.Element.properties.receivers.Element.syslog + syslog.endpoint = AAZStrType( + flags={"required": True}, + ) + syslog.protocol = AAZStrType() + + udp = cls._schema_on_200.value.Element.properties.receivers.Element.udp + udp.encoding = AAZStrType() + udp.endpoint = AAZStrType( + flags={"required": True}, + ) + udp.read_queue_length = AAZIntType( + serialized_name="readQueueLength", + ) + + service = cls._schema_on_200.value.Element.properties.service + service.persistence = AAZObjectType() + service.pipelines = AAZListType( + flags={"required": True}, + ) + + persistence = cls._schema_on_200.value.Element.properties.service.persistence + persistence.persistent_volume_name = AAZStrType( + serialized_name="persistentVolumeName", + flags={"required": True}, + ) + + pipelines = cls._schema_on_200.value.Element.properties.service.pipelines + pipelines.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.service.pipelines.Element + _element.exporters = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.processors = AAZListType() + _element.receivers = AAZListType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.value.Element.properties.service.pipelines.Element.exporters + exporters.Element = AAZStrType() + + processors = cls._schema_on_200.value.Element.properties.service.pipelines.Element.processors + processors.Element = AAZStrType() + + receivers = cls._schema_on_200.value.Element.properties.service.pipelines.Element.receivers + receivers.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_show.py new file mode 100644 index 00000000000..ddf3f5e35e9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_show.py @@ -0,0 +1,459 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor pipeline-group show", +) +class Show(AAZCommand): + """Get the specific pipeline group instance. + """ + + _aaz_info = { + "version": "2023-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/pipelinegroups/{}", "2023-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pipeline_group_name = AAZStrArg( + options=["-n", "--name", "--pipeline-group-name"], + help="The name of pipeline group. The name is case insensitive.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,10}[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PipelineGroupsGet(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 PipelineGroupsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/pipelineGroups/{pipelineGroupName}", + **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( + "pipelineGroupName", self.ctx.args.pipeline_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.extended_location = AAZObjectType( + serialized_name="extendedLocation", + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + extended_location = cls._schema_on_200.extended_location + extended_location.name = AAZStrType( + flags={"required": True}, + ) + extended_location.type = AAZStrType( + flags={"required": True}, + ) + + properties = cls._schema_on_200.properties + properties.exporters = AAZListType( + flags={"required": True}, + ) + properties.networking_configurations = AAZListType( + serialized_name="networkingConfigurations", + ) + properties.processors = AAZListType( + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.receivers = AAZListType( + flags={"required": True}, + ) + properties.replicas = AAZIntType() + properties.service = AAZObjectType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.properties.exporters + exporters.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectType( + serialized_name="azureMonitorWorkspaceLogs", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.tcp = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + + azure_monitor_workspace_logs = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectType( + flags={"required": True}, + ) + azure_monitor_workspace_logs.cache = AAZObjectType() + azure_monitor_workspace_logs.concurrency = AAZObjectType() + + api = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrType( + serialized_name="dataCollectionEndpointUrl", + flags={"required": True}, + ) + api.data_collection_rule = AAZStrType( + serialized_name="dataCollectionRule", + flags={"required": True}, + ) + api.schema = AAZObjectType( + flags={"required": True}, + ) + api.stream = AAZStrType( + flags={"required": True}, + ) + + schema = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListType( + serialized_name="recordMap", + flags={"required": True}, + ) + schema.resource_map = AAZListType( + serialized_name="resourceMap", + ) + schema.scope_map = AAZListType( + serialized_name="scopeMap", + ) + + record_map = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + resource_map = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + scope_map = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + cache = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntType( + serialized_name="maxStorageUsage", + ) + cache.retention_period = AAZIntType( + serialized_name="retentionPeriod", + ) + + concurrency = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntType( + serialized_name="batchQueueSize", + ) + concurrency.worker_count = AAZIntType( + serialized_name="workerCount", + ) + + tcp = cls._schema_on_200.properties.exporters.Element.tcp + tcp.url = AAZStrType( + flags={"required": True}, + ) + + networking_configurations = cls._schema_on_200.properties.networking_configurations + networking_configurations.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.networking_configurations.Element + _element.external_networking_mode = AAZStrType( + serialized_name="externalNetworkingMode", + flags={"required": True}, + ) + _element.host = AAZStrType() + _element.routes = AAZListType( + flags={"required": True}, + ) + + routes = cls._schema_on_200.properties.networking_configurations.Element.routes + routes.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.networking_configurations.Element.routes.Element + _element.path = AAZStrType() + _element.port = AAZIntType() + _element.receiver = AAZStrType( + flags={"required": True}, + ) + _element.subdomain = AAZStrType() + + processors = cls._schema_on_200.properties.processors + processors.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.processors.Element + _element.batch = AAZObjectType() + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + batch = cls._schema_on_200.properties.processors.Element.batch + batch.batch_size = AAZIntType( + serialized_name="batchSize", + ) + batch.timeout = AAZIntType() + + receivers = cls._schema_on_200.properties.receivers + receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.receivers.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.otlp = AAZObjectType() + _element.syslog = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.udp = AAZObjectType() + + otlp = cls._schema_on_200.properties.receivers.Element.otlp + otlp.endpoint = AAZStrType( + flags={"required": True}, + ) + + syslog = cls._schema_on_200.properties.receivers.Element.syslog + syslog.endpoint = AAZStrType( + flags={"required": True}, + ) + syslog.protocol = AAZStrType() + + udp = cls._schema_on_200.properties.receivers.Element.udp + udp.encoding = AAZStrType() + udp.endpoint = AAZStrType( + flags={"required": True}, + ) + udp.read_queue_length = AAZIntType( + serialized_name="readQueueLength", + ) + + service = cls._schema_on_200.properties.service + service.persistence = AAZObjectType() + service.pipelines = AAZListType( + flags={"required": True}, + ) + + persistence = cls._schema_on_200.properties.service.persistence + persistence.persistent_volume_name = AAZStrType( + serialized_name="persistentVolumeName", + flags={"required": True}, + ) + + pipelines = cls._schema_on_200.properties.service.pipelines + pipelines.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.service.pipelines.Element + _element.exporters = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.processors = AAZListType() + _element.receivers = AAZListType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.properties.service.pipelines.Element.exporters + exporters.Element = AAZStrType() + + processors = cls._schema_on_200.properties.service.pipelines.Element.processors + processors.Element = AAZStrType() + + receivers = cls._schema_on_200.properties.service.pipelines.Element.receivers + receivers.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_update.py new file mode 100644 index 00000000000..eb92a3a18af --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_update.py @@ -0,0 +1,1290 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor pipeline-group update", +) +class Update(AAZCommand): + """Update a pipeline group instance. + + :example: Update a pipeline-group instance + az monitor pipeline-group update --resource-group myResourceGroup --pipeline-group-name plGroup1 --receivers "[{type:UDP,name:udp-receiver1,udp:{endpoint:'0.0.0.0:518',encoding:utf-8}}]" --processors "[]" --exporters "[{type:AzureMonitorWorkspaceLogs,name:my-workspace-logs-exporter1,azure-monitor-workspace-logs:{api:{data-collection-endpoint-url:'https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com',stream:Custom-MyTableRawData_CL,data-collection-rule:dcr-00000000000000000000000000000000,schema:{record-map:[{from:body,to:Body},{from:severity_text,to:SeverityText},{from:time_unix_nano,to:TimeGenerated}]}},concurrency:{worker-count:4,batch-queue-size:100}}}]" --service "{pipelines:[{name:MyPipelineForLogs1,type:logs,receivers:[udp-receiver1],processors:[],exporters:[my-workspace-logs-exporter1]}]}" + """ + + _aaz_info = { + "version": "2023-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/pipelinegroups/{}", "2023-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pipeline_group_name = AAZStrArg( + options=["-n", "--name", "--pipeline-group-name"], + help="The name of pipeline group. The name is case insensitive.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,10}[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.exporters = AAZListArg( + options=["--exporters"], + arg_group="Properties", + help="The exporters specified for a pipeline group instance.", + ) + _args_schema.network_config = AAZListArg( + options=["--network-config"], + arg_group="Properties", + help="Networking configurations for the pipeline group instance.", + nullable=True, + ) + _args_schema.processors = AAZListArg( + options=["--processors"], + arg_group="Properties", + help="The processors specified for a pipeline group instance.", + ) + _args_schema.receivers = AAZListArg( + options=["--receivers"], + arg_group="Properties", + help="The receivers specified for a pipeline group instance.", + ) + _args_schema.replicas = AAZIntArg( + options=["--replicas"], + arg_group="Properties", + help="Defines the amount of replicas of the pipeline group instance.", + nullable=True, + ) + _args_schema.service = AAZObjectArg( + options=["--service"], + arg_group="Properties", + help="The service section for a given pipeline group instance.", + ) + + exporters = cls._args_schema.exporters + exporters.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectArg( + options=["azure-monitor-workspace-logs"], + help="Azure Monitor Workspace Logs specific configurations.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of exporter.", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.tcp = AAZObjectArg( + options=["tcp"], + help="TCP based exporter. Used for pipelineGroup exporter.", + nullable=True, + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of exporter.", + enum={"AzureMonitorWorkspaceLogs": "AzureMonitorWorkspaceLogs", "PipelineGroup": "PipelineGroup"}, + ) + + azure_monitor_workspace_logs = cls._args_schema.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectArg( + options=["api"], + help="API configurations for Azure Monitor workspace exporter.", + ) + azure_monitor_workspace_logs.cache = AAZObjectArg( + options=["cache"], + help="Cache configurations.", + nullable=True, + ) + azure_monitor_workspace_logs.concurrency = AAZObjectArg( + options=["concurrency"], + help="Concurrency configuration for the exporter.", + nullable=True, + ) + + api = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrArg( + options=["data-collection-endpoint-url"], + help="Data collection endpoint ingestion url.", + fmt=AAZStrArgFormat( + pattern="^(https?)://[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*$", + ), + ) + api.data_collection_rule = AAZStrArg( + options=["data-collection-rule"], + help="Data Collection Rule (DCR) immutable id.", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9.-]{1,1000}[^-]$", + ), + ) + api.schema = AAZObjectArg( + options=["schema"], + help="The schema mapping for incoming data.", + ) + api.stream = AAZStrArg( + options=["stream"], + help="Stream name in destination. Azure Monitor stream is related to the destination table.", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9._-]{1,1000}[^-]$", + ), + ) + + schema = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListArg( + options=["record-map"], + help="Record Map.", + ) + schema.resource_map = AAZListArg( + options=["resource-map"], + help="Resource Map captures information about the entity for which telemetry is recorded. For example, metrics exposed by a Kubernetes container can be linked to a resource that specifies the cluster, namespace, pod, and container name.Resource may capture an entire hierarchy of entity identification. It may describe the host in the cloud and specific container or an application running in the process.", + nullable=True, + ) + schema.scope_map = AAZListArg( + options=["scope-map"], + help="A scope map is a logical unit of the application code with which the emitted telemetry can be associated.", + nullable=True, + ) + + record_map = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element.from_ = AAZStrArg( + options=["from"], + help="Record Map Key.", + ) + _element.to = AAZStrArg( + options=["to"], + help="Record Map Value.", + ) + + resource_map = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element.from_ = AAZStrArg( + options=["from"], + help="Resource Map Key.", + ) + _element.to = AAZStrArg( + options=["to"], + help="Resource Map Value.", + ) + + scope_map = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element.from_ = AAZStrArg( + options=["from"], + help="Scope Map Key.", + ) + _element.to = AAZStrArg( + options=["to"], + help="Scope Map Value.", + ) + + cache = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntArg( + options=["max-storage-usage"], + help="Max storage usage in megabytes.", + nullable=True, + ) + cache.retention_period = AAZIntArg( + options=["retention-period"], + help="Retention period in minutes.", + nullable=True, + ) + + concurrency = cls._args_schema.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntArg( + options=["batch-queue-size"], + help="Size of the queue for log batches.", + nullable=True, + ) + concurrency.worker_count = AAZIntArg( + options=["worker-count"], + help="Number of parallel workers processing the log queues.", + nullable=True, + ) + + tcp = cls._args_schema.exporters.Element.tcp + tcp.url = AAZStrArg( + options=["url"], + help="TCP url to export.", + fmt=AAZStrArgFormat( + pattern="^(https?)://[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*$", + ), + ) + + network_config = cls._args_schema.network_config + network_config.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.network_config.Element + _element.external_networking_mode = AAZStrArg( + options=["external-networking-mode"], + help="External networking mode.", + enum={"LoadBalancerOnly": "LoadBalancerOnly"}, + ) + _element.host = AAZStrArg( + options=["host"], + help="The address exposed on the cluster. Example: azuremonitorpipeline.contoso.com.", + nullable=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+$", + ), + ) + _element.routes = AAZListArg( + options=["routes"], + help="Networking routes configuration.", + ) + + routes = cls._args_schema.network_config.Element.routes + routes.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.network_config.Element.routes.Element + _element.path = AAZStrArg( + options=["path"], + help="Route path.", + nullable=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-/\\.]+$", + ), + ) + _element.port = AAZIntArg( + options=["port"], + help="The port that will be configured externally. If not specified, it will use the port from the receiver definition.", + nullable=True, + fmt=AAZIntArgFormat( + maximum=65535, + minimum=1, + ), + ) + _element.receiver = AAZStrArg( + options=["receiver"], + help="The name of the previously defined receiver.", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.subdomain = AAZStrArg( + options=["subdomain"], + help="Route subdomain.", + nullable=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+$", + ), + ) + + processors = cls._args_schema.processors + processors.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.processors.Element + _element.batch = AAZObjectArg( + options=["batch"], + help="Batch processor configurations.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of processor.", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of processor.", + enum={"Batch": "Batch"}, + ) + + batch = cls._args_schema.processors.Element.batch + batch.batch_size = AAZIntArg( + options=["batch-size"], + help="Size of the batch.", + nullable=True, + fmt=AAZIntArgFormat( + maximum=100000, + minimum=10, + ), + ) + batch.timeout = AAZIntArg( + options=["timeout"], + help="Timeout in milliseconds.", + nullable=True, + fmt=AAZIntArgFormat( + maximum=60000, + minimum=10, + ), + ) + + receivers = cls._args_schema.receivers + receivers.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.receivers.Element + _element.name = AAZStrArg( + options=["name"], + help="The name of receiver.", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.otlp = AAZObjectArg( + options=["otlp"], + help="OTLP receiver configurations. This field is mandatory for OTLP and pipelineGroup receivers.", + nullable=True, + ) + _element.syslog = AAZObjectArg( + options=["syslog"], + help="Syslog configurations. This field is mandatory for syslog type receivers.", + nullable=True, + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of receiver.", + enum={"Ama": "Ama", "OTLP": "OTLP", "PipelineGroup": "PipelineGroup", "Syslog": "Syslog", "UDP": "UDP"}, + ) + _element.udp = AAZObjectArg( + options=["udp"], + help="UDP receiver configurations. This field is mandatory for UDP receivers.", + nullable=True, + ) + + otlp = cls._args_schema.receivers.Element.otlp + otlp.endpoint = AAZStrArg( + options=["endpoint"], + help="OTLP GRPC endpoint definition. Example: 0.0.0.0:.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+:[0-9]+$", + ), + ) + + syslog = cls._args_schema.receivers.Element.syslog + syslog.endpoint = AAZStrArg( + options=["endpoint"], + help="Syslog receiver endpoint definition. Example: 0.0.0.0:.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+:[0-9]+$", + ), + ) + syslog.protocol = AAZStrArg( + options=["protocol"], + help="Protocol to parse syslog messages. Default rfc3164", + nullable=True, + enum={"rfc3164": "rfc3164", "rfc5424": "rfc5424"}, + ) + + udp = cls._args_schema.receivers.Element.udp + udp.encoding = AAZStrArg( + options=["encoding"], + help="The encoding of the stream being received.", + nullable=True, + enum={"ascii": "ascii", "big5": "big5", "nop": "nop", "utf-16be": "utf-16be", "utf-16le": "utf-16le", "utf-8": "utf-8"}, + ) + udp.endpoint = AAZStrArg( + options=["endpoint"], + help="TCP endpoint definition. Example: 0.0.0.0:.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-\\.]+:[0-9]+$", + ), + ) + udp.read_queue_length = AAZIntArg( + options=["read-queue-length"], + help="Max read queue length.", + nullable=True, + fmt=AAZIntArgFormat( + maximum=100000, + minimum=100, + ), + ) + + service = cls._args_schema.service + service.persistence = AAZObjectArg( + options=["persistence"], + help="Persistence options to all pipelines in the instance.", + nullable=True, + ) + service.pipelines = AAZListArg( + options=["pipelines"], + help="Pipelines belonging to a given pipeline group.", + ) + + persistence = cls._args_schema.service.persistence + persistence.persistent_volume_name = AAZStrArg( + options=["persistent-volume-name"], + help="The name of the mounted persistent volume.", + ) + + pipelines = cls._args_schema.service.pipelines + pipelines.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.service.pipelines.Element + _element.exporters = AAZListArg( + options=["exporters"], + help="Reference to exporters configured for the pipeline.", + ) + _element.name = AAZStrArg( + options=["name"], + help="Name of the pipeline.", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,32}[^-]$", + ), + ) + _element.processors = AAZListArg( + options=["processors"], + help="Reference to processors configured for the pipeline.", + nullable=True, + ) + _element.receivers = AAZListArg( + options=["receivers"], + help="Reference to receivers configured for the pipeline.", + ) + _element.type = AAZStrArg( + options=["type"], + help="The type of pipeline", + enum={"logs": "logs"}, + ) + + exporters = cls._args_schema.service.pipelines.Element.exporters + exporters.Element = AAZStrArg( + nullable=True, + ) + + processors = cls._args_schema.service.pipelines.Element.processors + processors.Element = AAZStrArg( + nullable=True, + ) + + receivers = cls._args_schema.service.pipelines.Element.receivers + receivers.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PipelineGroupsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.PipelineGroupsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PipelineGroupsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/pipelineGroups/{pipelineGroupName}", + **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( + "pipelineGroupName", self.ctx.args.pipeline_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_pipeline_group_read(cls._schema_on_200) + + return cls._schema_on_200 + + class PipelineGroupsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/pipelineGroups/{pipelineGroupName}", + **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( + "pipelineGroupName", self.ctx.args.pipeline_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_pipeline_group_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("exporters", AAZListType, ".exporters", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("networkingConfigurations", AAZListType, ".network_config") + properties.set_prop("processors", AAZListType, ".processors", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("receivers", AAZListType, ".receivers", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("replicas", AAZIntType, ".replicas") + properties.set_prop("service", AAZObjectType, ".service", typ_kwargs={"flags": {"required": True}}) + + exporters = _builder.get(".properties.exporters") + if exporters is not None: + exporters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[]") + if _elements is not None: + _elements.set_prop("azureMonitorWorkspaceLogs", AAZObjectType, ".azure_monitor_workspace_logs") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("tcp", AAZObjectType, ".tcp") + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + azure_monitor_workspace_logs = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs") + if azure_monitor_workspace_logs is not None: + azure_monitor_workspace_logs.set_prop("api", AAZObjectType, ".api", typ_kwargs={"flags": {"required": True}}) + azure_monitor_workspace_logs.set_prop("cache", AAZObjectType, ".cache") + azure_monitor_workspace_logs.set_prop("concurrency", AAZObjectType, ".concurrency") + + api = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api") + if api is not None: + api.set_prop("dataCollectionEndpointUrl", AAZStrType, ".data_collection_endpoint_url", typ_kwargs={"flags": {"required": True}}) + api.set_prop("dataCollectionRule", AAZStrType, ".data_collection_rule", typ_kwargs={"flags": {"required": True}}) + api.set_prop("schema", AAZObjectType, ".schema", typ_kwargs={"flags": {"required": True}}) + api.set_prop("stream", AAZStrType, ".stream", typ_kwargs={"flags": {"required": True}}) + + schema = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema") + if schema is not None: + schema.set_prop("recordMap", AAZListType, ".record_map", typ_kwargs={"flags": {"required": True}}) + schema.set_prop("resourceMap", AAZListType, ".resource_map") + schema.set_prop("scopeMap", AAZListType, ".scope_map") + + record_map = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.recordMap") + if record_map is not None: + record_map.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.recordMap[]") + if _elements is not None: + _elements.set_prop("from", AAZStrType, ".from_", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("to", AAZStrType, ".to", typ_kwargs={"flags": {"required": True}}) + + resource_map = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.resourceMap") + if resource_map is not None: + resource_map.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.resourceMap[]") + if _elements is not None: + _elements.set_prop("from", AAZStrType, ".from_", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("to", AAZStrType, ".to", typ_kwargs={"flags": {"required": True}}) + + scope_map = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.scopeMap") + if scope_map is not None: + scope_map.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.api.schema.scopeMap[]") + if _elements is not None: + _elements.set_prop("from", AAZStrType, ".from_", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("to", AAZStrType, ".to", typ_kwargs={"flags": {"required": True}}) + + cache = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.cache") + if cache is not None: + cache.set_prop("maxStorageUsage", AAZIntType, ".max_storage_usage") + cache.set_prop("retentionPeriod", AAZIntType, ".retention_period") + + concurrency = _builder.get(".properties.exporters[].azureMonitorWorkspaceLogs.concurrency") + if concurrency is not None: + concurrency.set_prop("batchQueueSize", AAZIntType, ".batch_queue_size") + concurrency.set_prop("workerCount", AAZIntType, ".worker_count") + + tcp = _builder.get(".properties.exporters[].tcp") + if tcp is not None: + tcp.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) + + networking_configurations = _builder.get(".properties.networkingConfigurations") + if networking_configurations is not None: + networking_configurations.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.networkingConfigurations[]") + if _elements is not None: + _elements.set_prop("externalNetworkingMode", AAZStrType, ".external_networking_mode", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("host", AAZStrType, ".host") + _elements.set_prop("routes", AAZListType, ".routes", typ_kwargs={"flags": {"required": True}}) + + routes = _builder.get(".properties.networkingConfigurations[].routes") + if routes is not None: + routes.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.networkingConfigurations[].routes[]") + if _elements is not None: + _elements.set_prop("path", AAZStrType, ".path") + _elements.set_prop("port", AAZIntType, ".port") + _elements.set_prop("receiver", AAZStrType, ".receiver", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("subdomain", AAZStrType, ".subdomain") + + processors = _builder.get(".properties.processors") + if processors is not None: + processors.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.processors[]") + if _elements is not None: + _elements.set_prop("batch", AAZObjectType, ".batch") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + batch = _builder.get(".properties.processors[].batch") + if batch is not None: + batch.set_prop("batchSize", AAZIntType, ".batch_size") + batch.set_prop("timeout", AAZIntType, ".timeout") + + receivers = _builder.get(".properties.receivers") + if receivers is not None: + receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.receivers[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("otlp", AAZObjectType, ".otlp") + _elements.set_prop("syslog", AAZObjectType, ".syslog") + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("udp", AAZObjectType, ".udp") + + otlp = _builder.get(".properties.receivers[].otlp") + if otlp is not None: + otlp.set_prop("endpoint", AAZStrType, ".endpoint", typ_kwargs={"flags": {"required": True}}) + + syslog = _builder.get(".properties.receivers[].syslog") + if syslog is not None: + syslog.set_prop("endpoint", AAZStrType, ".endpoint", typ_kwargs={"flags": {"required": True}}) + syslog.set_prop("protocol", AAZStrType, ".protocol") + + udp = _builder.get(".properties.receivers[].udp") + if udp is not None: + udp.set_prop("encoding", AAZStrType, ".encoding") + udp.set_prop("endpoint", AAZStrType, ".endpoint", typ_kwargs={"flags": {"required": True}}) + udp.set_prop("readQueueLength", AAZIntType, ".read_queue_length") + + service = _builder.get(".properties.service") + if service is not None: + service.set_prop("persistence", AAZObjectType, ".persistence") + service.set_prop("pipelines", AAZListType, ".pipelines", typ_kwargs={"flags": {"required": True}}) + + persistence = _builder.get(".properties.service.persistence") + if persistence is not None: + persistence.set_prop("persistentVolumeName", AAZStrType, ".persistent_volume_name", typ_kwargs={"flags": {"required": True}}) + + pipelines = _builder.get(".properties.service.pipelines") + if pipelines is not None: + pipelines.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.service.pipelines[]") + if _elements is not None: + _elements.set_prop("exporters", AAZListType, ".exporters", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("processors", AAZListType, ".processors") + _elements.set_prop("receivers", AAZListType, ".receivers", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + exporters = _builder.get(".properties.service.pipelines[].exporters") + if exporters is not None: + exporters.set_elements(AAZStrType, ".") + + processors = _builder.get(".properties.service.pipelines[].processors") + if processors is not None: + processors.set_elements(AAZStrType, ".") + + receivers = _builder.get(".properties.service.pipelines[].receivers") + if receivers is not None: + receivers.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_pipeline_group_read = None + + @classmethod + def _build_schema_pipeline_group_read(cls, _schema): + if cls._schema_pipeline_group_read is not None: + _schema.extended_location = cls._schema_pipeline_group_read.extended_location + _schema.id = cls._schema_pipeline_group_read.id + _schema.location = cls._schema_pipeline_group_read.location + _schema.name = cls._schema_pipeline_group_read.name + _schema.properties = cls._schema_pipeline_group_read.properties + _schema.system_data = cls._schema_pipeline_group_read.system_data + _schema.tags = cls._schema_pipeline_group_read.tags + _schema.type = cls._schema_pipeline_group_read.type + return + + cls._schema_pipeline_group_read = _schema_pipeline_group_read = AAZObjectType() + + pipeline_group_read = _schema_pipeline_group_read + pipeline_group_read.extended_location = AAZObjectType( + serialized_name="extendedLocation", + ) + pipeline_group_read.id = AAZStrType( + flags={"read_only": True}, + ) + pipeline_group_read.location = AAZStrType( + flags={"required": True}, + ) + pipeline_group_read.name = AAZStrType( + flags={"read_only": True}, + ) + pipeline_group_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + pipeline_group_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + pipeline_group_read.tags = AAZDictType() + pipeline_group_read.type = AAZStrType( + flags={"read_only": True}, + ) + + extended_location = _schema_pipeline_group_read.extended_location + extended_location.name = AAZStrType( + flags={"required": True}, + ) + extended_location.type = AAZStrType( + flags={"required": True}, + ) + + properties = _schema_pipeline_group_read.properties + properties.exporters = AAZListType( + flags={"required": True}, + ) + properties.networking_configurations = AAZListType( + serialized_name="networkingConfigurations", + ) + properties.processors = AAZListType( + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.receivers = AAZListType( + flags={"required": True}, + ) + properties.replicas = AAZIntType() + properties.service = AAZObjectType( + flags={"required": True}, + ) + + exporters = _schema_pipeline_group_read.properties.exporters + exporters.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectType( + serialized_name="azureMonitorWorkspaceLogs", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.tcp = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + + azure_monitor_workspace_logs = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectType( + flags={"required": True}, + ) + azure_monitor_workspace_logs.cache = AAZObjectType() + azure_monitor_workspace_logs.concurrency = AAZObjectType() + + api = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrType( + serialized_name="dataCollectionEndpointUrl", + flags={"required": True}, + ) + api.data_collection_rule = AAZStrType( + serialized_name="dataCollectionRule", + flags={"required": True}, + ) + api.schema = AAZObjectType( + flags={"required": True}, + ) + api.stream = AAZStrType( + flags={"required": True}, + ) + + schema = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListType( + serialized_name="recordMap", + flags={"required": True}, + ) + schema.resource_map = AAZListType( + serialized_name="resourceMap", + ) + schema.scope_map = AAZListType( + serialized_name="scopeMap", + ) + + record_map = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + resource_map = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + scope_map = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + cache = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntType( + serialized_name="maxStorageUsage", + ) + cache.retention_period = AAZIntType( + serialized_name="retentionPeriod", + ) + + concurrency = _schema_pipeline_group_read.properties.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntType( + serialized_name="batchQueueSize", + ) + concurrency.worker_count = AAZIntType( + serialized_name="workerCount", + ) + + tcp = _schema_pipeline_group_read.properties.exporters.Element.tcp + tcp.url = AAZStrType( + flags={"required": True}, + ) + + networking_configurations = _schema_pipeline_group_read.properties.networking_configurations + networking_configurations.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.networking_configurations.Element + _element.external_networking_mode = AAZStrType( + serialized_name="externalNetworkingMode", + flags={"required": True}, + ) + _element.host = AAZStrType() + _element.routes = AAZListType( + flags={"required": True}, + ) + + routes = _schema_pipeline_group_read.properties.networking_configurations.Element.routes + routes.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.networking_configurations.Element.routes.Element + _element.path = AAZStrType() + _element.port = AAZIntType() + _element.receiver = AAZStrType( + flags={"required": True}, + ) + _element.subdomain = AAZStrType() + + processors = _schema_pipeline_group_read.properties.processors + processors.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.processors.Element + _element.batch = AAZObjectType() + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + batch = _schema_pipeline_group_read.properties.processors.Element.batch + batch.batch_size = AAZIntType( + serialized_name="batchSize", + ) + batch.timeout = AAZIntType() + + receivers = _schema_pipeline_group_read.properties.receivers + receivers.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.receivers.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.otlp = AAZObjectType() + _element.syslog = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.udp = AAZObjectType() + + otlp = _schema_pipeline_group_read.properties.receivers.Element.otlp + otlp.endpoint = AAZStrType( + flags={"required": True}, + ) + + syslog = _schema_pipeline_group_read.properties.receivers.Element.syslog + syslog.endpoint = AAZStrType( + flags={"required": True}, + ) + syslog.protocol = AAZStrType() + + udp = _schema_pipeline_group_read.properties.receivers.Element.udp + udp.encoding = AAZStrType() + udp.endpoint = AAZStrType( + flags={"required": True}, + ) + udp.read_queue_length = AAZIntType( + serialized_name="readQueueLength", + ) + + service = _schema_pipeline_group_read.properties.service + service.persistence = AAZObjectType() + service.pipelines = AAZListType( + flags={"required": True}, + ) + + persistence = _schema_pipeline_group_read.properties.service.persistence + persistence.persistent_volume_name = AAZStrType( + serialized_name="persistentVolumeName", + flags={"required": True}, + ) + + pipelines = _schema_pipeline_group_read.properties.service.pipelines + pipelines.Element = AAZObjectType() + + _element = _schema_pipeline_group_read.properties.service.pipelines.Element + _element.exporters = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.processors = AAZListType() + _element.receivers = AAZListType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + exporters = _schema_pipeline_group_read.properties.service.pipelines.Element.exporters + exporters.Element = AAZStrType() + + processors = _schema_pipeline_group_read.properties.service.pipelines.Element.processors + processors.Element = AAZStrType() + + receivers = _schema_pipeline_group_read.properties.service.pipelines.Element.receivers + receivers.Element = AAZStrType() + + system_data = _schema_pipeline_group_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_pipeline_group_read.tags + tags.Element = AAZStrType() + + _schema.extended_location = cls._schema_pipeline_group_read.extended_location + _schema.id = cls._schema_pipeline_group_read.id + _schema.location = cls._schema_pipeline_group_read.location + _schema.name = cls._schema_pipeline_group_read.name + _schema.properties = cls._schema_pipeline_group_read.properties + _schema.system_data = cls._schema_pipeline_group_read.system_data + _schema.tags = cls._schema_pipeline_group_read.tags + _schema.type = cls._schema_pipeline_group_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_wait.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_wait.py new file mode 100644 index 00000000000..603c64fe9da --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/pipeline_group/_wait.py @@ -0,0 +1,458 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor pipeline-group wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/pipelinegroups/{}", "2023-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pipeline_group_name = AAZStrArg( + options=["-n", "--name", "--pipeline-group-name"], + help="The name of pipeline group. The name is case insensitive.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]{3,10}[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PipelineGroupsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class PipelineGroupsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/pipelineGroups/{pipelineGroupName}", + **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( + "pipelineGroupName", self.ctx.args.pipeline_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.extended_location = AAZObjectType( + serialized_name="extendedLocation", + ) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + extended_location = cls._schema_on_200.extended_location + extended_location.name = AAZStrType( + flags={"required": True}, + ) + extended_location.type = AAZStrType( + flags={"required": True}, + ) + + properties = cls._schema_on_200.properties + properties.exporters = AAZListType( + flags={"required": True}, + ) + properties.networking_configurations = AAZListType( + serialized_name="networkingConfigurations", + ) + properties.processors = AAZListType( + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.receivers = AAZListType( + flags={"required": True}, + ) + properties.replicas = AAZIntType() + properties.service = AAZObjectType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.properties.exporters + exporters.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element + _element.azure_monitor_workspace_logs = AAZObjectType( + serialized_name="azureMonitorWorkspaceLogs", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.tcp = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + + azure_monitor_workspace_logs = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs + azure_monitor_workspace_logs.api = AAZObjectType( + flags={"required": True}, + ) + azure_monitor_workspace_logs.cache = AAZObjectType() + azure_monitor_workspace_logs.concurrency = AAZObjectType() + + api = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api + api.data_collection_endpoint_url = AAZStrType( + serialized_name="dataCollectionEndpointUrl", + flags={"required": True}, + ) + api.data_collection_rule = AAZStrType( + serialized_name="dataCollectionRule", + flags={"required": True}, + ) + api.schema = AAZObjectType( + flags={"required": True}, + ) + api.stream = AAZStrType( + flags={"required": True}, + ) + + schema = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema + schema.record_map = AAZListType( + serialized_name="recordMap", + flags={"required": True}, + ) + schema.resource_map = AAZListType( + serialized_name="resourceMap", + ) + schema.scope_map = AAZListType( + serialized_name="scopeMap", + ) + + record_map = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map + record_map.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.record_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + resource_map = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map + resource_map.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.resource_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + scope_map = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map + scope_map.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.api.schema.scope_map.Element + _element["from"] = AAZStrType( + flags={"required": True}, + ) + _element.to = AAZStrType( + flags={"required": True}, + ) + + cache = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.cache + cache.max_storage_usage = AAZIntType( + serialized_name="maxStorageUsage", + ) + cache.retention_period = AAZIntType( + serialized_name="retentionPeriod", + ) + + concurrency = cls._schema_on_200.properties.exporters.Element.azure_monitor_workspace_logs.concurrency + concurrency.batch_queue_size = AAZIntType( + serialized_name="batchQueueSize", + ) + concurrency.worker_count = AAZIntType( + serialized_name="workerCount", + ) + + tcp = cls._schema_on_200.properties.exporters.Element.tcp + tcp.url = AAZStrType( + flags={"required": True}, + ) + + networking_configurations = cls._schema_on_200.properties.networking_configurations + networking_configurations.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.networking_configurations.Element + _element.external_networking_mode = AAZStrType( + serialized_name="externalNetworkingMode", + flags={"required": True}, + ) + _element.host = AAZStrType() + _element.routes = AAZListType( + flags={"required": True}, + ) + + routes = cls._schema_on_200.properties.networking_configurations.Element.routes + routes.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.networking_configurations.Element.routes.Element + _element.path = AAZStrType() + _element.port = AAZIntType() + _element.receiver = AAZStrType( + flags={"required": True}, + ) + _element.subdomain = AAZStrType() + + processors = cls._schema_on_200.properties.processors + processors.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.processors.Element + _element.batch = AAZObjectType() + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + batch = cls._schema_on_200.properties.processors.Element.batch + batch.batch_size = AAZIntType( + serialized_name="batchSize", + ) + batch.timeout = AAZIntType() + + receivers = cls._schema_on_200.properties.receivers + receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.receivers.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.otlp = AAZObjectType() + _element.syslog = AAZObjectType() + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.udp = AAZObjectType() + + otlp = cls._schema_on_200.properties.receivers.Element.otlp + otlp.endpoint = AAZStrType( + flags={"required": True}, + ) + + syslog = cls._schema_on_200.properties.receivers.Element.syslog + syslog.endpoint = AAZStrType( + flags={"required": True}, + ) + syslog.protocol = AAZStrType() + + udp = cls._schema_on_200.properties.receivers.Element.udp + udp.encoding = AAZStrType() + udp.endpoint = AAZStrType( + flags={"required": True}, + ) + udp.read_queue_length = AAZIntType( + serialized_name="readQueueLength", + ) + + service = cls._schema_on_200.properties.service + service.persistence = AAZObjectType() + service.pipelines = AAZListType( + flags={"required": True}, + ) + + persistence = cls._schema_on_200.properties.service.persistence + persistence.persistent_volume_name = AAZStrType( + serialized_name="persistentVolumeName", + flags={"required": True}, + ) + + pipelines = cls._schema_on_200.properties.service.pipelines + pipelines.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.service.pipelines.Element + _element.exporters = AAZListType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.processors = AAZListType() + _element.receivers = AAZListType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + exporters = cls._schema_on_200.properties.service.pipelines.Element.exporters + exporters.Element = AAZStrType() + + processors = cls._schema_on_200.properties.service.pipelines.Element.processors + processors.Element = AAZStrType() + + receivers = cls._schema_on_200.properties.service.pipelines.Element.receivers + receivers.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/_list.py index 85dcd80efd8..3b5f400d876 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/_list.py @@ -16,10 +16,10 @@ is_preview=True, ) class List(AAZCommand): - """List all monitor private link scope resources. + """List all monitor private link scope resource. :example: List all monitor private link scope resources. - az monitor private-link-scope list --name MyAzureMonitorPrivateLinkScope + az monitor private-link-scope list -g MyResourceGroup """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/private_endpoint_connection/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/private_endpoint_connection/__init__.py index f32b66e3eeb..db73033039b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/private_endpoint_connection/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/private_endpoint_connection/__init__.py @@ -9,6 +9,7 @@ # flake8: noqa from .__cmd_group import * +from ._create import * from ._delete import * from ._list import * from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/private_endpoint_connection/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/private_endpoint_connection/_create.py new file mode 100644 index 00000000000..8da48819543 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/private_endpoint_connection/_create.py @@ -0,0 +1,286 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor private-link-scope private-endpoint-connection create", + is_preview=True, +) +class Create(AAZCommand): + """Create a private endpoint connection with a given name. + """ + + _aaz_info = { + "version": "2019-10-17-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/privatelinkscopes/{}/privateendpointconnections/{}", "2019-10-17-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.private_endpoint_connection_name = AAZStrArg( + options=["-n", "--name", "--private-endpoint-connection-name"], + help="The name of the private endpoint connection.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.scope_name = AAZStrArg( + options=["--scope-name"], + help="The name of the Azure Monitor PrivateLinkScope resource.", + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.private_endpoint = AAZObjectArg( + options=["--private-endpoint"], + arg_group="Properties", + help="Private endpoint which the connection belongs to.", + ) + _args_schema.private_link_service_connection_state = AAZObjectArg( + options=["--private-link-service-connection-state"], + arg_group="Properties", + help="Connection state of the private endpoint connection.", + ) + + private_endpoint = cls._args_schema.private_endpoint + private_endpoint.id = AAZStrArg( + options=["id"], + help="Resource id of the private endpoint.", + ) + + private_link_service_connection_state = cls._args_schema.private_link_service_connection_state + private_link_service_connection_state.description = AAZStrArg( + options=["description"], + help="The private link service connection description.", + required=True, + ) + private_link_service_connection_state.status = AAZStrArg( + options=["status"], + help="The private link service connection status.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PrivateEndpointConnectionsCreateOrUpdate(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 PrivateEndpointConnectionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + **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( + "privateEndpointConnectionName", self.ctx.args.private_endpoint_connection_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "scopeName", self.ctx.args.scope_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-17-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("privateEndpoint", AAZObjectType, ".private_endpoint") + properties.set_prop("privateLinkServiceConnectionState", AAZObjectType, ".private_link_service_connection_state") + + private_endpoint = _builder.get(".properties.privateEndpoint") + if private_endpoint is not None: + private_endpoint.set_prop("id", AAZStrType, ".id") + + private_link_service_connection_state = _builder.get(".properties.privateLinkServiceConnectionState") + if private_link_service_connection_state is not None: + private_link_service_connection_state.set_prop("description", AAZStrType, ".description", typ_kwargs={"flags": {"required": True}}) + private_link_service_connection_state.set_prop("status", AAZStrType, ".status", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + private_endpoint = cls._schema_on_200.properties.private_endpoint + private_endpoint.id = AAZStrType() + + private_link_service_connection_state = cls._schema_on_200.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + flags={"read_only": True}, + ) + private_link_service_connection_state.description = AAZStrType( + flags={"required": True}, + ) + private_link_service_connection_state.status = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/scoped_resource/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/scoped_resource/__init__.py index 2d1a2078686..db73033039b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/scoped_resource/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/scoped_resource/__init__.py @@ -13,4 +13,5 @@ from ._delete import * from ._list import * from ._show import * +from ._update import * from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/scoped_resource/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/scoped_resource/_update.py new file mode 100644 index 00000000000..140457f2fb6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/private_link_scope/scoped_resource/_update.py @@ -0,0 +1,375 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor private-link-scope scoped-resource update", + is_preview=True, +) +class Update(AAZCommand): + """Update a private endpoint connection with a given name. + """ + + _aaz_info = { + "version": "2019-10-17-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.insights/privatelinkscopes/{}/scopedresources/{}", "2019-10-17-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the assigned resource.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.scope_name = AAZStrArg( + options=["--scope-name"], + help="Name of the Azure Monitor Private Link Scope.", + required=True, + id_part="name", + ) + _args_schema.linked_resource = AAZStrArg( + options=["--linked-resource"], + help="ARM resource ID of the linked resource. It should be one of log analytics workspace or application insights component.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PrivateLinkScopedResourcesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.PrivateLinkScopedResourcesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PrivateLinkScopedResourcesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + **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( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "scopeName", self.ctx.args.scope_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-17-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_scoped_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class PrivateLinkScopedResourcesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + **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( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "scopeName", self.ctx.args.scope_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2019-10-17-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_scoped_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("linkedResourceId", AAZStrType, ".linked_resource") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_scoped_resource_read = None + + @classmethod + def _build_schema_scoped_resource_read(cls, _schema): + if cls._schema_scoped_resource_read is not None: + _schema.id = cls._schema_scoped_resource_read.id + _schema.name = cls._schema_scoped_resource_read.name + _schema.properties = cls._schema_scoped_resource_read.properties + _schema.type = cls._schema_scoped_resource_read.type + return + + cls._schema_scoped_resource_read = _schema_scoped_resource_read = AAZObjectType() + + scoped_resource_read = _schema_scoped_resource_read + scoped_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + scoped_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + scoped_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + scoped_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_scoped_resource_read.properties + properties.linked_resource_id = AAZStrType( + serialized_name="linkedResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + _schema.id = cls._schema_scoped_resource_read.id + _schema.name = cls._schema_scoped_resource_read.name + _schema.properties = cls._schema_scoped_resource_read.properties + _schema.type = cls._schema_scoped_resource_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/__cmd_group.py new file mode 100644 index 00000000000..97cad0d5700 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor tenant-action-group", +) +class __CMDGroup(AAZCommandGroup): + """monitor tenant-action-group + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/__init__.py new file mode 100644 index 00000000000..5df4edd53b0 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._create_notification import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_create.py new file mode 100644 index 00000000000..a5045b89699 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_create.py @@ -0,0 +1,556 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor tenant-action-group create", +) +class Create(AAZCommand): + """Create a new tenant action group or update an existing one. + """ + + _aaz_info = { + "version": "2023-05-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/managementgroups/{}/providers/microsoft.insights/tenantactiongroups/{}", "2023-05-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.x_ms_client_tenant_id = AAZStrArg( + options=["--x-ms-client-tenant-id"], + help="The tenant ID of the client making the request.", + required=True, + ) + _args_schema.management_group_id = AAZStrArg( + options=["--management-group-id"], + help="The management group id.", + required=True, + ) + _args_schema.tenant_action_group_name = AAZStrArg( + options=["--tenant-action-group-name"], + help="The name of the action group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z][A-Za-z0-9]*$", + max_length=260, + min_length=1, + ), + ) + _args_schema.group_short_name = AAZStrArg( + options=["--short-name", "--group-short-name"], + help="The short name of the action group. This will be used in SMS messages.", + fmt=AAZStrArgFormat( + max_length=12, + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Space-separated tags: key[=value] [key[=value] ...]. Use '' to clear existing tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "ActionGroup" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="ActionGroup", + help="Resource location", + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.azure_app_push_receivers = AAZListArg( + options=["--azure-app-push-receivers"], + arg_group="Properties", + help="The list of AzureAppPush receivers that are part of this tenant action group.", + ) + _args_schema.email_receivers = AAZListArg( + options=["--email-receivers"], + arg_group="Properties", + help="The list of email receivers that are part of this tenant action group.", + ) + _args_schema.enabled_tenant = AAZBoolArg( + options=["--enabled-tenant"], + arg_group="Properties", + help="Indicates whether this tenant action group is enabled. If a tenant action group is not enabled, then none of its receivers will receive communications.", + default=True, + ) + _args_schema.sms_receivers = AAZListArg( + options=["--sms-receivers"], + arg_group="Properties", + help="The list of SMS receivers that are part of this tenant action group.", + ) + _args_schema.voice_receivers = AAZListArg( + options=["--voice-receivers"], + arg_group="Properties", + help="The list of voice receivers that are part of this tenant action group.", + ) + _args_schema.webhook_receivers = AAZListArg( + options=["--webhook-receivers"], + arg_group="Properties", + help="The list of webhook receivers that are part of this tenant action group.", + ) + + azure_app_push_receivers = cls._args_schema.azure_app_push_receivers + azure_app_push_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.azure_app_push_receivers.Element + _element.email_address = AAZStrArg( + options=["email-address"], + help="The email address registered for the Azure mobile app.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the Azure mobile app push receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + + email_receivers = cls._args_schema.email_receivers + email_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.email_receivers.Element + _element.email_address = AAZStrArg( + options=["email-address"], + help="The email address of this receiver.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the email receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.use_common_alert_schema = AAZBoolArg( + options=["use-common-alert-schema"], + help="Indicates whether to use common alert schema.", + default=False, + ) + + sms_receivers = cls._args_schema.sms_receivers + sms_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.sms_receivers.Element + _element.country_code = AAZStrArg( + options=["country-code"], + help="The country code of the SMS receiver.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the SMS receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.phone_number = AAZStrArg( + options=["phone-number"], + help="The phone number of the SMS receiver.", + required=True, + ) + + voice_receivers = cls._args_schema.voice_receivers + voice_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.voice_receivers.Element + _element.country_code = AAZStrArg( + options=["country-code"], + help="The country code of the voice receiver.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the voice receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.phone_number = AAZStrArg( + options=["phone-number"], + help="The phone number of the voice receiver.", + required=True, + ) + + webhook_receivers = cls._args_schema.webhook_receivers + webhook_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.webhook_receivers.Element + _element.identifier_uri = AAZStrArg( + options=["identifier-uri"], + help="Indicates the identifier uri for aad auth.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the webhook receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.object_id = AAZStrArg( + options=["object-id"], + help="Indicates the webhook app object Id for aad auth.", + ) + _element.service_uri = AAZStrArg( + options=["service-uri"], + help="The URI where webhooks should be sent.", + required=True, + ) + _element.tenant_id = AAZStrArg( + options=["tenant-id"], + help="Indicates the tenant id for aad auth.", + ) + _element.use_aad_auth = AAZBoolArg( + options=["use-aad-auth"], + help="Indicates whether or not use AAD authentication.", + default=False, + ) + _element.use_common_alert_schema = AAZBoolArg( + options=["use-common-alert-schema"], + help="Indicates whether to use common alert schema.", + default=False, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TenantActionGroupsCreateOrUpdate(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 TenantActionGroupsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + **self.serialize_url_param( + "tenantActionGroupName", self.ctx.args.tenant_action_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + required=True, + ), + **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("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("azureAppPushReceivers", AAZListType, ".azure_app_push_receivers") + properties.set_prop("emailReceivers", AAZListType, ".email_receivers") + properties.set_prop("enabled", AAZBoolType, ".enabled_tenant", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("groupShortName", AAZStrType, ".group_short_name", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("smsReceivers", AAZListType, ".sms_receivers") + properties.set_prop("voiceReceivers", AAZListType, ".voice_receivers") + properties.set_prop("webhookReceivers", AAZListType, ".webhook_receivers") + + azure_app_push_receivers = _builder.get(".properties.azureAppPushReceivers") + if azure_app_push_receivers is not None: + azure_app_push_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.azureAppPushReceivers[]") + if _elements is not None: + _elements.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + + email_receivers = _builder.get(".properties.emailReceivers") + if email_receivers is not None: + email_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.emailReceivers[]") + if _elements is not None: + _elements.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("useCommonAlertSchema", AAZBoolType, ".use_common_alert_schema") + + sms_receivers = _builder.get(".properties.smsReceivers") + if sms_receivers is not None: + sms_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.smsReceivers[]") + if _elements is not None: + _elements.set_prop("countryCode", AAZStrType, ".country_code", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("phoneNumber", AAZStrType, ".phone_number", typ_kwargs={"flags": {"required": True}}) + + voice_receivers = _builder.get(".properties.voiceReceivers") + if voice_receivers is not None: + voice_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.voiceReceivers[]") + if _elements is not None: + _elements.set_prop("countryCode", AAZStrType, ".country_code", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("phoneNumber", AAZStrType, ".phone_number", typ_kwargs={"flags": {"required": True}}) + + webhook_receivers = _builder.get(".properties.webhookReceivers") + if webhook_receivers is not None: + webhook_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.webhookReceivers[]") + if _elements is not None: + _elements.set_prop("identifierUri", AAZStrType, ".identifier_uri") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("objectId", AAZStrType, ".object_id") + _elements.set_prop("serviceUri", AAZStrType, ".service_uri", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("tenantId", AAZStrType, ".tenant_id") + _elements.set_prop("useAadAuth", AAZBoolType, ".use_aad_auth") + _elements.set_prop("useCommonAlertSchema", AAZBoolType, ".use_common_alert_schema") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.azure_app_push_receivers = AAZListType( + serialized_name="azureAppPushReceivers", + ) + properties.email_receivers = AAZListType( + serialized_name="emailReceivers", + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.group_short_name = AAZStrType( + serialized_name="groupShortName", + flags={"required": True}, + ) + properties.sms_receivers = AAZListType( + serialized_name="smsReceivers", + ) + properties.voice_receivers = AAZListType( + serialized_name="voiceReceivers", + ) + properties.webhook_receivers = AAZListType( + serialized_name="webhookReceivers", + ) + + azure_app_push_receivers = cls._schema_on_200_201.properties.azure_app_push_receivers + azure_app_push_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.azure_app_push_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + + email_receivers = cls._schema_on_200_201.properties.email_receivers + email_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.email_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.status = AAZStrType() + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + sms_receivers = cls._schema_on_200_201.properties.sms_receivers + sms_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.sms_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + _element.status = AAZStrType() + + voice_receivers = cls._schema_on_200_201.properties.voice_receivers + voice_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.voice_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + + webhook_receivers = cls._schema_on_200_201.properties.webhook_receivers + webhook_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.webhook_receivers.Element + _element.identifier_uri = AAZStrType( + serialized_name="identifierUri", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.service_uri = AAZStrType( + serialized_name="serviceUri", + flags={"required": True}, + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.use_aad_auth = AAZBoolType( + serialized_name="useAadAuth", + ) + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_create_notification.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_create_notification.py new file mode 100644 index 00000000000..52088fd5965 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_create_notification.py @@ -0,0 +1,449 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor tenant-action-group create-notification", +) +class CreateNotification(AAZCommand): + """Send test notifications to a set of provided receivers + """ + + _aaz_info = { + "version": "2023-05-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/managementgroups/{}/providers/microsoft.insights/tenantactiongroups/{}/createnotifications", "2023-05-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.x_ms_client_tenant_id = AAZStrArg( + options=["--x-ms-client-tenant-id"], + help="The tenant ID of the client making the request.", + required=True, + ) + _args_schema.management_group_id = AAZStrArg( + options=["--management-group-id"], + help="The management group id.", + required=True, + ) + _args_schema.tenant_action_group_name = AAZStrArg( + options=["--tenant-action-group-name"], + help="The name of the action group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z][A-Za-z0-9]*$", + max_length=260, + min_length=1, + ), + ) + + # define Arg Group "NotificationRequest" + + _args_schema = cls._args_schema + _args_schema.alert_type = AAZStrArg( + options=["--alert-type"], + arg_group="NotificationRequest", + help="The value of the supported alert type. Supported alert type value is: servicehealth", + required=True, + fmt=AAZStrArgFormat( + max_length=30, + ), + ) + _args_schema.azure_app_push_receivers = AAZListArg( + options=["--azure-app-push-receivers"], + arg_group="NotificationRequest", + help="The list of AzureAppPush receivers that are part of this action group.", + ) + _args_schema.email_receivers = AAZListArg( + options=["--email-receivers"], + arg_group="NotificationRequest", + help="The list of email receivers that are part of this action group.", + ) + _args_schema.sms_receivers = AAZListArg( + options=["--sms-receivers"], + arg_group="NotificationRequest", + help="The list of SMS receivers that are part of this action group.", + ) + _args_schema.voice_receivers = AAZListArg( + options=["--voice-receivers"], + arg_group="NotificationRequest", + help="The list of voice receivers that are part of this action group.", + ) + _args_schema.webhook_receivers = AAZListArg( + options=["--webhook-receivers"], + arg_group="NotificationRequest", + help="The list of webhook receivers that are part of this action group.", + ) + + azure_app_push_receivers = cls._args_schema.azure_app_push_receivers + azure_app_push_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.azure_app_push_receivers.Element + _element.email_address = AAZStrArg( + options=["email-address"], + help="The email address registered for the Azure mobile app.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the Azure mobile app push receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + + email_receivers = cls._args_schema.email_receivers + email_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.email_receivers.Element + _element.email_address = AAZStrArg( + options=["email-address"], + help="The email address of this receiver.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the email receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.use_common_alert_schema = AAZBoolArg( + options=["use-common-alert-schema"], + help="Indicates whether to use common alert schema.", + default=False, + ) + + sms_receivers = cls._args_schema.sms_receivers + sms_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.sms_receivers.Element + _element.country_code = AAZStrArg( + options=["country-code"], + help="The country code of the SMS receiver.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the SMS receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.phone_number = AAZStrArg( + options=["phone-number"], + help="The phone number of the SMS receiver.", + required=True, + ) + + voice_receivers = cls._args_schema.voice_receivers + voice_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.voice_receivers.Element + _element.country_code = AAZStrArg( + options=["country-code"], + help="The country code of the voice receiver.", + required=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the voice receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.phone_number = AAZStrArg( + options=["phone-number"], + help="The phone number of the voice receiver.", + required=True, + ) + + webhook_receivers = cls._args_schema.webhook_receivers + webhook_receivers.Element = AAZObjectArg() + + _element = cls._args_schema.webhook_receivers.Element + _element.identifier_uri = AAZStrArg( + options=["identifier-uri"], + help="Indicates the identifier uri for aad auth.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the webhook receiver. Names must be unique across all receivers within a tenant action group.", + required=True, + ) + _element.object_id = AAZStrArg( + options=["object-id"], + help="Indicates the webhook app object Id for aad auth.", + ) + _element.service_uri = AAZStrArg( + options=["service-uri"], + help="The URI where webhooks should be sent.", + required=True, + ) + _element.tenant_id = AAZStrArg( + options=["tenant-id"], + help="Indicates the tenant id for aad auth.", + ) + _element.use_aad_auth = AAZBoolArg( + options=["use-aad-auth"], + help="Indicates whether or not use AAD authentication.", + default=False, + ) + _element.use_common_alert_schema = AAZBoolArg( + options=["use-common-alert-schema"], + help="Indicates whether to use common alert schema.", + default=False, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.CreateNotificationsAtTenantActionGroupResourceLevel(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 CreateNotificationsAtTenantActionGroupResourceLevel(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}/createNotifications", + **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( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + **self.serialize_url_param( + "tenantActionGroupName", self.ctx.args.tenant_action_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + required=True, + ), + **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("alertType", AAZStrType, ".alert_type", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("azureAppPushReceivers", AAZListType, ".azure_app_push_receivers") + _builder.set_prop("emailReceivers", AAZListType, ".email_receivers") + _builder.set_prop("smsReceivers", AAZListType, ".sms_receivers") + _builder.set_prop("voiceReceivers", AAZListType, ".voice_receivers") + _builder.set_prop("webhookReceivers", AAZListType, ".webhook_receivers") + + azure_app_push_receivers = _builder.get(".azureAppPushReceivers") + if azure_app_push_receivers is not None: + azure_app_push_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".azureAppPushReceivers[]") + if _elements is not None: + _elements.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + + email_receivers = _builder.get(".emailReceivers") + if email_receivers is not None: + email_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".emailReceivers[]") + if _elements is not None: + _elements.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("useCommonAlertSchema", AAZBoolType, ".use_common_alert_schema") + + sms_receivers = _builder.get(".smsReceivers") + if sms_receivers is not None: + sms_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".smsReceivers[]") + if _elements is not None: + _elements.set_prop("countryCode", AAZStrType, ".country_code", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("phoneNumber", AAZStrType, ".phone_number", typ_kwargs={"flags": {"required": True}}) + + voice_receivers = _builder.get(".voiceReceivers") + if voice_receivers is not None: + voice_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".voiceReceivers[]") + if _elements is not None: + _elements.set_prop("countryCode", AAZStrType, ".country_code", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("phoneNumber", AAZStrType, ".phone_number", typ_kwargs={"flags": {"required": True}}) + + webhook_receivers = _builder.get(".webhookReceivers") + if webhook_receivers is not None: + webhook_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".webhookReceivers[]") + if _elements is not None: + _elements.set_prop("identifierUri", AAZStrType, ".identifier_uri") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("objectId", AAZStrType, ".object_id") + _elements.set_prop("serviceUri", AAZStrType, ".service_uri", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("tenantId", AAZStrType, ".tenant_id") + _elements.set_prop("useAadAuth", AAZBoolType, ".use_aad_auth") + _elements.set_prop("useCommonAlertSchema", AAZBoolType, ".use_common_alert_schema") + + 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.action_details = AAZListType( + serialized_name="actionDetails", + ) + _schema_on_200.completed_time = AAZStrType( + serialized_name="completedTime", + ) + _schema_on_200.context = AAZObjectType() + _schema_on_200.created_time = AAZStrType( + serialized_name="createdTime", + ) + _schema_on_200.state = AAZStrType( + flags={"required": True}, + ) + + action_details = cls._schema_on_200.action_details + action_details.Element = AAZObjectType() + + _element = cls._schema_on_200.action_details.Element + _element.mechanism_type = AAZStrType( + serialized_name="mechanismType", + ) + _element.message = AAZStrType() + _element.name = AAZStrType() + _element.send_time = AAZStrType( + serialized_name="sendTime", + ) + _element.status = AAZStrType() + _element.sub_state = AAZStrType( + serialized_name="subState", + ) + + context = cls._schema_on_200.context + context.context_type = AAZStrType( + serialized_name="contextType", + ) + context.notification_source = AAZStrType( + serialized_name="notificationSource", + ) + + return cls._schema_on_200 + + +class _CreateNotificationHelper: + """Helper class for CreateNotification""" + + +__all__ = ["CreateNotification"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_delete.py new file mode 100644 index 00000000000..00093612d92 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_delete.py @@ -0,0 +1,153 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor tenant-action-group delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a tenant action group. + """ + + _aaz_info = { + "version": "2023-05-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/managementgroups/{}/providers/microsoft.insights/tenantactiongroups/{}", "2023-05-01-preview"], + ] + } + + 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.x_ms_client_tenant_id = AAZStrArg( + options=["--x-ms-client-tenant-id"], + help="The tenant ID of the client making the request.", + required=True, + ) + _args_schema.management_group_id = AAZStrArg( + options=["--management-group-id"], + help="The management group id.", + required=True, + ) + _args_schema.tenant_action_group_name = AAZStrArg( + options=["--tenant-action-group-name"], + help="The name of the action group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z][A-Za-z0-9]*$", + max_length=260, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TenantActionGroupsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class TenantActionGroupsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + **self.serialize_url_param( + "tenantActionGroupName", self.ctx.args.tenant_action_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_list.py new file mode 100644 index 00000000000..64f879e0b73 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_list.py @@ -0,0 +1,298 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor tenant-action-group list", +) +class List(AAZCommand): + """List a list of all tenant action groups in a management group. + """ + + _aaz_info = { + "version": "2023-05-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/managementgroups/{}/providers/microsoft.insights/tenantactiongroups", "2023-05-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.x_ms_client_tenant_id = AAZStrArg( + options=["--x-ms-client-tenant-id"], + help="The tenant ID of the client making the request.", + required=True, + ) + _args_schema.management_group_id = AAZStrArg( + options=["--management-group-id"], + help="The management group id.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TenantActionGroupsListByManagementGroupId(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) + return result + + class TenantActionGroupsListByManagementGroupId(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + required=True, + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.azure_app_push_receivers = AAZListType( + serialized_name="azureAppPushReceivers", + ) + properties.email_receivers = AAZListType( + serialized_name="emailReceivers", + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.group_short_name = AAZStrType( + serialized_name="groupShortName", + flags={"required": True}, + ) + properties.sms_receivers = AAZListType( + serialized_name="smsReceivers", + ) + properties.voice_receivers = AAZListType( + serialized_name="voiceReceivers", + ) + properties.webhook_receivers = AAZListType( + serialized_name="webhookReceivers", + ) + + azure_app_push_receivers = cls._schema_on_200.value.Element.properties.azure_app_push_receivers + azure_app_push_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.azure_app_push_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + + email_receivers = cls._schema_on_200.value.Element.properties.email_receivers + email_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.email_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.status = AAZStrType() + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + sms_receivers = cls._schema_on_200.value.Element.properties.sms_receivers + sms_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.sms_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + _element.status = AAZStrType() + + voice_receivers = cls._schema_on_200.value.Element.properties.voice_receivers + voice_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.voice_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + + webhook_receivers = cls._schema_on_200.value.Element.properties.webhook_receivers + webhook_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.webhook_receivers.Element + _element.identifier_uri = AAZStrType( + serialized_name="identifierUri", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.service_uri = AAZStrType( + serialized_name="serviceUri", + flags={"required": True}, + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.use_aad_auth = AAZBoolType( + serialized_name="useAadAuth", + ) + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_show.py new file mode 100644 index 00000000000..c4616472b73 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_show.py @@ -0,0 +1,303 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor tenant-action-group show", +) +class Show(AAZCommand): + """Get a tenant action group. + """ + + _aaz_info = { + "version": "2023-05-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/managementgroups/{}/providers/microsoft.insights/tenantactiongroups/{}", "2023-05-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.x_ms_client_tenant_id = AAZStrArg( + options=["--x-ms-client-tenant-id"], + help="The tenant ID of the client making the request.", + required=True, + ) + _args_schema.management_group_id = AAZStrArg( + options=["--management-group-id"], + help="The management group id.", + required=True, + ) + _args_schema.tenant_action_group_name = AAZStrArg( + options=["--tenant-action-group-name"], + help="The name of the action group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z][A-Za-z0-9]*$", + max_length=260, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TenantActionGroupsGet(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 TenantActionGroupsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + **self.serialize_url_param( + "tenantActionGroupName", self.ctx.args.tenant_action_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + required=True, + ), + **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.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.azure_app_push_receivers = AAZListType( + serialized_name="azureAppPushReceivers", + ) + properties.email_receivers = AAZListType( + serialized_name="emailReceivers", + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.group_short_name = AAZStrType( + serialized_name="groupShortName", + flags={"required": True}, + ) + properties.sms_receivers = AAZListType( + serialized_name="smsReceivers", + ) + properties.voice_receivers = AAZListType( + serialized_name="voiceReceivers", + ) + properties.webhook_receivers = AAZListType( + serialized_name="webhookReceivers", + ) + + azure_app_push_receivers = cls._schema_on_200.properties.azure_app_push_receivers + azure_app_push_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.azure_app_push_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + + email_receivers = cls._schema_on_200.properties.email_receivers + email_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.email_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.status = AAZStrType() + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + sms_receivers = cls._schema_on_200.properties.sms_receivers + sms_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.sms_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + _element.status = AAZStrType() + + voice_receivers = cls._schema_on_200.properties.voice_receivers + voice_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.voice_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + + webhook_receivers = cls._schema_on_200.properties.webhook_receivers + webhook_receivers.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.webhook_receivers.Element + _element.identifier_uri = AAZStrType( + serialized_name="identifierUri", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.service_uri = AAZStrType( + serialized_name="serviceUri", + flags={"required": True}, + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.use_aad_auth = AAZBoolType( + serialized_name="useAadAuth", + ) + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_update.py new file mode 100644 index 00000000000..f8d86bab530 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/_update.py @@ -0,0 +1,696 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor tenant-action-group update", +) +class Update(AAZCommand): + """Update a new tenant action group or update an existing one. + """ + + _aaz_info = { + "version": "2023-05-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/managementgroups/{}/providers/microsoft.insights/tenantactiongroups/{}", "2023-05-01-preview"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.x_ms_client_tenant_id = AAZStrArg( + options=["--x-ms-client-tenant-id"], + help="The tenant ID of the client making the request.", + required=True, + ) + _args_schema.management_group_id = AAZStrArg( + options=["--management-group-id"], + help="The management group id.", + required=True, + ) + _args_schema.tenant_action_group_name = AAZStrArg( + options=["--tenant-action-group-name"], + help="The name of the action group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z][A-Za-z0-9]*$", + max_length=260, + min_length=1, + ), + ) + _args_schema.group_short_name = AAZStrArg( + options=["--short-name", "--group-short-name"], + help="The short name of the action group. This will be used in SMS messages.", + fmt=AAZStrArgFormat( + max_length=12, + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + help="Space-separated tags: key[=value] [key[=value] ...]. Use '' to clear existing tags.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.azure_app_push_receivers = AAZListArg( + options=["--azure-app-push-receivers"], + arg_group="Properties", + help="The list of AzureAppPush receivers that are part of this tenant action group.", + nullable=True, + ) + _args_schema.email_receivers = AAZListArg( + options=["--email-receivers"], + arg_group="Properties", + help="The list of email receivers that are part of this tenant action group.", + nullable=True, + ) + _args_schema.enabled = AAZBoolArg( + options=["--enabled"], + arg_group="Properties", + help="Indicates whether this tenant action group is enabled. If a tenant action group is not enabled, then none of its receivers will receive communications.", + ) + _args_schema.sms_receivers = AAZListArg( + options=["--sms-receivers"], + arg_group="Properties", + help="The list of SMS receivers that are part of this tenant action group.", + nullable=True, + ) + _args_schema.voice_receivers = AAZListArg( + options=["--voice-receivers"], + arg_group="Properties", + help="The list of voice receivers that are part of this tenant action group.", + nullable=True, + ) + _args_schema.webhook_receivers = AAZListArg( + options=["--webhook-receivers"], + arg_group="Properties", + help="The list of webhook receivers that are part of this tenant action group.", + nullable=True, + ) + + azure_app_push_receivers = cls._args_schema.azure_app_push_receivers + azure_app_push_receivers.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.azure_app_push_receivers.Element + _element.email_address = AAZStrArg( + options=["email-address"], + help="The email address registered for the Azure mobile app.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the Azure mobile app push receiver. Names must be unique across all receivers within a tenant action group.", + ) + + email_receivers = cls._args_schema.email_receivers + email_receivers.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.email_receivers.Element + _element.email_address = AAZStrArg( + options=["email-address"], + help="The email address of this receiver.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the email receiver. Names must be unique across all receivers within a tenant action group.", + ) + _element.use_common_alert_schema = AAZBoolArg( + options=["use-common-alert-schema"], + help="Indicates whether to use common alert schema.", + nullable=True, + ) + + sms_receivers = cls._args_schema.sms_receivers + sms_receivers.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.sms_receivers.Element + _element.country_code = AAZStrArg( + options=["country-code"], + help="The country code of the SMS receiver.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the SMS receiver. Names must be unique across all receivers within a tenant action group.", + ) + _element.phone_number = AAZStrArg( + options=["phone-number"], + help="The phone number of the SMS receiver.", + ) + + voice_receivers = cls._args_schema.voice_receivers + voice_receivers.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.voice_receivers.Element + _element.country_code = AAZStrArg( + options=["country-code"], + help="The country code of the voice receiver.", + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the voice receiver. Names must be unique across all receivers within a tenant action group.", + ) + _element.phone_number = AAZStrArg( + options=["phone-number"], + help="The phone number of the voice receiver.", + ) + + webhook_receivers = cls._args_schema.webhook_receivers + webhook_receivers.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.webhook_receivers.Element + _element.identifier_uri = AAZStrArg( + options=["identifier-uri"], + help="Indicates the identifier uri for aad auth.", + nullable=True, + ) + _element.name = AAZStrArg( + options=["name"], + help="The name of the webhook receiver. Names must be unique across all receivers within a tenant action group.", + ) + _element.object_id = AAZStrArg( + options=["object-id"], + help="Indicates the webhook app object Id for aad auth.", + nullable=True, + ) + _element.service_uri = AAZStrArg( + options=["service-uri"], + help="The URI where webhooks should be sent.", + ) + _element.tenant_id = AAZStrArg( + options=["tenant-id"], + help="Indicates the tenant id for aad auth.", + nullable=True, + ) + _element.use_aad_auth = AAZBoolArg( + options=["use-aad-auth"], + help="Indicates whether or not use AAD authentication.", + nullable=True, + ) + _element.use_common_alert_schema = AAZBoolArg( + options=["use-common-alert-schema"], + help="Indicates whether to use common alert schema.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TenantActionGroupsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.TenantActionGroupsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class TenantActionGroupsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + **self.serialize_url_param( + "tenantActionGroupName", self.ctx.args.tenant_action_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + required=True, + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_tenant_action_group_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class TenantActionGroupsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + **self.serialize_url_param( + "tenantActionGroupName", self.ctx.args.tenant_action_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + required=True, + ), + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_tenant_action_group_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("azureAppPushReceivers", AAZListType, ".azure_app_push_receivers") + properties.set_prop("emailReceivers", AAZListType, ".email_receivers") + properties.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("groupShortName", AAZStrType, ".group_short_name", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("smsReceivers", AAZListType, ".sms_receivers") + properties.set_prop("voiceReceivers", AAZListType, ".voice_receivers") + properties.set_prop("webhookReceivers", AAZListType, ".webhook_receivers") + + azure_app_push_receivers = _builder.get(".properties.azureAppPushReceivers") + if azure_app_push_receivers is not None: + azure_app_push_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.azureAppPushReceivers[]") + if _elements is not None: + _elements.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + + email_receivers = _builder.get(".properties.emailReceivers") + if email_receivers is not None: + email_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.emailReceivers[]") + if _elements is not None: + _elements.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("useCommonAlertSchema", AAZBoolType, ".use_common_alert_schema") + + sms_receivers = _builder.get(".properties.smsReceivers") + if sms_receivers is not None: + sms_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.smsReceivers[]") + if _elements is not None: + _elements.set_prop("countryCode", AAZStrType, ".country_code", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("phoneNumber", AAZStrType, ".phone_number", typ_kwargs={"flags": {"required": True}}) + + voice_receivers = _builder.get(".properties.voiceReceivers") + if voice_receivers is not None: + voice_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.voiceReceivers[]") + if _elements is not None: + _elements.set_prop("countryCode", AAZStrType, ".country_code", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("phoneNumber", AAZStrType, ".phone_number", typ_kwargs={"flags": {"required": True}}) + + webhook_receivers = _builder.get(".properties.webhookReceivers") + if webhook_receivers is not None: + webhook_receivers.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.webhookReceivers[]") + if _elements is not None: + _elements.set_prop("identifierUri", AAZStrType, ".identifier_uri") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("objectId", AAZStrType, ".object_id") + _elements.set_prop("serviceUri", AAZStrType, ".service_uri", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("tenantId", AAZStrType, ".tenant_id") + _elements.set_prop("useAadAuth", AAZBoolType, ".use_aad_auth") + _elements.set_prop("useCommonAlertSchema", AAZBoolType, ".use_common_alert_schema") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_tenant_action_group_resource_read = None + + @classmethod + def _build_schema_tenant_action_group_resource_read(cls, _schema): + if cls._schema_tenant_action_group_resource_read is not None: + _schema.id = cls._schema_tenant_action_group_resource_read.id + _schema.location = cls._schema_tenant_action_group_resource_read.location + _schema.name = cls._schema_tenant_action_group_resource_read.name + _schema.properties = cls._schema_tenant_action_group_resource_read.properties + _schema.tags = cls._schema_tenant_action_group_resource_read.tags + _schema.type = cls._schema_tenant_action_group_resource_read.type + return + + cls._schema_tenant_action_group_resource_read = _schema_tenant_action_group_resource_read = AAZObjectType() + + tenant_action_group_resource_read = _schema_tenant_action_group_resource_read + tenant_action_group_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + tenant_action_group_resource_read.location = AAZStrType( + flags={"required": True}, + ) + tenant_action_group_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + tenant_action_group_resource_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + tenant_action_group_resource_read.tags = AAZDictType() + tenant_action_group_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_tenant_action_group_resource_read.properties + properties.azure_app_push_receivers = AAZListType( + serialized_name="azureAppPushReceivers", + ) + properties.email_receivers = AAZListType( + serialized_name="emailReceivers", + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.group_short_name = AAZStrType( + serialized_name="groupShortName", + flags={"required": True}, + ) + properties.sms_receivers = AAZListType( + serialized_name="smsReceivers", + ) + properties.voice_receivers = AAZListType( + serialized_name="voiceReceivers", + ) + properties.webhook_receivers = AAZListType( + serialized_name="webhookReceivers", + ) + + azure_app_push_receivers = _schema_tenant_action_group_resource_read.properties.azure_app_push_receivers + azure_app_push_receivers.Element = AAZObjectType() + + _element = _schema_tenant_action_group_resource_read.properties.azure_app_push_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + + email_receivers = _schema_tenant_action_group_resource_read.properties.email_receivers + email_receivers.Element = AAZObjectType() + + _element = _schema_tenant_action_group_resource_read.properties.email_receivers.Element + _element.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.status = AAZStrType() + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + sms_receivers = _schema_tenant_action_group_resource_read.properties.sms_receivers + sms_receivers.Element = AAZObjectType() + + _element = _schema_tenant_action_group_resource_read.properties.sms_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + _element.status = AAZStrType() + + voice_receivers = _schema_tenant_action_group_resource_read.properties.voice_receivers + voice_receivers.Element = AAZObjectType() + + _element = _schema_tenant_action_group_resource_read.properties.voice_receivers.Element + _element.country_code = AAZStrType( + serialized_name="countryCode", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.phone_number = AAZStrType( + serialized_name="phoneNumber", + flags={"required": True}, + ) + + webhook_receivers = _schema_tenant_action_group_resource_read.properties.webhook_receivers + webhook_receivers.Element = AAZObjectType() + + _element = _schema_tenant_action_group_resource_read.properties.webhook_receivers.Element + _element.identifier_uri = AAZStrType( + serialized_name="identifierUri", + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.object_id = AAZStrType( + serialized_name="objectId", + ) + _element.service_uri = AAZStrType( + serialized_name="serviceUri", + flags={"required": True}, + ) + _element.tenant_id = AAZStrType( + serialized_name="tenantId", + ) + _element.use_aad_auth = AAZBoolType( + serialized_name="useAadAuth", + ) + _element.use_common_alert_schema = AAZBoolType( + serialized_name="useCommonAlertSchema", + ) + + tags = _schema_tenant_action_group_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_tenant_action_group_resource_read.id + _schema.location = cls._schema_tenant_action_group_resource_read.location + _schema.name = cls._schema_tenant_action_group_resource_read.name + _schema.properties = cls._schema_tenant_action_group_resource_read.properties + _schema.tags = cls._schema_tenant_action_group_resource_read.tags + _schema.type = cls._schema_tenant_action_group_resource_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/__cmd_group.py new file mode 100644 index 00000000000..70a6db5f715 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "monitor tenant-action-group notification-statu", +) +class __CMDGroup(AAZCommandGroup): + """monitor tenant-action-group notification-statu + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/__init__.py new file mode 100644 index 00000000000..28d5f355813 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/_show.py new file mode 100644 index 00000000000..dba281d27e6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/tenant_action_group/notification_statu/_show.py @@ -0,0 +1,219 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor tenant-action-group notification-statu show", +) +class Show(AAZCommand): + """Get the test notifications by the notification id + """ + + _aaz_info = { + "version": "2023-05-01-preview", + "resources": [ + ["mgmt-plane", "/providers/microsoft.management/managementgroups/{}/providers/microsoft.insights/tenantactiongroups/{}/notificationstatus/{}", "2023-05-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.x_ms_client_tenant_id = AAZStrArg( + options=["--x-ms-client-tenant-id"], + help="The tenant ID of the client making the request.", + required=True, + ) + _args_schema.management_group_id = AAZStrArg( + options=["--management-group-id"], + help="The management group id.", + required=True, + ) + _args_schema.notification_id = AAZStrArg( + options=["--notification-id"], + help="The notification id", + required=True, + ) + _args_schema.tenant_action_group_name = AAZStrArg( + options=["--tenant-action-group-name"], + help="The name of the action group.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z][A-Za-z0-9]*$", + max_length=260, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.GetTestNotificationsAtTenantActionGroupResourceLevel(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 GetTestNotificationsAtTenantActionGroupResourceLevel(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}/notificationStatus/{notificationId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "managementGroupId", self.ctx.args.management_group_id, + required=True, + ), + **self.serialize_url_param( + "notificationId", self.ctx.args.notification_id, + required=True, + ), + **self.serialize_url_param( + "tenantActionGroupName", self.ctx.args.tenant_action_group_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "x-ms-client-tenant-id", self.ctx.args.x_ms_client_tenant_id, + required=True, + ), + **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.action_details = AAZListType( + serialized_name="actionDetails", + ) + _schema_on_200.completed_time = AAZStrType( + serialized_name="completedTime", + ) + _schema_on_200.context = AAZObjectType() + _schema_on_200.created_time = AAZStrType( + serialized_name="createdTime", + ) + _schema_on_200.state = AAZStrType( + flags={"required": True}, + ) + + action_details = cls._schema_on_200.action_details + action_details.Element = AAZObjectType() + + _element = cls._schema_on_200.action_details.Element + _element.mechanism_type = AAZStrType( + serialized_name="mechanismType", + ) + _element.message = AAZStrType() + _element.name = AAZStrType() + _element.send_time = AAZStrType( + serialized_name="sendTime", + ) + _element.status = AAZStrType() + _element.sub_state = AAZStrType( + serialized_name="subState", + ) + + context = cls._schema_on_200.context + context.context_type = AAZStrType( + serialized_name="contextType", + ) + context.notification_source = AAZStrType( + serialized_name="notificationSource", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"]