diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 53bcda971dc..12960d41a55 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -333,3 +333,5 @@ /src/carbon/ @itiinani /src/amlfs/ @Aman-Jain-14 @amajai @mawhite @brpanask @tibanyas + +/src/storage-discovery/ @shanefujs @calvinhzy diff --git a/src/service_name.json b/src/service_name.json index d32d6e02332..64acbe82abe 100644 --- a/src/service_name.json +++ b/src/service_name.json @@ -884,6 +884,11 @@ "AzureServiceName": "Azure Storage Actions", "URL": "https://learn.microsoft.com/azure/storage-actions/" }, + { + "Command": "az storage-discovery", + "AzureServiceName": "Azure Storage Discovery", + "URL": "https://learn.microsoft.com/azure/storage-discovery/" + }, { "Command": "az baremetalinstance", "AzureServiceName": "BareMetal Infrastructure", diff --git a/src/storage-discovery/HISTORY.rst b/src/storage-discovery/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/storage-discovery/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/storage-discovery/README.md b/src/storage-discovery/README.md new file mode 100644 index 00000000000..de165da4d1f --- /dev/null +++ b/src/storage-discovery/README.md @@ -0,0 +1,56 @@ +# Azure CLI StorageDiscovery Extension # +This is an extension to Azure CLI to manage StorageDiscovery resources. + +## How to use ## +### az storage-discovery workspace create ### +```commandline +az storage-discovery workspace create \ + --resource-group myRG \ + --name myWorkspace \ + --location francecentral \ + --workspace-roots "/subscriptions/mySubId/resourceGroups/myRG" \ + --scopes '[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"]}]' +``` + +### az storage-discovery workspace create (with full configuration) ### +```commandline +az storage-discovery workspace create \ + --resource-group myRG \ + --name myWorkspace \ + --location francecentral \ + --description "My workspace for storage discovery" \ + --sku Standard \ + --workspace-roots "/subscriptions/mySubId/resourceGroups/myRG" \ + --scopes '[{"displayName":"production","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":["environment"],"tags":{"project":"demo","tier":"prod"}}]' +``` + +### az storage-discovery workspace show ### +```commandline +az storage-discovery workspace show --resource-group myRG --name myWorkspace +``` + +### az storage-discovery workspace update ### +```commandline +az storage-discovery workspace update \ + --resource-group myRG \ + --name myWorkspace \ + --description "Updated description" \ + --sku Free \ + --scopes '[{"displayName":"updated","resourceTypes":["Microsoft.Storage/storageAccounts"],"tags":{"environment":"test"}}]' \ + --tags environment=production team=storage +``` + +### az storage-discovery workspace list ### +```commandline +az storage-discovery workspace list --resource-group myRG +``` + +### az storage-discovery workspace list (subscription level) ### +```commandline +az storage-discovery workspace list +``` + +### az storage-discovery workspace delete ### +```commandline +az storage-discovery workspace delete --resource-group myRG --name myWorkspace +``` \ No newline at end of file diff --git a/src/storage-discovery/azext_storage_discovery/__init__.py b/src/storage-discovery/azext_storage_discovery/__init__.py new file mode 100644 index 00000000000..33ec589b0a4 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/__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_storage_discovery._help import helps # pylint: disable=unused-import + + +class StorageDiscoveryCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_storage_discovery.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_storage_discovery.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_storage_discovery._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = StorageDiscoveryCommandsLoader diff --git a/src/storage-discovery/azext_storage_discovery/_help.py b/src/storage-discovery/azext_storage_discovery/_help.py new file mode 100644 index 00000000000..faed951223c --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/_help.py @@ -0,0 +1,61 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All 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 + +helps['storage-discovery workspace create'] = """ + type: command + short-summary: Create a storage discovery workspace. + examples: + - name: Create a storage discovery workspace with basic settings. + text: | + az storage-discovery workspace create \\ + --resource-group myRG \\ + --name myWorkspace \\ + --location eastus2 \\ + --workspace-roots "/subscriptions/mySubId/resourceGroups/myRG" \\ + --scopes '[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"]}]' + - name: Create a storage discovery workspace with full configuration. + text: | + az storage-discovery workspace create \\ + --resource-group myRG \\ + --name myWorkspace \\ + --location francecentral \\ + --description "My workspace for storage discovery" \\ + --sku Standard \\ + --workspace-roots "/subscriptions/mySubId/resourceGroups/myRG" \\ + --scopes '[{"displayName":"production","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":["environment"],"tags":{"project":"demo","tier":"prod"}}]' +""" + +helps['storage-discovery workspace update'] = """ + type: command + short-summary: Update a storage discovery workspace. + examples: + - name: Update workspace description and SKU. + text: | + az storage-discovery workspace update \\ + --resource-group myRG \\ + --name myWorkspace \\ + --description "Updated description" \\ + --sku Free + - name: Update workspace with new scopes and tags. + text: | + az storage-discovery workspace update \\ + --resource-group myRG \\ + --name myWorkspace \\ + --scopes '[{"displayName":"updated","resourceTypes":["Microsoft.Storage/storageAccounts"],"tags":{"environment":"test"}}]' \\ + --tags environment=production team=storage + - name: Update workspace roots to subscription level. + text: | + az storage-discovery workspace update \\ + --resource-group myRG \\ + --name myWorkspace \\ + --workspace-roots "/subscriptions/mySubId" +""" diff --git a/src/storage-discovery/azext_storage_discovery/_params.py b/src/storage-discovery/azext_storage_discovery/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/_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/storage-discovery/azext_storage_discovery/aaz/__init__.py b/src/storage-discovery/azext_storage_discovery/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/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/storage-discovery/azext_storage_discovery/aaz/latest/__init__.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/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/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/__cmd_group.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/__cmd_group.py new file mode 100644 index 00000000000..eb53c09502f --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "storage-discovery", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage Storage Discovery + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/__init__.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/__cmd_group.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/__cmd_group.py new file mode 100644 index 00000000000..49df0aa0703 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "storage-discovery workspace", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage Storage Discovery Workspace + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/__init__.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_create.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_create.py new file mode 100644 index 00000000000..f8a8a5ef3e0 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_create.py @@ -0,0 +1,397 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage-discovery workspace create", + is_preview=True, +) +class Create(AAZCommand): + """Create a StorageDiscoveryWorkspace + + :example: Create or Update a StorageDiscoveryWorkspace + az az storage-discovery workspace create --resource-group myRG --name myWorkspace --location francecentral --workspace-roots "/subscriptions/mySubId/resourceGroups/myRG" --scopes '[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"]}]' + az storage-discovery workspace create --resource-group myRG --name myWorkspace --location francecentral --description "My workspace for storage discovery" --sku Standard --workspace-roots "/subscriptions/mySubId/resourceGroups/myRG" --scopes '[{"displayName":"production","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":["environment"],"tags":{"project":"demo","tier":"prod"}}]' + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storagediscovery/storagediscoveryworkspaces/{}", "2025-06-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_discovery_workspace_name = AAZStrArg( + options=["-n", "--name", "--storage-discovery-workspace-name"], + help="The name of the StorageDiscoveryWorkspace", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*$", + max_length=64, + min_length=4, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="The description of the storage discovery workspace", + ) + _args_schema.scopes = AAZListArg( + options=["--scopes"], + arg_group="Properties", + help="The scopes of the storage discovery workspace.", + ) + _args_schema.sku = AAZStrArg( + options=["--sku"], + arg_group="Properties", + help="The storage discovery sku", + default="Standard", + enum={"Free": "Free", "Standard": "Standard"}, + ) + _args_schema.workspace_roots = AAZListArg( + options=["--workspace-roots"], + arg_group="Properties", + help="The view level storage discovery data estate", + ) + + scopes = cls._args_schema.scopes + scopes.Element = AAZObjectArg() + + _element = cls._args_schema.scopes.Element + _element.display_name = AAZStrArg( + options=["display-name"], + help="Display name of the collection", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]+([ -][a-zA-Z0-9]+)*$", + max_length=64, + min_length=4, + ), + ) + _element.resource_types = AAZListArg( + options=["resource-types"], + help="Resource types for the collection", + required=True, + ) + _element.tag_keys_only = AAZListArg( + options=["tag-keys-only"], + help="The storage account tags keys to filter", + ) + _element.tags = AAZDictArg( + options=["tags"], + help="Resource tags.", + ) + + resource_types = cls._args_schema.scopes.Element.resource_types + resource_types.Element = AAZStrArg( + enum={"Microsoft.Storage/storageAccounts": "Microsoft.Storage/storageAccounts"}, + ) + + tag_keys_only = cls._args_schema.scopes.Element.tag_keys_only + tag_keys_only.Element = AAZStrArg() + + tags = cls._args_schema.scopes.Element.tags + tags.Element = AAZStrArg() + + workspace_roots = cls._args_schema.workspace_roots + workspace_roots.Element = AAZResourceIdArg() + + # 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() + self.StorageDiscoveryWorkspacesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 StorageDiscoveryWorkspacesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/{storageDiscoveryWorkspaceName}", + **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( + "storageDiscoveryWorkspaceName", self.ctx.args.storage_discovery_workspace_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("scopes", AAZListType, ".scopes", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("sku", AAZStrType, ".sku") + properties.set_prop("workspaceRoots", AAZListType, ".workspace_roots", typ_kwargs={"flags": {"required": True}}) + + scopes = _builder.get(".properties.scopes") + if scopes is not None: + scopes.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.scopes[]") + if _elements is not None: + _elements.set_prop("displayName", AAZStrType, ".display_name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("resourceTypes", AAZListType, ".resource_types", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("tagKeysOnly", AAZListType, ".tag_keys_only") + _elements.set_prop("tags", AAZDictType, ".tags") + + resource_types = _builder.get(".properties.scopes[].resourceTypes") + if resource_types is not None: + resource_types.set_elements(AAZStrType, ".") + + tag_keys_only = _builder.get(".properties.scopes[].tagKeysOnly") + if tag_keys_only is not None: + tag_keys_only.set_elements(AAZStrType, ".") + + tags = _builder.get(".properties.scopes[].tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + workspace_roots = _builder.get(".properties.workspaceRoots") + if workspace_roots is not None: + workspace_roots.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.description = AAZStrType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.sku = AAZStrType() + properties.workspace_roots = AAZListType( + serialized_name="workspaceRoots", + flags={"required": True}, + ) + + scopes = cls._schema_on_200_201.properties.scopes + scopes.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.scopes.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + _element.resource_types = AAZListType( + serialized_name="resourceTypes", + flags={"required": True}, + ) + _element.tag_keys_only = AAZListType( + serialized_name="tagKeysOnly", + ) + _element.tags = AAZDictType() + + resource_types = cls._schema_on_200_201.properties.scopes.Element.resource_types + resource_types.Element = AAZStrType() + + tag_keys_only = cls._schema_on_200_201.properties.scopes.Element.tag_keys_only + tag_keys_only.Element = AAZStrType() + + tags = cls._schema_on_200_201.properties.scopes.Element.tags + tags.Element = AAZStrType() + + workspace_roots = cls._schema_on_200_201.properties.workspace_roots + workspace_roots.Element = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_delete.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_delete.py new file mode 100644 index 00000000000..40a6be3b136 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_delete.py @@ -0,0 +1,145 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage-discovery workspace delete", + is_preview=True, + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a StorageDiscoveryWorkspace + + :example: Delete a StorageDiscoveryWorkspace + az storage-discovery workspace delete --resource-group myRG --name myWorkspace + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storagediscovery/storagediscoveryworkspaces/{}", "2025-06-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_discovery_workspace_name = AAZStrArg( + options=["-n", "--name", "--storage-discovery-workspace-name"], + help="The name of the StorageDiscoveryWorkspace", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*$", + max_length=64, + min_length=4, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageDiscoveryWorkspacesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class StorageDiscoveryWorkspacesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/{storageDiscoveryWorkspaceName}", + **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( + "storageDiscoveryWorkspaceName", self.ctx.args.storage_discovery_workspace_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_list.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_list.py new file mode 100644 index 00000000000..aa08bbc021d --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_list.py @@ -0,0 +1,430 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage-discovery workspace list", + is_preview=True, +) +class List(AAZCommand): + """List StorageDiscoveryWorkspace resources by subscription ID + + :example: List StorageDiscoveryWorkspaces by Subscription + az storage-discovery workspace list + az storage-discovery workspace list --resource-group myRG + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.storagediscovery/storagediscoveryworkspaces", "2025-06-01-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storagediscovery/storagediscoveryworkspaces", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + if condition_0: + self.StorageDiscoveryWorkspacesListBySubscription(ctx=self.ctx)() + if condition_1: + self.StorageDiscoveryWorkspacesListByResourceGroup(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 StorageDiscoveryWorkspacesListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.sku = AAZStrType() + properties.workspace_roots = AAZListType( + serialized_name="workspaceRoots", + flags={"required": True}, + ) + + scopes = cls._schema_on_200.value.Element.properties.scopes + scopes.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.scopes.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + _element.resource_types = AAZListType( + serialized_name="resourceTypes", + flags={"required": True}, + ) + _element.tag_keys_only = AAZListType( + serialized_name="tagKeysOnly", + ) + _element.tags = AAZDictType() + + resource_types = cls._schema_on_200.value.Element.properties.scopes.Element.resource_types + resource_types.Element = AAZStrType() + + tag_keys_only = cls._schema_on_200.value.Element.properties.scopes.Element.tag_keys_only + tag_keys_only.Element = AAZStrType() + + tags = cls._schema_on_200.value.Element.properties.scopes.Element.tags + tags.Element = AAZStrType() + + workspace_roots = cls._schema_on_200.value.Element.properties.workspace_roots + workspace_roots.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class StorageDiscoveryWorkspacesListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.StorageDiscovery/storageDiscoveryWorkspaces", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.sku = AAZStrType() + properties.workspace_roots = AAZListType( + serialized_name="workspaceRoots", + flags={"required": True}, + ) + + scopes = cls._schema_on_200.value.Element.properties.scopes + scopes.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.scopes.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + _element.resource_types = AAZListType( + serialized_name="resourceTypes", + flags={"required": True}, + ) + _element.tag_keys_only = AAZListType( + serialized_name="tagKeysOnly", + ) + _element.tags = AAZDictType() + + resource_types = cls._schema_on_200.value.Element.properties.scopes.Element.resource_types + resource_types.Element = AAZStrType() + + tag_keys_only = cls._schema_on_200.value.Element.properties.scopes.Element.tag_keys_only + tag_keys_only.Element = AAZStrType() + + tags = cls._schema_on_200.value.Element.properties.scopes.Element.tags + tags.Element = AAZStrType() + + workspace_roots = cls._schema_on_200.value.Element.properties.workspace_roots + workspace_roots.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_show.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_show.py new file mode 100644 index 00000000000..e3d9494b0a1 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_show.py @@ -0,0 +1,255 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage-discovery workspace show", + is_preview=True, +) +class Show(AAZCommand): + """Get a StorageDiscoveryWorkspace + + :example: Get a StorageDiscoveryWorkspace + az storage-discovery workspace show --resource-group myRG --name myWorkspace + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storagediscovery/storagediscoveryworkspaces/{}", "2025-06-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_discovery_workspace_name = AAZStrArg( + options=["-n", "--name", "--storage-discovery-workspace-name"], + help="The name of the StorageDiscoveryWorkspace", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*$", + max_length=64, + min_length=4, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageDiscoveryWorkspacesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def 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 StorageDiscoveryWorkspacesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.StorageDiscovery/storageDiscoveryWorkspaces/{storageDiscoveryWorkspaceName}", + **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( + "storageDiscoveryWorkspaceName", self.ctx.args.storage_discovery_workspace_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.sku = AAZStrType() + properties.workspace_roots = AAZListType( + serialized_name="workspaceRoots", + flags={"required": True}, + ) + + scopes = cls._schema_on_200.properties.scopes + scopes.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.scopes.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + _element.resource_types = AAZListType( + serialized_name="resourceTypes", + flags={"required": True}, + ) + _element.tag_keys_only = AAZListType( + serialized_name="tagKeysOnly", + ) + _element.tags = AAZDictType() + + resource_types = cls._schema_on_200.properties.scopes.Element.resource_types + resource_types.Element = AAZStrType() + + tag_keys_only = cls._schema_on_200.properties.scopes.Element.tag_keys_only + tag_keys_only.Element = AAZStrType() + + tags = cls._schema_on_200.properties.scopes.Element.tags + tags.Element = AAZStrType() + + workspace_roots = cls._schema_on_200.properties.workspace_roots + workspace_roots.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_update.py b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_update.py new file mode 100644 index 00000000000..bb7c20148b1 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/aaz/latest/storage_discovery/workspace/_update.py @@ -0,0 +1,545 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage-discovery workspace update", + is_preview=True, +) +class Update(AAZCommand): + """Update a StorageDiscoveryWorkspace + + :example: Update a StorageDiscoveryWorkspace + az storage-discovery workspace update --resource-group myRG --name myWorkspace --description "Updated description" --sku Free --scopes '[{"displayName":"updated","resourceTypes":["Microsoft.Storage/storageAccounts"],"tags":{"environment":"test"}}]' --tags environment=production team=storage + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storagediscovery/storagediscoveryworkspaces/{}", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_discovery_workspace_name = AAZStrArg( + options=["-n", "--name", "--storage-discovery-workspace-name"], + help="The name of the StorageDiscoveryWorkspace", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*$", + max_length=64, + min_length=4, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="The description of the storage discovery workspace", + nullable=True, + ) + _args_schema.scopes = AAZListArg( + options=["--scopes"], + arg_group="Properties", + help="The scopes of the storage discovery workspace.", + ) + _args_schema.sku = AAZStrArg( + options=["--sku"], + arg_group="Properties", + help="The storage discovery sku", + nullable=True, + enum={"Free": "Free", "Standard": "Standard"}, + ) + _args_schema.workspace_roots = AAZListArg( + options=["--workspace-roots"], + arg_group="Properties", + help="The view level storage discovery data estate", + ) + + scopes = cls._args_schema.scopes + scopes.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.scopes.Element + _element.display_name = AAZStrArg( + options=["display-name"], + help="Display name of the collection", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]+([ -][a-zA-Z0-9]+)*$", + max_length=64, + min_length=4, + ), + ) + _element.resource_types = AAZListArg( + options=["resource-types"], + help="Resource types for the collection", + ) + _element.tag_keys_only = AAZListArg( + options=["tag-keys-only"], + help="The storage account tags keys to filter", + nullable=True, + ) + _element.tags = AAZDictArg( + options=["tags"], + help="Resource tags.", + nullable=True, + ) + + resource_types = cls._args_schema.scopes.Element.resource_types + resource_types.Element = AAZStrArg( + nullable=True, + enum={"Microsoft.Storage/storageAccounts": "Microsoft.Storage/storageAccounts"}, + ) + + tag_keys_only = cls._args_schema.scopes.Element.tag_keys_only + tag_keys_only.Element = AAZStrArg( + nullable=True, + ) + + tags = cls._args_schema.scopes.Element.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + workspace_roots = cls._args_schema.workspace_roots + workspace_roots.Element = AAZResourceIdArg( + nullable=True, + ) + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageDiscoveryWorkspacesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.StorageDiscoveryWorkspacesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class StorageDiscoveryWorkspacesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_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.StorageDiscovery/storageDiscoveryWorkspaces/{storageDiscoveryWorkspaceName}", + **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( + "storageDiscoveryWorkspaceName", self.ctx.args.storage_discovery_workspace_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_storage_discovery_workspace_read(cls._schema_on_200) + + return cls._schema_on_200 + + class StorageDiscoveryWorkspacesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/{storageDiscoveryWorkspaceName}", + **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( + "storageDiscoveryWorkspaceName", self.ctx.args.storage_discovery_workspace_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_storage_discovery_workspace_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("scopes", AAZListType, ".scopes", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("sku", AAZStrType, ".sku") + properties.set_prop("workspaceRoots", AAZListType, ".workspace_roots", typ_kwargs={"flags": {"required": True}}) + + scopes = _builder.get(".properties.scopes") + if scopes is not None: + scopes.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.scopes[]") + if _elements is not None: + _elements.set_prop("displayName", AAZStrType, ".display_name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("resourceTypes", AAZListType, ".resource_types", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("tagKeysOnly", AAZListType, ".tag_keys_only") + _elements.set_prop("tags", AAZDictType, ".tags") + + resource_types = _builder.get(".properties.scopes[].resourceTypes") + if resource_types is not None: + resource_types.set_elements(AAZStrType, ".") + + tag_keys_only = _builder.get(".properties.scopes[].tagKeysOnly") + if tag_keys_only is not None: + tag_keys_only.set_elements(AAZStrType, ".") + + tags = _builder.get(".properties.scopes[].tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + workspace_roots = _builder.get(".properties.workspaceRoots") + if workspace_roots is not None: + workspace_roots.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_storage_discovery_workspace_read = None + + @classmethod + def _build_schema_storage_discovery_workspace_read(cls, _schema): + if cls._schema_storage_discovery_workspace_read is not None: + _schema.id = cls._schema_storage_discovery_workspace_read.id + _schema.location = cls._schema_storage_discovery_workspace_read.location + _schema.name = cls._schema_storage_discovery_workspace_read.name + _schema.properties = cls._schema_storage_discovery_workspace_read.properties + _schema.system_data = cls._schema_storage_discovery_workspace_read.system_data + _schema.tags = cls._schema_storage_discovery_workspace_read.tags + _schema.type = cls._schema_storage_discovery_workspace_read.type + return + + cls._schema_storage_discovery_workspace_read = _schema_storage_discovery_workspace_read = AAZObjectType() + + storage_discovery_workspace_read = _schema_storage_discovery_workspace_read + storage_discovery_workspace_read.id = AAZStrType( + flags={"read_only": True}, + ) + storage_discovery_workspace_read.location = AAZStrType( + flags={"required": True}, + ) + storage_discovery_workspace_read.name = AAZStrType( + flags={"read_only": True}, + ) + storage_discovery_workspace_read.properties = AAZObjectType() + storage_discovery_workspace_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + storage_discovery_workspace_read.tags = AAZDictType() + storage_discovery_workspace_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_storage_discovery_workspace_read.properties + properties.description = AAZStrType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.scopes = AAZListType( + flags={"required": True}, + ) + properties.sku = AAZStrType() + properties.workspace_roots = AAZListType( + serialized_name="workspaceRoots", + flags={"required": True}, + ) + + scopes = _schema_storage_discovery_workspace_read.properties.scopes + scopes.Element = AAZObjectType() + + _element = _schema_storage_discovery_workspace_read.properties.scopes.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + flags={"required": True}, + ) + _element.resource_types = AAZListType( + serialized_name="resourceTypes", + flags={"required": True}, + ) + _element.tag_keys_only = AAZListType( + serialized_name="tagKeysOnly", + ) + _element.tags = AAZDictType() + + resource_types = _schema_storage_discovery_workspace_read.properties.scopes.Element.resource_types + resource_types.Element = AAZStrType() + + tag_keys_only = _schema_storage_discovery_workspace_read.properties.scopes.Element.tag_keys_only + tag_keys_only.Element = AAZStrType() + + tags = _schema_storage_discovery_workspace_read.properties.scopes.Element.tags + tags.Element = AAZStrType() + + workspace_roots = _schema_storage_discovery_workspace_read.properties.workspace_roots + workspace_roots.Element = AAZStrType() + + system_data = _schema_storage_discovery_workspace_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_storage_discovery_workspace_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_storage_discovery_workspace_read.id + _schema.location = cls._schema_storage_discovery_workspace_read.location + _schema.name = cls._schema_storage_discovery_workspace_read.name + _schema.properties = cls._schema_storage_discovery_workspace_read.properties + _schema.system_data = cls._schema_storage_discovery_workspace_read.system_data + _schema.tags = cls._schema_storage_discovery_workspace_read.tags + _schema.type = cls._schema_storage_discovery_workspace_read.type + + +__all__ = ["Update"] diff --git a/src/storage-discovery/azext_storage_discovery/azext_metadata.json b/src/storage-discovery/azext_storage_discovery/azext_metadata.json new file mode 100644 index 00000000000..71889bb136b --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.75.0" +} \ No newline at end of file diff --git a/src/storage-discovery/azext_storage_discovery/commands.py b/src/storage-discovery/azext_storage_discovery/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/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/storage-discovery/azext_storage_discovery/custom.py b/src/storage-discovery/azext_storage_discovery/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/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/storage-discovery/azext_storage_discovery/tests/__init__.py b/src/storage-discovery/azext_storage_discovery/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/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/storage-discovery/azext_storage_discovery/tests/latest/__init__.py b/src/storage-discovery/azext_storage_discovery/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/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/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_create.yaml b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_create.yaml new file mode 100644 index 00000000000..e06bf4edf31 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_create.yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"location": "francecentral", "properties": {"description": "123", "scopes": + [{"displayName": "test1", "resourceTypes": ["Microsoft.Storage/storageAccounts"], + "tagKeysOnly": ["e2etest1"], "tags": {"tag1": "value1", "tag2": "value2"}}], + "sku": "Standard", "workspaceRoots": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace create + Connection: + - keep-alive + Content-Length: + - '362' + Content-Type: + - application/json + ParameterSetName: + - -g -n --location --description --sku --workspace-roots --scopes + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/clitest000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/clitest000002","name":"clitest000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"francecentral","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:29:28.1808107Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:29:28.1808107Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":"123","scopes":[{"displayName":"test1","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":["e2etest1"],"tags":{"tag1":"value1","tag2":"value2"}}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '881' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:30 GMT + etag: + - '"090059b8-0000-0e00-0000-689142590000"' + expires: + - '-1' + mise-correlation-id: + - fac33fd9-8aa1-4496-89b0-6af67af1888d + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/westus2/4e992be2-4596-4c39-95e1-97adf9548c55 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: AC03343244A64C4FB3B2828575B28EB1 Ref B: MWH011020806034 Ref C: 2025-08-04T23:29:23Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n -y + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/clitest000002?api-version=2025-06-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 04 Aug 2025 23:29:32 GMT + expires: + - '-1' + mise-correlation-id: + - acdfb41a-4273-454b-b469-7663f8488611 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/francecentral/eb34bd5a-f682-480d-826c-a928dd78a13c + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '799' + x-ms-ratelimit-remaining-subscription-global-deletes: + - '11999' + x-msedge-ref: + - 'Ref A: 310594CEBFF04E7B9C181863183270B8 Ref B: MWH011020806054 Ref C: 2025-08-04T23:29:30Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_delete.yaml b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_delete.yaml new file mode 100644 index 00000000000..888b1b3d38b --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_delete.yaml @@ -0,0 +1,220 @@ +interactions: +- request: + body: '{"location": "francecentral", "properties": {"scopes": [{"displayName": + "basic", "resourceTypes": ["Microsoft.Storage/storageAccounts"]}], "sku": "Standard", + "workspaceRoots": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace create + Connection: + - keep-alive + Content-Length: + - '265' + Content-Type: + - application/json + ParameterSetName: + - -g -n --location --workspace-roots --scopes + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/deletews000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/deletews000002","name":"deletews000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"francecentral","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:29:41.8247547Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:29:41.8247547Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":null,"scopes":[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":null,"tags":null}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '845' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:43 GMT + etag: + - '"090062b8-0000-0e00-0000-689142660000"' + expires: + - '-1' + mise-correlation-id: + - 748fe106-fb11-405a-ad5d-9a86f802d9aa + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/westus2/d2d6173c-ab66-4379-86e6-9e8896a65670 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: B33F382167A1452A8F8471132F9E9788 Ref B: CO6AA3150217029 Ref C: 2025-08-04T23:29:35Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace list + Connection: + - keep-alive + ParameterSetName: + - -g + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces?api-version=2025-06-01-preview + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/deletews000002","name":"deletews000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"francecentral","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:29:41.8247547Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:29:41.8247547Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"scopes":[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"]}],"provisioningState":"Succeeded"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '807' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:43 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-original-request-ids: + - 5f3c8c89-0910-4842-88ed-ee88de715b9a + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 56CE892D385848CB861266251F93CBD8 Ref B: MWH011020808040 Ref C: 2025-08-04T23:29:43Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n -y + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/deletews000002?api-version=2025-06-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 04 Aug 2025 23:29:45 GMT + expires: + - '-1' + mise-correlation-id: + - 552b9331-ee56-4859-91a0-9c289a747489 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/francecentral/db7d9842-9526-4bb7-98f3-e870a607b64a + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '799' + x-ms-ratelimit-remaining-subscription-global-deletes: + - '11999' + x-msedge-ref: + - 'Ref A: C7CEB4F880B14271AE4B0550DB827BF3 Ref B: MWH011020806034 Ref C: 2025-08-04T23:29:44Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace list + Connection: + - keep-alive + ParameterSetName: + - -g + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces?api-version=2025-06-01-preview + response: + body: + string: '{"value":[]}' + headers: + cache-control: + - no-cache + content-length: + - '12' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:46 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 30DD03447EA1481D915F67BE2AF24EB8 Ref B: MWH011020806054 Ref C: 2025-08-04T23:29:45Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_list.yaml b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_list.yaml new file mode 100644 index 00000000000..5b18aa11db6 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_list.yaml @@ -0,0 +1,46 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces?api-version=2025-06-01-preview + response: + body: + string: '{"value":[]}' + headers: + cache-control: + - no-cache + content-length: + - '12' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:50 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: F664E3FFDE704CD8A2323D2980414ED8 Ref B: MWH011020807023 Ref C: 2025-08-04T23:29:50Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_show.yaml b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_show.yaml new file mode 100644 index 00000000000..3becfa3cf7b --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_show.yaml @@ -0,0 +1,291 @@ +interactions: +- request: + body: '{"location": "francecentral", "properties": {"scopes": [{"displayName": + "basic", "resourceTypes": ["Microsoft.Storage/storageAccounts"]}], "sku": "Standard", + "workspaceRoots": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace create + Connection: + - keep-alive + Content-Length: + - '265' + Content-Type: + - application/json + ParameterSetName: + - -g -n --location --workspace-roots --scopes + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002","name":"sdworkspace000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"francecentral","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:29:54.6494315Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:29:54.6494315Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":null,"scopes":[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":null,"tags":null}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '851' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:56 GMT + etag: + - '"09006bb8-0000-0e00-0000-689142730000"' + expires: + - '-1' + mise-correlation-id: + - b72d91a8-185b-466c-8c91-78fbf003c95d + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/eastus/02aa6289-e7c8-4130-bfb5-2df9ce33a101 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: B385D508333E4FD3B3D3E13DF52C4220 Ref B: CO6AA3150220039 Ref C: 2025-08-04T23:29:52Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace show + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002","name":"sdworkspace000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"francecentral","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:29:54.6494315Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:29:54.6494315Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":null,"scopes":[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":null,"tags":null}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '851' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:55 GMT + etag: + - '"09006bb8-0000-0e00-0000-689142730000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 06796561D4BE45AFABC6791B58279A0F Ref B: MWH011020808040 Ref C: 2025-08-04T23:29:56Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace update + Connection: + - keep-alive + ParameterSetName: + - -g -n --tags + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002","name":"sdworkspace000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"francecentral","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:29:54.6494315Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:29:54.6494315Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":null,"scopes":[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":null,"tags":null}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '851' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:56 GMT + etag: + - '"09006bb8-0000-0e00-0000-689142730000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 74A0503C09744CA2B3909A5F3EE0D321 Ref B: MWH011020806034 Ref C: 2025-08-04T23:29:56Z' + status: + code: 200 + message: OK +- request: + body: '{"location": "francecentral", "properties": {"scopes": [{"displayName": + "basic", "resourceTypes": ["Microsoft.Storage/storageAccounts"]}], "sku": "Standard", + "workspaceRoots": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"]}, + "tags": {"team": "Discovery", "environment": "test", "purpose": "demo"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace update + Connection: + - keep-alive + Content-Length: + - '338' + Content-Type: + - application/json + ParameterSetName: + - -g -n --tags + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002","name":"sdworkspace000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"francecentral","tags":{"team":"Discovery","environment":"test","purpose":"demo"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:29:54.6494315Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:29:57.4392952Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":null,"scopes":[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":null,"tags":null}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '889' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:29:57 GMT + etag: + - '"09006db8-0000-0e00-0000-689142750000"' + expires: + - '-1' + mise-correlation-id: + - af47ee19-128e-466d-91cd-f1465729fca4 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/francecentral/75920b46-4ad2-4883-a5e6-a206214578e8 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 899958593F714EDFAF8564814EDECB2B Ref B: MWH011020806054 Ref C: 2025-08-04T23:29:57Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n -y + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/sdworkspace000002?api-version=2025-06-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 04 Aug 2025 23:30:02 GMT + expires: + - '-1' + mise-correlation-id: + - 8229b5f0-4a68-443b-9b51-ac0d57a03832 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/westus2/fc97b20c-b512-4db5-9fc5-86f717bfa127 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '799' + x-ms-ratelimit-remaining-subscription-global-deletes: + - '11999' + x-msedge-ref: + - 'Ref A: 0A7DE7E6BC4F4DCAA2042FFCF198FFC7 Ref B: MWH011020808062 Ref C: 2025-08-04T23:29:58Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_update.yaml b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_update.yaml new file mode 100644 index 00000000000..0f6f9266030 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/tests/latest/recordings/test_storage_discovery_workspace_update.yaml @@ -0,0 +1,242 @@ +interactions: +- request: + body: '{"location": "eastus2", "properties": {"description": "initial", "scopes": + [{"displayName": "test1", "resourceTypes": ["Microsoft.Storage/storageAccounts"]}], + "sku": "Standard", "workspaceRoots": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace create + Connection: + - keep-alive + Content-Length: + - '285' + Content-Type: + - application/json + ParameterSetName: + - -g -n --location --description --sku --workspace-roots --scopes + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/updatews000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/updatews000002","name":"updatews000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"eastus2","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:30:11.6266581Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:30:11.6266581Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":"initial","scopes":[{"displayName":"test1","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":null,"tags":null}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '844' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:30:12 GMT + etag: + - '"58009008-0000-0200-0000-689142840000"' + expires: + - '-1' + mise-correlation-id: + - 92f4c0d4-cef9-4975-9d6e-c2372e903ba2 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/francecentral/7aa65700-31aa-4efc-84fc-8008e43ad790 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 9089F56B6AC54BA5AAE602995780D0CE Ref B: MWH011020807023 Ref C: 2025-08-04T23:30:07Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace update + Connection: + - keep-alive + ParameterSetName: + - -g -n --description --sku --scopes --tags + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/updatews000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/updatews000002","name":"updatews000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"eastus2","tags":{"team":"Discovery"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:30:11.6266581Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:30:11.6266581Z"},"properties":{"sku":"Standard","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":"initial","scopes":[{"displayName":"test1","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":null,"tags":null}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '844' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:30:12 GMT + etag: + - '"58009008-0000-0200-0000-689142840000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 5E181EC47A6E4D8AB377299AAFD2EB97 Ref B: MWH011020808040 Ref C: 2025-08-04T23:30:13Z' + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2", "properties": {"description": "test2", "scopes": + [{"displayName": "test2", "resourceTypes": ["Microsoft.Storage/storageAccounts"], + "tagKeysOnly": ["e2etest2"], "tags": {"tag3": "value3"}}], "sku": "Free", "workspaceRoots": + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"]}, + "tags": {"team": "Discovery", "tag4": "value4"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace update + Connection: + - keep-alive + Content-Length: + - '385' + Content-Type: + - application/json + ParameterSetName: + - -g -n --description --sku --scopes --tags + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/updatews000002?api-version=2025-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/updatews000002","name":"updatews000002","type":"microsoft.storagediscovery/storagediscoveryworkspaces","location":"eastus2","tags":{"team":"Discovery","tag4":"value4"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-08-04T23:30:11.6266581Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-08-04T23:30:15.0798664Z"},"properties":{"sku":"Free","workspaceRoots":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001"],"description":"test2","scopes":[{"displayName":"test2","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":["e2etest2"],"tags":{"tag3":"value3"}}],"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '875' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 04 Aug 2025 23:30:16 GMT + etag: + - '"5800da08-0000-0200-0000-689142880000"' + expires: + - '-1' + mise-correlation-id: + - 6b808c42-905f-4413-be6c-5c1903655569 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/francecentral/8f2427a1-c296-4b84-85d2-fb9f2d2c4ba4 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 5DD30D9CB71042BA82DA13177A014CAD Ref B: MWH011020806034 Ref C: 2025-08-04T23:30:13Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - storage-discovery workspace delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n -y + User-Agent: + - AZURECLI/2.75.0 azsdk-python-core/1.35.0 Python/3.12.11 (Linux-6.8.0-1030-azure-x86_64-with-glibc2.36) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.StorageDiscovery/storageDiscoveryWorkspaces/updatews000002?api-version=2025-06-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 04 Aug 2025 23:30:21 GMT + expires: + - '-1' + mise-correlation-id: + - b7cc6ad7-94e4-4e51-a2b2-0175e3b61635 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=2968a26f-a796-4124-8684-894f8a239db2/francecentral/2d7e8b65-3881-43c9-9d81-ddff7091116c + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '799' + x-ms-ratelimit-remaining-subscription-global-deletes: + - '11999' + x-msedge-ref: + - 'Ref A: DC545F3002364484B83808C00634EFE5 Ref B: MWH011020806054 Ref C: 2025-08-04T23:30:17Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/storage-discovery/azext_storage_discovery/tests/latest/test_storage_discovery.py b/src/storage-discovery/azext_storage_discovery/tests/latest/test_storage_discovery.py new file mode 100644 index 00000000000..522cc3aba66 --- /dev/null +++ b/src/storage-discovery/azext_storage_discovery/tests/latest/test_storage_discovery.py @@ -0,0 +1,153 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * + + +class StorageDiscoveryScenario(ScenarioTest): + @ResourceGroupPreparer(location='francecentral') + def test_storage_discovery_workspace_create(self): + self.kwargs.update({ + "workspace_name": self.create_random_name('clitest', 18), + "discovery_scope_level1": f"/subscriptions/{self.get_subscription_id()}/resourceGroups/{self.kwargs['rg']}" + }) + + # Test create workspace with scope file + self.kwargs.update({ + "scope1_json": '[{"displayName":"test1","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":["e2etest1"],"tags":{"tag1":"value1","tag2":"value2"}}]' + }) + + # Create workspace + self.cmd('az storage-discovery workspace create ' + '-g {rg} -n {workspace_name} --location francecentral ' + '--description "123" --sku Standard ' + '--workspace-roots "{discovery_scope_level1}" ' + '--scopes "{scope1_json}"', + checks=[ + JMESPathCheck('name', self.kwargs.get('workspace_name', '')), + JMESPathCheck('location', "francecentral"), + JMESPathCheck('properties.description', "123"), + JMESPathCheck('properties.sku', "Standard"), + JMESPathCheck('properties.workspaceRoots[0]', self.kwargs.get('discovery_scope_level1', '')), + JMESPathCheck('properties.scopes[0].displayName', "test1"), + JMESPathCheck('properties.scopes[0].resourceTypes[0]', "Microsoft.Storage/storageAccounts"), + JMESPathCheck('properties.scopes[0].tagKeysOnly[0]', "e2etest1"), + JMESPathCheck('properties.scopes[0].tags.tag1', "value1"), + JMESPathCheck('properties.scopes[0].tags.tag2', "value2") + ]) + + # Clean up + self.cmd('az storage-discovery workspace delete -g {rg} -n {workspace_name} -y') + + @ResourceGroupPreparer(location='eastus2') + def test_storage_discovery_workspace_update(self): + self.kwargs.update({ + "workspace_name": self.create_random_name('updatews', 18), + "discovery_scope_level1": f"/subscriptions/{self.get_subscription_id()}/resourceGroups/{self.kwargs['rg']}" + }) + + # Create initial workspace + self.kwargs.update({ + "scope1_json": '[{"displayName":"test1","resourceTypes":["Microsoft.Storage/storageAccounts"]}]' + }) + + self.cmd('az storage-discovery workspace create ' + '-g {rg} -n {workspace_name} --location eastus2 ' + '--description "initial" --sku Standard ' + '--workspace-roots "{discovery_scope_level1}" ' + '--scopes "{scope1_json}"') + + # Test update workspace + self.kwargs.update({ + "scope2_json": '[{"displayName":"test2","resourceTypes":["Microsoft.Storage/storageAccounts"],"tagKeysOnly":["e2etest2"],"tags":{"tag3":"value3"}}]' + }) + + self.cmd('az storage-discovery workspace update ' + '-g {rg} -n {workspace_name} ' + '--description "test2" --sku Free ' + '--scopes "{scope2_json}" ' + '--tags tag4=value4', + checks=[ + JMESPathCheck('properties.description', "test2"), + JMESPathCheck('properties.sku', "Free"), + JMESPathCheck('properties.workspaceRoots[0]', self.kwargs.get('discovery_scope_level1', '')), + JMESPathCheck('properties.scopes[0].displayName', "test2"), + JMESPathCheck('properties.scopes[0].tagKeysOnly[0]', "e2etest2"), + JMESPathCheck('properties.scopes[0].tags.tag3', "value3"), + JMESPathCheck('tags.tag4', "value4") + ]) + + # Clean up + self.cmd('az storage-discovery workspace delete -g {rg} -n {workspace_name} -y') + + @ResourceGroupPreparer(location='francecentral') + def test_storage_discovery_workspace_delete(self): + self.kwargs.update({ + "workspace_name": self.create_random_name('deletews', 18), + "workspace_scope": f"/subscriptions/{self.get_subscription_id()}/resourceGroups/{self.kwargs['rg']}", + "basic_scope_json": '[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"]}]' + }) + + # Create workspace + self.cmd('az storage-discovery workspace create ' + '-g {rg} -n {workspace_name} --location francecentral ' + '--workspace-roots "{workspace_scope}" ' + '--scopes "{basic_scope_json}"') + + # Verify workspace exists + self.cmd('az storage-discovery workspace list -g {rg}', + checks=[JMESPathCheck('length(@)', 1)]) + + # Test delete workspace + self.cmd('az storage-discovery workspace delete -g {rg} -n {workspace_name} -y') + + # Verify workspace is deleted + self.cmd('az storage-discovery workspace list -g {rg}', + checks=[JMESPathCheck('length(@)', 0)]) + + @ResourceGroupPreparer(location='francecentral') + def test_storage_discovery_workspace_show(self): + self.kwargs.update({ + "workspace_name": self.create_random_name('sdworkspace', 18), + "workspace_scope": f"/subscriptions/{self.get_subscription_id()}/resourceGroups/{self.kwargs['rg']}", + "basic_scope_json": '[{"displayName":"basic","resourceTypes":["Microsoft.Storage/storageAccounts"]}]' + }) + + # Test create workspace with minimal parameters but required scopes + self.cmd('az storage-discovery workspace create ' + '-g {rg} -n {workspace_name} --location francecentral ' + '--workspace-roots "{workspace_scope}" ' + '--scopes "{basic_scope_json}"', + checks=[ + JMESPathCheck('name', self.kwargs.get('workspace_name', '')), + JMESPathCheck('location', "francecentral"), + JMESPathCheck('properties.workspaceRoots[0]', self.kwargs.get('workspace_scope', '')) + ]) + + # Test show workspace + self.cmd('az storage-discovery workspace show -g {rg} -n {workspace_name}', + checks=[ + JMESPathCheck('name', self.kwargs.get('workspace_name', '')), + JMESPathCheck('location', "francecentral") + ]) + + # Test update workspace with tags only + self.cmd('az storage-discovery workspace update ' + '-g {rg} -n {workspace_name} ' + '--tags environment=test purpose=demo', + checks=[ + JMESPathCheck('tags.environment', "test"), + JMESPathCheck('tags.purpose', "demo") + ]) + + # Clean up + self.cmd('az storage-discovery workspace delete -g {rg} -n {workspace_name} -y') + + def test_storage_discovery_workspace_list(self): + # Test list workspaces from subscription (may be empty) + result = self.cmd('az storage-discovery workspace list').get_output_in_json() + self.assertIsInstance(result, list) diff --git a/src/storage-discovery/setup.cfg b/src/storage-discovery/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/storage-discovery/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/storage-discovery/setup.py b/src/storage-discovery/setup.py new file mode 100644 index 00000000000..e70c4562930 --- /dev/null +++ b/src/storage-discovery/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='storage-discovery', + version=VERSION, + description='Microsoft Azure Command-Line Tools StorageDiscovery 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/storage-discovery', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_storage_discovery': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +)