diff --git a/src/databasewatcher/HISTORY.rst b/src/databasewatcher/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/databasewatcher/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/databasewatcher/README.md b/src/databasewatcher/README.md new file mode 100644 index 00000000000..364d7e6118a --- /dev/null +++ b/src/databasewatcher/README.md @@ -0,0 +1,5 @@ +# Azure CLI Databasewatcher Extension # +This is an extension to Azure CLI to manage Databasewatcher resources. + +## How to use ## +Please add commands usage here. \ No newline at end of file diff --git a/src/databasewatcher/azext_databasewatcher/__init__.py b/src/databasewatcher/azext_databasewatcher/__init__.py new file mode 100644 index 00000000000..ad52d9ef70c --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/__init__.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_databasewatcher._help import helps # pylint: disable=unused-import + + +class DatabasewatcherCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_databasewatcher.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_databasewatcher.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_databasewatcher._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = DatabasewatcherCommandsLoader diff --git a/src/databasewatcher/azext_databasewatcher/_help.py b/src/databasewatcher/azext_databasewatcher/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/databasewatcher/azext_databasewatcher/_params.py b/src/databasewatcher/azext_databasewatcher/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/_params.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/databasewatcher/azext_databasewatcher/aaz/__init__.py b/src/databasewatcher/azext_databasewatcher/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/__init__.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/__init__.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/__cmd_group.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/__cmd_group.py new file mode 100644 index 00000000000..6b6e4fdf0b1 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/__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( + "databasewatcher", +) +class __CMDGroup(AAZCommandGroup): + """Manage the Database Watcher service. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/__init__.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/__init__.py new file mode 100644 index 00000000000..6b92483ac1e --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/__init__.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._show import * +from ._start import * +from ._stop import * +from ._update import * +from ._wait import * diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_create.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_create.py new file mode 100644 index 00000000000..2cc43a29e5e --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_create.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( + "databasewatcher create", +) +class Create(AAZCommand): + """Create a Watcher + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + + # 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 "Properties" + + _args_schema = cls._args_schema + _args_schema.datastore = AAZObjectArg( + options=["--datastore"], + arg_group="Properties", + help="The data store for collected monitoring data.", + ) + _args_schema.default_alert_rule_identity_resource_id = AAZResourceIdArg( + options=["--default-alert-rule-identity-resource-id"], + arg_group="Properties", + help="The resource ID of a user-assigned managed identity that will be assigned to a new alert rule.", + ) + + datastore = cls._args_schema.datastore + datastore.adx_cluster_resource_id = AAZResourceIdArg( + options=["adx-cluster-resource-id"], + help="The Azure resource ID of an Azure Data Explorer cluster. Value required if kusto-offering-type is adx. Do not pass value if kusto-offering-type is fabric or free.", + ) + datastore.kusto_cluster_display_name = AAZStrArg( + options=["kusto-cluster-display-name"], + help="The Kusto cluster display name. Value required if kusto-offering-type is adx or free. Do not pass value if kusto-offering-type is fabric.", + ) + datastore.kusto_cluster_uri = AAZStrArg( + options=["kusto-cluster-uri"], + help="The Kusto cluster URI.", + required=True, + ) + datastore.kusto_data_ingestion_uri = AAZStrArg( + options=["kusto-data-ingestion-uri"], + help="The Kusto data ingestion URI.", + required=True, + ) + datastore.kusto_database_name = AAZStrArg( + options=["kusto-database-name"], + help="The name of a Kusto database.", + required=True, + ) + datastore.kusto_management_url = AAZStrArg( + options=["kusto-management-url"], + help="The Kusto management URL.", + required=True, + ) + datastore.kusto_offering_type = AAZStrArg( + options=["kusto-offering-type"], + help="The type of a Kusto offering.", + required=True, + enum={"adx": "adx", "fabric": "fabric", "free": "free"}, + ) + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _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.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.WatchersCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 WatchersCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}", + **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( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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) + _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("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("datastore", AAZObjectType, ".datastore") + properties.set_prop("defaultAlertRuleIdentityResourceId", AAZStrType, ".default_alert_rule_identity_resource_id") + + datastore = _builder.get(".properties.datastore") + if datastore is not None: + datastore.set_prop("adxClusterResourceId", AAZStrType, ".adx_cluster_resource_id") + datastore.set_prop("kustoClusterDisplayName", AAZStrType, ".kusto_cluster_display_name") + datastore.set_prop("kustoClusterUri", AAZStrType, ".kusto_cluster_uri", typ_kwargs={"flags": {"required": True}}) + datastore.set_prop("kustoDataIngestionUri", AAZStrType, ".kusto_data_ingestion_uri", typ_kwargs={"flags": {"required": True}}) + datastore.set_prop("kustoDatabaseName", AAZStrType, ".kusto_database_name", typ_kwargs={"flags": {"required": True}}) + datastore.set_prop("kustoManagementUrl", AAZStrType, ".kusto_management_url", typ_kwargs={"flags": {"required": True}}) + datastore.set_prop("kustoOfferingType", AAZStrType, ".kusto_offering_type", 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_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.identity = AAZIdentityObjectType() + _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.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = cls._schema_on_200_201.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_delete.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_delete.py new file mode 100644 index 00000000000..ce1121631ea --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_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( + "databasewatcher delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a Watcher + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.WatchersDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class WatchersDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_show.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_show.py new file mode 100644 index 00000000000..d691af0e831 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_show.py @@ -0,0 +1,278 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher show", +) +class Show(AAZCommand): + """Get a Watcher + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WatchersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 WatchersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}", + **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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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.identity = AAZIdentityObjectType() + _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.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = cls._schema_on_200.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_start.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_start.py new file mode 100644 index 00000000000..ba6cb74315e --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_start.py @@ -0,0 +1,295 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher start", +) +class Start(AAZCommand): + """Start monitoring all targets configured for a database watcher. + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}/start", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.WatchersStart(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 WatchersStart(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}/start", + **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( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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.identity = AAZIdentityObjectType() + _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.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = cls._schema_on_200.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _StartHelper: + """Helper class for Start""" + + +__all__ = ["Start"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_stop.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_stop.py new file mode 100644 index 00000000000..80013ec3cf9 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_stop.py @@ -0,0 +1,295 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher stop", +) +class Stop(AAZCommand): + """Stop monitoring all targets configured for a database watcher. + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}/stop", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.WatchersStop(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 WatchersStop(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}/stop", + **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( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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.identity = AAZIdentityObjectType() + _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.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = cls._schema_on_200.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _StopHelper: + """Helper class for Stop""" + + +__all__ = ["Stop"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_update.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_update.py new file mode 100644 index 00000000000..aecb06c4f0a --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_update.py @@ -0,0 +1,385 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher update", +) +class Update(AAZCommand): + """Update a Watcher + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + + # define Arg Group "Identity" + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.datastore = AAZObjectArg( + options=["--datastore"], + arg_group="Properties", + help="The data store for collected monitoring data.", + ) + _args_schema.default_alert_rule_identity_resource_id = AAZResourceIdArg( + options=["--default-alert-rule-identity-resource-id"], + arg_group="Properties", + help="The resource ID of a user-assigned managed identity that will be assigned to a new alert rule.", + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Properties", + help="Resource tags.", + ) + + datastore = cls._args_schema.datastore + datastore.adx_cluster_resource_id = AAZResourceIdArg( + options=["adx-cluster-resource-id"], + help="The Azure resource ID of an Azure Data Explorer cluster. Value required if kusto-offering-type is adx. Do not pass value if kusto-offering-type is fabric or free.", + ) + datastore.kusto_cluster_display_name = AAZStrArg( + options=["kusto-cluster-display-name"], + help="The Kusto cluster display name. Value required if kusto-offering-type is adx or free. Do not pass value if kusto-offering-type is fabric.", + ) + datastore.kusto_cluster_uri = AAZStrArg( + options=["kusto-cluster-uri"], + help="The Kusto cluster URI.", + ) + datastore.kusto_data_ingestion_uri = AAZStrArg( + options=["kusto-data-ingestion-uri"], + help="The Kusto data ingestion URI.", + ) + datastore.kusto_database_name = AAZStrArg( + options=["kusto-database-name"], + help="The name of a Kusto database.", + ) + datastore.kusto_management_url = AAZStrArg( + options=["kusto-management-url"], + help="The Kusto management URL.", + ) + datastore.kusto_offering_type = AAZStrArg( + options=["kusto-offering-type"], + help="The type of a Kusto offering.", + enum={"adx": "adx", "fabric": "fabric", "free": "free"}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.WatchersUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 WatchersUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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) + _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("datastore", AAZObjectType, ".datastore") + properties.set_prop("defaultAlertRuleIdentityResourceId", AAZStrType, ".default_alert_rule_identity_resource_id") + + datastore = _builder.get(".properties.datastore") + if datastore is not None: + datastore.set_prop("adxClusterResourceId", AAZStrType, ".adx_cluster_resource_id") + datastore.set_prop("kustoClusterDisplayName", AAZStrType, ".kusto_cluster_display_name") + datastore.set_prop("kustoClusterUri", AAZStrType, ".kusto_cluster_uri") + datastore.set_prop("kustoDataIngestionUri", AAZStrType, ".kusto_data_ingestion_uri") + datastore.set_prop("kustoDatabaseName", AAZStrType, ".kusto_database_name") + datastore.set_prop("kustoManagementUrl", AAZStrType, ".kusto_management_url") + datastore.set_prop("kustoOfferingType", AAZStrType, ".kusto_offering_type") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _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.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = cls._schema_on_200.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_wait.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_wait.py new file mode 100644 index 00000000000..160f1cf0bfa --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/_wait.py @@ -0,0 +1,277 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher 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.databasewatcher/watchers/{}", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WatchersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 WatchersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}", + **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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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.identity = AAZIdentityObjectType() + _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.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = cls._schema_on_200.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/__cmd_group.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/__cmd_group.py new file mode 100644 index 00000000000..aa158032d61 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/__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( + "databasewatcher health-validation", +) +class __CMDGroup(AAZCommandGroup): + """Manage the Database Watcher health validation resource. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/__init__.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/__init__.py new file mode 100644 index 00000000000..0fae59e6503 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/__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 ._start import * diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/_start.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/_start.py new file mode 100644 index 00000000000..b9a2169161d --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/health_validation/_start.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( + "databasewatcher health-validation start", +) +class Start(AAZCommand): + """Starts health validation for a watcher. + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}/healthvalidations/{}/startvalidation", "2025-01-02"], + ] + } + + 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.health_validation_name = AAZStrArg( + options=["--health-validation-name"], + help="The health validation resource name. The operation would fail if not using the default value.", + required=True, + id_part="child_name_1", + default="healthValidation", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_.]{0,62}[a-zA-Z0-9_]{1}$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.HealthValidationsStartValidation(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 HealthValidationsStartValidation(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation", + **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( + "healthValidationName", self.ctx.args.health_validation_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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.end_time = AAZStrType( + serialized_name="endTime", + flags={"read_only": True}, + ) + properties.issues = AAZListType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + issues = cls._schema_on_200.properties.issues + issues.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.issues.Element + _element.additional_details = AAZStrType( + serialized_name="additionalDetails", + flags={"read_only": True}, + ) + _element.error_code = AAZStrType( + serialized_name="errorCode", + flags={"read_only": True}, + ) + _element.error_message = AAZStrType( + serialized_name="errorMessage", + flags={"read_only": True}, + ) + _element.recommendation_message = AAZStrType( + serialized_name="recommendationMessage", + flags={"read_only": True}, + ) + _element.recommendation_url = AAZStrType( + serialized_name="recommendationUrl", + flags={"read_only": True}, + ) + _element.related_resource_id = AAZStrType( + serialized_name="relatedResourceId", + flags={"read_only": True}, + ) + _element.related_resource_type = AAZStrType( + serialized_name="relatedResourceType", + 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 _StartHelper: + """Helper class for Start""" + + +__all__ = ["Start"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/__cmd_group.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/__cmd_group.py new file mode 100644 index 00000000000..ddb26147708 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/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( + "databasewatcher identity", +) +class __CMDGroup(AAZCommandGroup): + """Manage identities for Database Watcher resource. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/__init__.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/__init__.py new file mode 100644 index 00000000000..3a074471e35 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/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 ._remove import * +from ._show import * +from ._wait import * diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_assign.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_assign.py new file mode 100644 index 00000000000..6f75233c296 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_assign.py @@ -0,0 +1,479 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher identity assign", +) +class Assign(AAZCommand): + """Assign the user or system managed identities. + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}", "2025-01-02", "identity"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + + # define Arg Group "Resource.identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Resource.identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Resource.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.WatchersGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.required()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.required()) + yield self.WatchersCreateOrUpdate(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.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 WatchersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}", + **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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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_watcher_read(cls._schema_on_200) + + return cls._schema_on_200 + + class WatchersCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}", + **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( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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_watcher_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.required()) + + 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_watcher_read = None + + @classmethod + def _build_schema_watcher_read(cls, _schema): + if cls._schema_watcher_read is not None: + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + return + + cls._schema_watcher_read = _schema_watcher_read = AAZObjectType() + + watcher_read = _schema_watcher_read + watcher_read.id = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.identity = AAZIdentityObjectType() + watcher_read.location = AAZStrType( + flags={"required": True}, + ) + watcher_read.name = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + watcher_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + watcher_read.tags = AAZDictType() + watcher_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_watcher_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_watcher_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_watcher_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_watcher_read.properties + properties.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = _schema_watcher_read.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = _schema_watcher_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_watcher_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + + +__all__ = ["Assign"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_remove.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_remove.py new file mode 100644 index 00000000000..d88d2c42e39 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_remove.py @@ -0,0 +1,480 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher identity remove", + confirmation="Are you sure you want to perform this operation?", +) +class Remove(AAZCommand): + """Remove the user or system managed identities. + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}", "2025-01-02", "identity"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + + # define Arg Group "Resource.identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Resource.identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Resource.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.WatchersGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.required()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.required()) + yield self.WatchersCreateOrUpdate(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.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 WatchersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}", + **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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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_watcher_read(cls._schema_on_200) + + return cls._schema_on_200 + + class WatchersCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}", + **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( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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_watcher_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.required()) + + 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_watcher_read = None + + @classmethod + def _build_schema_watcher_read(cls, _schema): + if cls._schema_watcher_read is not None: + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + return + + cls._schema_watcher_read = _schema_watcher_read = AAZObjectType() + + watcher_read = _schema_watcher_read + watcher_read.id = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.identity = AAZIdentityObjectType() + watcher_read.location = AAZStrType( + flags={"required": True}, + ) + watcher_read.name = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + watcher_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + watcher_read.tags = AAZDictType() + watcher_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_watcher_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_watcher_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_watcher_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_watcher_read.properties + properties.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = _schema_watcher_read.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = _schema_watcher_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_watcher_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + + +__all__ = ["Remove"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_show.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_show.py new file mode 100644 index 00000000000..66ce99f80a1 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_show.py @@ -0,0 +1,316 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher identity show", +) +class Show(AAZCommand): + """Show the details of managed identities. + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}", "2025-01-02", "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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WatchersGet(ctx=self.ctx)() + self.post_operations() + + @register_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 WatchersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}", + **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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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_watcher_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_watcher_read = None + + @classmethod + def _build_schema_watcher_read(cls, _schema): + if cls._schema_watcher_read is not None: + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + return + + cls._schema_watcher_read = _schema_watcher_read = AAZObjectType() + + watcher_read = _schema_watcher_read + watcher_read.id = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.identity = AAZIdentityObjectType() + watcher_read.location = AAZStrType( + flags={"required": True}, + ) + watcher_read.name = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + watcher_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + watcher_read.tags = AAZDictType() + watcher_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_watcher_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_watcher_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_watcher_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_watcher_read.properties + properties.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = _schema_watcher_read.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = _schema_watcher_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_watcher_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + + +__all__ = ["Show"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_wait.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_wait.py new file mode 100644 index 00000000000..a4dbb6ba9a0 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/identity/_wait.py @@ -0,0 +1,304 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher identity 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.databasewatcher/watchers/{}", "2025-01-02", "identity"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["-n", "--name", "--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WatchersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 WatchersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}", + **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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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() + _WaitHelper._build_schema_watcher_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_watcher_read = None + + @classmethod + def _build_schema_watcher_read(cls, _schema): + if cls._schema_watcher_read is not None: + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + return + + cls._schema_watcher_read = _schema_watcher_read = AAZObjectType() + + watcher_read = _schema_watcher_read + watcher_read.id = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.identity = AAZIdentityObjectType() + watcher_read.location = AAZStrType( + flags={"required": True}, + ) + watcher_read.name = AAZStrType( + flags={"read_only": True}, + ) + watcher_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + watcher_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + watcher_read.tags = AAZDictType() + watcher_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_watcher_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_watcher_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType() + + _element = _schema_watcher_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_watcher_read.properties + properties.datastore = AAZObjectType() + properties.default_alert_rule_identity_resource_id = AAZStrType( + serialized_name="defaultAlertRuleIdentityResourceId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + datastore = _schema_watcher_read.properties.datastore + datastore.adx_cluster_resource_id = AAZStrType( + serialized_name="adxClusterResourceId", + ) + datastore.kusto_cluster_display_name = AAZStrType( + serialized_name="kustoClusterDisplayName", + ) + datastore.kusto_cluster_uri = AAZStrType( + serialized_name="kustoClusterUri", + flags={"required": True}, + ) + datastore.kusto_data_ingestion_uri = AAZStrType( + serialized_name="kustoDataIngestionUri", + flags={"required": True}, + ) + datastore.kusto_database_name = AAZStrType( + serialized_name="kustoDatabaseName", + flags={"required": True}, + ) + datastore.kusto_management_url = AAZStrType( + serialized_name="kustoManagementUrl", + flags={"required": True}, + ) + datastore.kusto_offering_type = AAZStrType( + serialized_name="kustoOfferingType", + flags={"required": True}, + ) + + system_data = _schema_watcher_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_watcher_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_watcher_read.id + _schema.identity = cls._schema_watcher_read.identity + _schema.location = cls._schema_watcher_read.location + _schema.name = cls._schema_watcher_read.name + _schema.properties = cls._schema_watcher_read.properties + _schema.system_data = cls._schema_watcher_read.system_data + _schema.tags = cls._schema_watcher_read.tags + _schema.type = cls._schema_watcher_read.type + + +__all__ = ["Wait"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/__cmd_group.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/__cmd_group.py new file mode 100644 index 00000000000..2e2e5bdb40a --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/__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( + "databasewatcher shared-private-link", +) +class __CMDGroup(AAZCommandGroup): + """Manage the Database Watcher shared private link resource. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/__init__.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/__init__.py new file mode 100644 index 00000000000..2d1a2078686 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/__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 ._wait import * diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_create.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_create.py new file mode 100644 index 00000000000..189e23086e8 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_create.py @@ -0,0 +1,297 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher shared-private-link create", +) +class Create(AAZCommand): + """Create a SharedPrivateLinkResource + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}/sharedprivatelinkresources/{}", "2025-01-02"], + ] + } + + 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.shared_private_link_resource_name = AAZStrArg( + options=["-n", "--name", "--shared-private-link-resource-name"], + help="The Shared Private Link resource name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_.]{0,62}[a-zA-Z0-9_]{1}$", + ), + ) + _args_schema.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.dns_zone = AAZStrArg( + options=["--dns-zone"], + arg_group="Properties", + help="The DNS zone segment to be included in the DNS name of the shared private link. Value is required for Azure Data Explorer clusters and SQL managed instances, and must be omitted for SQL logical servers and key vaults. The value is the second segment of the host FQDN name of the resource that the shared private link resource is for. For example: if the host name is 'adx-cluster-21187695.eastus.kusto.windows.net', then the value is 'eastus'; if the host name is 'sql-mi-23961134.767d5869f605.database.windows.net', then the value is '767d5869f605'.", + ) + _args_schema.group_id = AAZStrArg( + options=["--group-id"], + arg_group="Properties", + help="The group id from the provider of resource the shared private link resource is for.", + ) + _args_schema.private_link_resource_id = AAZResourceIdArg( + options=["--private-link-resource-id"], + arg_group="Properties", + help="The resource ID of the resource the shared private link resource is for.", + ) + _args_schema.request_message = AAZStrArg( + options=["--request-message"], + arg_group="Properties", + help="The request message for requesting approval of the shared private link resource.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.SharedPrivateLinkResourcesCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 SharedPrivateLinkResourcesCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + **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( + "sharedPrivateLinkResourceName", self.ctx.args.shared_private_link_resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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("dnsZone", AAZStrType, ".dns_zone") + properties.set_prop("groupId", AAZStrType, ".group_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("privateLinkResourceId", AAZStrType, ".private_link_resource_id", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("requestMessage", AAZStrType, ".request_message", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.dns_zone = AAZStrType( + serialized_name="dnsZone", + ) + properties.group_id = AAZStrType( + serialized_name="groupId", + flags={"required": True}, + ) + properties.private_link_resource_id = AAZStrType( + serialized_name="privateLinkResourceId", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.request_message = AAZStrType( + serialized_name="requestMessage", + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_delete.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_delete.py new file mode 100644 index 00000000000..bf9c7c3535b --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_delete.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( + "databasewatcher shared-private-link delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a SharedPrivateLinkResource + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}/sharedprivatelinkresources/{}", "2025-01-02"], + ] + } + + 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.shared_private_link_resource_name = AAZStrArg( + options=["-n", "--name", "--shared-private-link-resource-name"], + help="The Shared Private Link resource name.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_.]{0,62}[a-zA-Z0-9_]{1}$", + ), + ) + _args_schema.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.SharedPrivateLinkResourcesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class SharedPrivateLinkResourcesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(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.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + **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( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "sharedPrivateLinkResourceName", self.ctx.args.shared_private_link_resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + 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/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_list.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_list.py new file mode 100644 index 00000000000..c8c1c79df71 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_list.py @@ -0,0 +1,236 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher shared-private-link list", +) +class List(AAZCommand): + """List SharedPrivateLinkResource resources by Watcher + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}/sharedprivatelinkresources", "2025-01-02"], + ] + } + + 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.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SharedPrivateLinkResourcesListByWatcher(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 SharedPrivateLinkResourcesListByWatcher(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources", + **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, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.dns_zone = AAZStrType( + serialized_name="dnsZone", + ) + properties.group_id = AAZStrType( + serialized_name="groupId", + flags={"required": True}, + ) + properties.private_link_resource_id = AAZStrType( + serialized_name="privateLinkResourceId", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.request_message = AAZStrType( + serialized_name="requestMessage", + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_show.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_show.py new file mode 100644 index 00000000000..2bc9cf0d154 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_show.py @@ -0,0 +1,237 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher shared-private-link show", +) +class Show(AAZCommand): + """Get a SharedPrivateLinkResource + """ + + _aaz_info = { + "version": "2025-01-02", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databasewatcher/watchers/{}/sharedprivatelinkresources/{}", "2025-01-02"], + ] + } + + 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.shared_private_link_resource_name = AAZStrArg( + options=["-n", "--name", "--shared-private-link-resource-name"], + help="The Shared Private Link resource name.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_.]{0,62}[a-zA-Z0-9_]{1}$", + ), + ) + _args_schema.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SharedPrivateLinkResourcesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 SharedPrivateLinkResourcesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + **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( + "sharedPrivateLinkResourceName", self.ctx.args.shared_private_link_resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.dns_zone = AAZStrType( + serialized_name="dnsZone", + ) + properties.group_id = AAZStrType( + serialized_name="groupId", + flags={"required": True}, + ) + properties.private_link_resource_id = AAZStrType( + serialized_name="privateLinkResourceId", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.request_message = AAZStrType( + serialized_name="requestMessage", + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_wait.py b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_wait.py new file mode 100644 index 00000000000..cf714b90fb6 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/aaz/latest/databasewatcher/shared_private_link/_wait.py @@ -0,0 +1,236 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "databasewatcher shared-private-link 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.databasewatcher/watchers/{}/sharedprivatelinkresources/{}", "2025-01-02"], + ] + } + + 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.shared_private_link_resource_name = AAZStrArg( + options=["-n", "--name", "--shared-private-link-resource-name"], + help="The Shared Private Link resource name.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_.]{0,62}[a-zA-Z0-9_]{1}$", + ), + ) + _args_schema.watcher_name = AAZStrArg( + options=["--watcher-name"], + help="The database watcher name.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{1}[a-zA-Z0-9-_]{3,60}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SharedPrivateLinkResourcesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 SharedPrivateLinkResourcesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + **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( + "sharedPrivateLinkResourceName", self.ctx.args.shared_private_link_resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "watcherName", self.ctx.args.watcher_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-01-02", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.dns_zone = AAZStrType( + serialized_name="dnsZone", + ) + properties.group_id = AAZStrType( + serialized_name="groupId", + flags={"required": True}, + ) + properties.private_link_resource_id = AAZStrType( + serialized_name="privateLinkResourceId", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.request_message = AAZStrType( + serialized_name="requestMessage", + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/databasewatcher/azext_databasewatcher/azext_metadata.json b/src/databasewatcher/azext_databasewatcher/azext_metadata.json new file mode 100644 index 00000000000..b2e481ecb9e --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.67.0" +} \ No newline at end of file diff --git a/src/databasewatcher/azext_databasewatcher/commands.py b/src/databasewatcher/azext_databasewatcher/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/commands.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): # pylint: disable=unused-argument + pass diff --git a/src/databasewatcher/azext_databasewatcher/custom.py b/src/databasewatcher/azext_databasewatcher/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/custom.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger + + +logger = get_logger(__name__) diff --git a/src/databasewatcher/azext_databasewatcher/tests/__init__.py b/src/databasewatcher/azext_databasewatcher/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/databasewatcher/azext_databasewatcher/tests/latest/__init__.py b/src/databasewatcher/azext_databasewatcher/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/databasewatcher/azext_databasewatcher/tests/latest/test_databasewatcher.py b/src/databasewatcher/azext_databasewatcher/tests/latest/test_databasewatcher.py new file mode 100644 index 00000000000..bd624d974ba --- /dev/null +++ b/src/databasewatcher/azext_databasewatcher/tests/latest/test_databasewatcher.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * + + +class DatabasewatcherScenario(ScenarioTest): + # TODO: add tests here + pass diff --git a/src/databasewatcher/setup.cfg b/src/databasewatcher/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/databasewatcher/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/databasewatcher/setup.py b/src/databasewatcher/setup.py new file mode 100644 index 00000000000..d272090445d --- /dev/null +++ b/src/databasewatcher/setup.py @@ -0,0 +1,49 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# HISTORY.rst entry. +VERSION = '1.0.0b1' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='databasewatcher', + version=VERSION, + description='Microsoft Azure Command-Line Tools Databasewatcher Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/databasewatcher', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_databasewatcher': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +)