diff --git a/src/file-share/HISTORY.rst b/src/file-share/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/file-share/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/file-share/README.md b/src/file-share/README.md new file mode 100644 index 00000000000..46a5102fd08 --- /dev/null +++ b/src/file-share/README.md @@ -0,0 +1,5 @@ +# Azure CLI FileShare Extension # +This is an extension to Azure CLI to manage FileShare resources. + +## How to use ## +Please add commands usage here. \ No newline at end of file diff --git a/src/file-share/azext_file_share/__init__.py b/src/file-share/azext_file_share/__init__.py new file mode 100644 index 00000000000..d754c29b424 --- /dev/null +++ b/src/file-share/azext_file_share/__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_file_share._help import helps # pylint: disable=unused-import + + +class FileShareCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_file_share.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_file_share.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_file_share._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = FileShareCommandsLoader diff --git a/src/file-share/azext_file_share/_help.py b/src/file-share/azext_file_share/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/file-share/azext_file_share/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/file-share/azext_file_share/_params.py b/src/file-share/azext_file_share/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/file-share/azext_file_share/_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/file-share/azext_file_share/aaz/__init__.py b/src/file-share/azext_file_share/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/file-share/azext_file_share/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/file-share/azext_file_share/aaz/latest/__init__.py b/src/file-share/azext_file_share/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/file-share/azext_file_share/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/file-share/azext_file_share/aaz/latest/file_share/__cmd_group.py b/src/file-share/azext_file_share/aaz/latest/file_share/__cmd_group.py new file mode 100644 index 00000000000..974db111351 --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/__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( + "file-share", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage File Share + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/__init__.py b/src/file-share/azext_file_share/aaz/latest/file_share/__init__.py new file mode 100644 index 00000000000..9556f9d83dd --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/__init__.py @@ -0,0 +1,21 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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 ._check_name_availability import * +from ._create import * +from ._delete import * +from ._get_limit import * +from ._get_provisioning_recommendation import * +from ._get_usage_data import * +from ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_check_name_availability.py b/src/file-share/azext_file_share/aaz/latest/file_share/_check_name_availability.py new file mode 100644 index 00000000000..0cb60ddd9c4 --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_check_name_availability.py @@ -0,0 +1,190 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "file-share check-name-availability", + is_preview=True, +) +class CheckNameAvailability(AAZCommand): + """Implements local CheckNameAvailability operations + + :example: Check Name Availability for File Shares + az file-share check-name-availability --location dpplbglogsvzrbbeo --name fvykqbgmd --type kcyswj + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.fileshares/locations/{}/checknameavailability", "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.location = AAZResourceLocationArg( + required=True, + id_part="name", + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["--name"], + arg_group="Body", + help="The name of the resource for which availability needs to be checked.", + ) + _args_schema.type = AAZStrArg( + options=["--type"], + arg_group="Body", + help="The resource type.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileSharesCheckNameAvailability(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 FileSharesCheckNameAvailability(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.FileShares/locations/{location}/checkNameAvailability", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + 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("name", AAZStrType, ".name") + _builder.set_prop("type", AAZStrType, ".type") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.message = AAZStrType() + _schema_on_200.name_available = AAZBoolType( + serialized_name="nameAvailable", + ) + _schema_on_200.reason = AAZStrType() + + return cls._schema_on_200 + + +class _CheckNameAvailabilityHelper: + """Helper class for CheckNameAvailability""" + + +__all__ = ["CheckNameAvailability"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_create.py b/src/file-share/azext_file_share/aaz/latest/file_share/_create.py new file mode 100644 index 00000000000..0751dd54fb3 --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_create.py @@ -0,0 +1,516 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share create", + is_preview=True, +) +class Create(AAZCommand): + """Create a file share. + + :example: Create a File Share + az file-share create --resource-group rgfileshares --resource-name fileshare --mount-name fileshare --media-tier SSD --redundancy Local --protocol NFS --provisioned-storage-gib 8 --provisioned-io-per-sec 5 --provisioned-throughput-mib-per-sec 22 --nfs-protocol-properties "{root-squash:NoRootSquash}" --public-access-properties "{allowed-subnets:[/subscriptions/9760acf5-4638-11e7-9bdb-020073ca7778/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3]}" --public-network-access Enabled --tags "{key9647:xwokdvyoae}" --location gdsuixfhrgfbbbfjtgocmlzyuonrr + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.media_tier = AAZStrArg( + options=["--media-tier"], + arg_group="Properties", + help="The storage media tier of the file share.", + enum={"SSD": "SSD"}, + ) + _args_schema.mount_name = AAZStrArg( + options=["--mount-name"], + arg_group="Properties", + help="The name of the file share as seen by the end user when mounting the share, such as in a URI or UNC format in their operating system.", + ) + _args_schema.nfs_protocol_properties = AAZObjectArg( + options=["--nfs-protocol-properties"], + arg_group="Properties", + help="Protocol settings specific NFS.", + ) + _args_schema.protocol = AAZStrArg( + options=["--protocol"], + arg_group="Properties", + help="The file sharing protocol for this file share.", + enum={"NFS": "NFS"}, + ) + _args_schema.provisioned_io_per_sec = AAZIntArg( + options=["--provisioned-io-per-sec"], + arg_group="Properties", + help="The provisioned IO / sec of the share.", + ) + _args_schema.provisioned_storage_gib = AAZIntArg( + options=["--provisioned-storage-gib"], + arg_group="Properties", + help="The provisioned storage size of the share in GiB (1 GiB is 1024^3 bytes or 1073741824 bytes). A component of the file share's bill is the provisioned storage, regardless of the amount of used storage.", + ) + _args_schema.provisioned_throughput_mib_per_sec = AAZIntArg( + options=["--provisioned-throughput-mib-per-sec"], + arg_group="Properties", + help="The provisioned throughput / sec of the share.", + ) + _args_schema.public_access_properties = AAZObjectArg( + options=["--public-access-properties"], + arg_group="Properties", + help="The set of properties for control public access.", + ) + _args_schema.public_network_access = AAZStrArg( + options=["--public-network-access"], + arg_group="Properties", + help="Gets or sets allow or disallow public network access to azure managed file share", + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + _args_schema.redundancy = AAZStrArg( + options=["--redundancy"], + arg_group="Properties", + help="The chosen redundancy level of the file share.", + enum={"Local": "Local", "Zone": "Zone"}, + ) + + nfs_protocol_properties = cls._args_schema.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrArg( + options=["root-squash"], + help="Root squash defines how root users on clients are mapped to the NFS share.", + enum={"AllSquash": "AllSquash", "NoRootSquash": "NoRootSquash", "RootSquash": "RootSquash"}, + ) + + public_access_properties = cls._args_schema.public_access_properties + public_access_properties.allowed_subnets = AAZListArg( + options=["allowed-subnets"], + help="The allowed set of subnets when access is restricted.", + ) + + allowed_subnets = cls._args_schema.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrArg() + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Resource", + help="The geo-location where the resource lives", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.FileSharesCreateOrUpdate(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 FileSharesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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("mediaTier", AAZStrType, ".media_tier") + properties.set_prop("mountName", AAZStrType, ".mount_name") + properties.set_prop("nfsProtocolProperties", AAZObjectType, ".nfs_protocol_properties") + properties.set_prop("protocol", AAZStrType, ".protocol") + properties.set_prop("provisionedIOPerSec", AAZIntType, ".provisioned_io_per_sec") + properties.set_prop("provisionedStorageGiB", AAZIntType, ".provisioned_storage_gib") + properties.set_prop("provisionedThroughputMiBPerSec", AAZIntType, ".provisioned_throughput_mib_per_sec") + properties.set_prop("publicAccessProperties", AAZObjectType, ".public_access_properties") + properties.set_prop("publicNetworkAccess", AAZStrType, ".public_network_access") + properties.set_prop("redundancy", AAZStrType, ".redundancy") + + nfs_protocol_properties = _builder.get(".properties.nfsProtocolProperties") + if nfs_protocol_properties is not None: + nfs_protocol_properties.set_prop("rootSquash", AAZStrType, ".root_squash") + + public_access_properties = _builder.get(".properties.publicAccessProperties") + if public_access_properties is not None: + public_access_properties.set_prop("allowedSubnets", AAZListType, ".allowed_subnets") + + allowed_subnets = _builder.get(".properties.publicAccessProperties.allowedSubnets") + if allowed_subnets is not None: + allowed_subnets.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}, + ) + _CreateHelper._build_schema_system_data_read(_schema_on_200_201.system_data) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.host_name = AAZStrType( + serialized_name="hostName", + flags={"read_only": True}, + ) + properties.included_burst_io_per_sec = AAZIntType( + serialized_name="includedBurstIOPerSec", + flags={"read_only": True}, + ) + properties.max_burst_io_per_sec_credits = AAZIntType( + serialized_name="maxBurstIOPerSecCredits", + flags={"read_only": True}, + ) + properties.media_tier = AAZStrType( + serialized_name="mediaTier", + ) + properties.mount_name = AAZStrType( + serialized_name="mountName", + ) + properties.nfs_protocol_properties = AAZObjectType( + serialized_name="nfsProtocolProperties", + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.protocol = AAZStrType() + properties.provisioned_io_per_sec = AAZIntType( + serialized_name="provisionedIOPerSec", + ) + properties.provisioned_io_per_sec_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedIOPerSecNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_storage_gi_b = AAZIntType( + serialized_name="provisionedStorageGiB", + ) + properties.provisioned_storage_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedStorageNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="provisionedThroughputMiBPerSec", + ) + properties.provisioned_throughput_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedThroughputNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_access_properties = AAZObjectType( + serialized_name="publicAccessProperties", + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.redundancy = AAZStrType() + + nfs_protocol_properties = cls._schema_on_200_201.properties.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrType( + serialized_name="rootSquash", + ) + + private_endpoint_connections = cls._schema_on_200_201.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.private_endpoint_connections.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _CreateHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + public_access_properties = cls._schema_on_200_201.properties.public_access_properties + public_access_properties.allowed_subnets = AAZListType( + serialized_name="allowedSubnets", + ) + + allowed_subnets = cls._schema_on_200_201.properties.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrType() + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Create"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_delete.py b/src/file-share/azext_file_share/aaz/latest/file_share/_delete.py new file mode 100644 index 00000000000..9ef2ed1605e --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_delete.py @@ -0,0 +1,167 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share delete", + is_preview=True, + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a FileShare + + :example: Delete a File Share + az file-share delete --resource-group rgfileshares --resource-name fileshare + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.FileSharesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class FileSharesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}", + **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( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_get_limit.py b/src/file-share/azext_file_share/aaz/latest/file_share/_get_limit.py new file mode 100644 index 00000000000..19707d07edb --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_get_limit.py @@ -0,0 +1,228 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share get-limit", + is_preview=True, +) +class GetLimit(AAZCommand): + """Get file shares limits. + + :example: File Share Get Limits + az file-share get-limit --location dpplbglogsvzrbbeo + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.fileshares/locations/{}/getlimits", "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.location = AAZResourceLocationArg( + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileShareGetLimits(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 FileShareGetLimits(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.FileShares/locations/{location}/getLimits", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + 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.properties = AAZObjectType( + flags={"required": True}, + ) + + properties = cls._schema_on_200.properties + properties.limits = AAZObjectType( + flags={"required": True}, + ) + properties.provisioning_constants = AAZObjectType( + serialized_name="provisioningConstants", + flags={"required": True}, + ) + + limits = cls._schema_on_200.properties.limits + limits.max_file_share_private_endpoint_connections = AAZIntType( + serialized_name="maxFileSharePrivateEndpointConnections", + flags={"required": True}, + ) + limits.max_file_share_snapshots = AAZIntType( + serialized_name="maxFileShareSnapshots", + flags={"required": True}, + ) + limits.max_file_share_subnets = AAZIntType( + serialized_name="maxFileShareSubnets", + flags={"required": True}, + ) + limits.max_file_shares = AAZIntType( + serialized_name="maxFileShares", + flags={"required": True}, + ) + limits.max_provisioned_io_per_sec = AAZIntType( + serialized_name="maxProvisionedIOPerSec", + flags={"required": True}, + ) + limits.max_provisioned_storage_gi_b = AAZIntType( + serialized_name="maxProvisionedStorageGiB", + flags={"required": True}, + ) + limits.max_provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="maxProvisionedThroughputMiBPerSec", + flags={"required": True}, + ) + limits.min_provisioned_io_per_sec = AAZIntType( + serialized_name="minProvisionedIOPerSec", + flags={"required": True}, + ) + limits.min_provisioned_storage_gi_b = AAZIntType( + serialized_name="minProvisionedStorageGiB", + flags={"required": True}, + ) + limits.min_provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="minProvisionedThroughputMiBPerSec", + flags={"required": True}, + ) + + provisioning_constants = cls._schema_on_200.properties.provisioning_constants + provisioning_constants.base_io_per_sec = AAZIntType( + serialized_name="baseIOPerSec", + flags={"required": True}, + ) + provisioning_constants.base_throughput_mi_b_per_sec = AAZIntType( + serialized_name="baseThroughputMiBPerSec", + flags={"required": True}, + ) + provisioning_constants.scalar_io_per_sec = AAZFloatType( + serialized_name="scalarIOPerSec", + flags={"required": True}, + ) + provisioning_constants.scalar_throughput_mi_b_per_sec = AAZFloatType( + serialized_name="scalarThroughputMiBPerSec", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _GetLimitHelper: + """Helper class for GetLimit""" + + +__all__ = ["GetLimit"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_get_provisioning_recommendation.py b/src/file-share/azext_file_share/aaz/latest/file_share/_get_provisioning_recommendation.py new file mode 100644 index 00000000000..380cda1e77f --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_get_provisioning_recommendation.py @@ -0,0 +1,204 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share get-provisioning-recommendation", + is_preview=True, +) +class GetProvisioningRecommendation(AAZCommand): + """Get file shares provisioning parameters recommendation. + + :example: File Share Get Provisioning Recommendation + az file-share get-provisioning-recommendation --location dpplbglogsvzrbbeo --provisioned-storage-gib 7 + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.fileshares/locations/{}/getprovisioningrecommendation", "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.location = AAZResourceLocationArg( + required=True, + id_part="name", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.provisioned_storage_gib = AAZIntArg( + options=["--provisioned-storage-gib"], + arg_group="Properties", + help="The desired provisioned storage size of the share in GiB. Will be use to calculate the values of remaining provisioning parameters.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileShareGetProvisioningRecommendation(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 FileShareGetProvisioningRecommendation(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.FileShares/locations/{location}/getProvisioningRecommendation", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + 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("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("provisionedStorageGiB", AAZIntType, ".provisioned_storage_gib", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType( + flags={"required": True}, + ) + + properties = cls._schema_on_200.properties + properties.available_redundancy_options = AAZListType( + serialized_name="availableRedundancyOptions", + flags={"required": True}, + ) + properties.provisioned_io_per_sec = AAZIntType( + serialized_name="provisionedIOPerSec", + flags={"required": True}, + ) + properties.provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="provisionedThroughputMiBPerSec", + flags={"required": True}, + ) + + available_redundancy_options = cls._schema_on_200.properties.available_redundancy_options + available_redundancy_options.Element = AAZStrType() + + return cls._schema_on_200 + + +class _GetProvisioningRecommendationHelper: + """Helper class for GetProvisioningRecommendation""" + + +__all__ = ["GetProvisioningRecommendation"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_get_usage_data.py b/src/file-share/azext_file_share/aaz/latest/file_share/_get_usage_data.py new file mode 100644 index 00000000000..26ab766b6ad --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_get_usage_data.py @@ -0,0 +1,171 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share get-usage-data", + is_preview=True, +) +class GetUsageData(AAZCommand): + """Get file shares usage data. + + :example: File Share Get Usage Data + az file-share get-usage-data --location dpplbglogsvzrbbeo + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.fileshares/locations/{}/getusagedata", "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.location = AAZResourceLocationArg( + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileShareGetUsageData(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 FileShareGetUsageData(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.FileShares/locations/{location}/getUsageData", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + 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.properties = AAZObjectType( + flags={"required": True}, + ) + + properties = cls._schema_on_200.properties + properties.live_shares = AAZObjectType( + serialized_name="liveShares", + flags={"required": True}, + ) + + live_shares = cls._schema_on_200.properties.live_shares + live_shares.file_share_count = AAZIntType( + serialized_name="fileShareCount", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _GetUsageDataHelper: + """Helper class for GetUsageData""" + + +__all__ = ["GetUsageData"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_list.py b/src/file-share/azext_file_share/aaz/latest/file_share/_list.py new file mode 100644 index 00000000000..b7ce0f30a9e --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_list.py @@ -0,0 +1,601 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share list", + is_preview=True, +) +class List(AAZCommand): + """List FileShare resources by subscription ID + + :example: List a File Share + az file-share list -g resourcegroup1 + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.fileshares/fileshares", "2025-06-01-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares", "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.FileSharesListBySubscription(ctx=self.ctx)() + if condition_1: + self.FileSharesListByParent(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 FileSharesListBySubscription(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.FileShares/fileShares", + **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}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.host_name = AAZStrType( + serialized_name="hostName", + flags={"read_only": True}, + ) + properties.included_burst_io_per_sec = AAZIntType( + serialized_name="includedBurstIOPerSec", + flags={"read_only": True}, + ) + properties.max_burst_io_per_sec_credits = AAZIntType( + serialized_name="maxBurstIOPerSecCredits", + flags={"read_only": True}, + ) + properties.media_tier = AAZStrType( + serialized_name="mediaTier", + ) + properties.mount_name = AAZStrType( + serialized_name="mountName", + ) + properties.nfs_protocol_properties = AAZObjectType( + serialized_name="nfsProtocolProperties", + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.protocol = AAZStrType() + properties.provisioned_io_per_sec = AAZIntType( + serialized_name="provisionedIOPerSec", + ) + properties.provisioned_io_per_sec_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedIOPerSecNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_storage_gi_b = AAZIntType( + serialized_name="provisionedStorageGiB", + ) + properties.provisioned_storage_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedStorageNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="provisionedThroughputMiBPerSec", + ) + properties.provisioned_throughput_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedThroughputNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_access_properties = AAZObjectType( + serialized_name="publicAccessProperties", + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.redundancy = AAZStrType() + + nfs_protocol_properties = cls._schema_on_200.value.Element.properties.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrType( + serialized_name="rootSquash", + ) + + private_endpoint_connections = cls._schema_on_200.value.Element.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + public_access_properties = cls._schema_on_200.value.Element.properties.public_access_properties + public_access_properties.allowed_subnets = AAZListType( + serialized_name="allowedSubnets", + ) + + allowed_subnets = cls._schema_on_200.value.Element.properties.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrType() + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class FileSharesListByParent(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.FileShares/fileShares", + **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}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.host_name = AAZStrType( + serialized_name="hostName", + flags={"read_only": True}, + ) + properties.included_burst_io_per_sec = AAZIntType( + serialized_name="includedBurstIOPerSec", + flags={"read_only": True}, + ) + properties.max_burst_io_per_sec_credits = AAZIntType( + serialized_name="maxBurstIOPerSecCredits", + flags={"read_only": True}, + ) + properties.media_tier = AAZStrType( + serialized_name="mediaTier", + ) + properties.mount_name = AAZStrType( + serialized_name="mountName", + ) + properties.nfs_protocol_properties = AAZObjectType( + serialized_name="nfsProtocolProperties", + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.protocol = AAZStrType() + properties.provisioned_io_per_sec = AAZIntType( + serialized_name="provisionedIOPerSec", + ) + properties.provisioned_io_per_sec_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedIOPerSecNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_storage_gi_b = AAZIntType( + serialized_name="provisionedStorageGiB", + ) + properties.provisioned_storage_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedStorageNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="provisionedThroughputMiBPerSec", + ) + properties.provisioned_throughput_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedThroughputNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_access_properties = AAZObjectType( + serialized_name="publicAccessProperties", + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.redundancy = AAZStrType() + + nfs_protocol_properties = cls._schema_on_200.value.Element.properties.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrType( + serialized_name="rootSquash", + ) + + private_endpoint_connections = cls._schema_on_200.value.Element.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + public_access_properties = cls._schema_on_200.value.Element.properties.public_access_properties + public_access_properties.allowed_subnets = AAZListType( + serialized_name="allowedSubnets", + ) + + allowed_subnets = cls._schema_on_200.value.Element.properties.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrType() + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["List"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_show.py b/src/file-share/azext_file_share/aaz/latest/file_share/_show.py new file mode 100644 index 00000000000..624f42c8b0c --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_show.py @@ -0,0 +1,361 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share show", + is_preview=True, +) +class Show(AAZCommand): + """Get a FileShare + + :example: Show a FileShare + az file-share show --resource-group rgfileshares --resource-name fileshare + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}", "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.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileSharesGet(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 FileSharesGet(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.FileShares/fileShares/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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}, + ) + _ShowHelper._build_schema_system_data_read(_schema_on_200.system_data) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.host_name = AAZStrType( + serialized_name="hostName", + flags={"read_only": True}, + ) + properties.included_burst_io_per_sec = AAZIntType( + serialized_name="includedBurstIOPerSec", + flags={"read_only": True}, + ) + properties.max_burst_io_per_sec_credits = AAZIntType( + serialized_name="maxBurstIOPerSecCredits", + flags={"read_only": True}, + ) + properties.media_tier = AAZStrType( + serialized_name="mediaTier", + ) + properties.mount_name = AAZStrType( + serialized_name="mountName", + ) + properties.nfs_protocol_properties = AAZObjectType( + serialized_name="nfsProtocolProperties", + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.protocol = AAZStrType() + properties.provisioned_io_per_sec = AAZIntType( + serialized_name="provisionedIOPerSec", + ) + properties.provisioned_io_per_sec_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedIOPerSecNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_storage_gi_b = AAZIntType( + serialized_name="provisionedStorageGiB", + ) + properties.provisioned_storage_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedStorageNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="provisionedThroughputMiBPerSec", + ) + properties.provisioned_throughput_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedThroughputNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_access_properties = AAZObjectType( + serialized_name="publicAccessProperties", + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.redundancy = AAZStrType() + + nfs_protocol_properties = cls._schema_on_200.properties.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrType( + serialized_name="rootSquash", + ) + + private_endpoint_connections = cls._schema_on_200.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.private_endpoint_connections.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ShowHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + public_access_properties = cls._schema_on_200.properties.public_access_properties + public_access_properties.allowed_subnets = AAZListType( + serialized_name="allowedSubnets", + ) + + allowed_subnets = cls._schema_on_200.properties.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrType() + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Show"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_update.py b/src/file-share/azext_file_share/aaz/latest/file_share/_update.py new file mode 100644 index 00000000000..79e829c9c7d --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_update.py @@ -0,0 +1,638 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share update", + is_preview=True, +) +class Update(AAZCommand): + """Update a file share. + + :example: Update a File Share + az file-share update --resource-group rgfileshares --resource-name fileshare --mount-name fileshare --media-tier SSD --redundancy Local --protocol NFS --provisioned-storage-gib 8 --provisioned-io-per-sec 5 --provisioned-throughput-mib-per-sec 22 --nfs-protocol-properties "{root-squash:NoRootSquash}" --public-access-properties "{allowed-subnets:[/subscriptions/9760acf5-4638-11e7-9bdb-020073ca7778/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3]}" --public-network-access Enabled --tags "{key9647:xwokdvyoae}" --location gdsuixfhrgfbbbfjtgocmlzyuonrr + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.nfs_protocol_properties = AAZObjectArg( + options=["--nfs-protocol-properties"], + arg_group="Properties", + help="Protocol settings specific NFS.", + nullable=True, + ) + _args_schema.provisioned_io_per_sec = AAZIntArg( + options=["--provisioned-io-per-sec"], + arg_group="Properties", + help="The provisioned IO / sec of the share.", + nullable=True, + ) + _args_schema.provisioned_storage_gib = AAZIntArg( + options=["--provisioned-storage-gib"], + arg_group="Properties", + help="The provisioned storage size of the share in GiB (1 GiB is 1024^3 bytes or 1073741824 bytes). A component of the file share's bill is the provisioned storage, regardless of the amount of used storage.", + nullable=True, + ) + _args_schema.provisioned_throughput_mib_per_sec = AAZIntArg( + options=["--provisioned-throughput-mib-per-sec"], + arg_group="Properties", + help="The provisioned throughput / sec of the share.", + nullable=True, + ) + _args_schema.public_access_properties = AAZObjectArg( + options=["--public-access-properties"], + arg_group="Properties", + help="The set of properties for control public access.", + nullable=True, + ) + _args_schema.public_network_access = AAZStrArg( + options=["--public-network-access"], + arg_group="Properties", + help="Gets or sets allow or disallow public network access to azure managed file share", + nullable=True, + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + + nfs_protocol_properties = cls._args_schema.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrArg( + options=["root-squash"], + help="Root squash defines how root users on clients are mapped to the NFS share.", + nullable=True, + enum={"AllSquash": "AllSquash", "NoRootSquash": "NoRootSquash", "RootSquash": "RootSquash"}, + ) + + public_access_properties = cls._args_schema.public_access_properties + public_access_properties.allowed_subnets = AAZListArg( + options=["allowed-subnets"], + help="The allowed set of subnets when access is restricted.", + nullable=True, + ) + + allowed_subnets = cls._args_schema.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileSharesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.FileSharesCreateOrUpdate(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 FileSharesGet(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.FileShares/fileShares/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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_file_share_read(cls._schema_on_200) + + return cls._schema_on_200 + + class FileSharesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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_file_share_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("nfsProtocolProperties", AAZObjectType, ".nfs_protocol_properties") + properties.set_prop("provisionedIOPerSec", AAZIntType, ".provisioned_io_per_sec") + properties.set_prop("provisionedStorageGiB", AAZIntType, ".provisioned_storage_gib") + properties.set_prop("provisionedThroughputMiBPerSec", AAZIntType, ".provisioned_throughput_mib_per_sec") + properties.set_prop("publicAccessProperties", AAZObjectType, ".public_access_properties") + properties.set_prop("publicNetworkAccess", AAZStrType, ".public_network_access") + + nfs_protocol_properties = _builder.get(".properties.nfsProtocolProperties") + if nfs_protocol_properties is not None: + nfs_protocol_properties.set_prop("rootSquash", AAZStrType, ".root_squash") + + public_access_properties = _builder.get(".properties.publicAccessProperties") + if public_access_properties is not None: + public_access_properties.set_prop("allowedSubnets", AAZListType, ".allowed_subnets") + + allowed_subnets = _builder.get(".properties.publicAccessProperties.allowedSubnets") + if allowed_subnets is not None: + allowed_subnets.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_file_share_read = None + + @classmethod + def _build_schema_file_share_read(cls, _schema): + if cls._schema_file_share_read is not None: + _schema.id = cls._schema_file_share_read.id + _schema.location = cls._schema_file_share_read.location + _schema.name = cls._schema_file_share_read.name + _schema.properties = cls._schema_file_share_read.properties + _schema.system_data = cls._schema_file_share_read.system_data + _schema.tags = cls._schema_file_share_read.tags + _schema.type = cls._schema_file_share_read.type + return + + cls._schema_file_share_read = _schema_file_share_read = AAZObjectType() + + file_share_read = _schema_file_share_read + file_share_read.id = AAZStrType( + flags={"read_only": True}, + ) + file_share_read.location = AAZStrType( + flags={"required": True}, + ) + file_share_read.name = AAZStrType( + flags={"read_only": True}, + ) + file_share_read.properties = AAZObjectType() + file_share_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + cls._build_schema_system_data_read(file_share_read.system_data) + file_share_read.tags = AAZDictType() + file_share_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_file_share_read.properties + properties.host_name = AAZStrType( + serialized_name="hostName", + flags={"read_only": True}, + ) + properties.included_burst_io_per_sec = AAZIntType( + serialized_name="includedBurstIOPerSec", + flags={"read_only": True}, + ) + properties.max_burst_io_per_sec_credits = AAZIntType( + serialized_name="maxBurstIOPerSecCredits", + flags={"read_only": True}, + ) + properties.media_tier = AAZStrType( + serialized_name="mediaTier", + ) + properties.mount_name = AAZStrType( + serialized_name="mountName", + ) + properties.nfs_protocol_properties = AAZObjectType( + serialized_name="nfsProtocolProperties", + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.protocol = AAZStrType() + properties.provisioned_io_per_sec = AAZIntType( + serialized_name="provisionedIOPerSec", + ) + properties.provisioned_io_per_sec_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedIOPerSecNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_storage_gi_b = AAZIntType( + serialized_name="provisionedStorageGiB", + ) + properties.provisioned_storage_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedStorageNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="provisionedThroughputMiBPerSec", + ) + properties.provisioned_throughput_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedThroughputNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_access_properties = AAZObjectType( + serialized_name="publicAccessProperties", + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.redundancy = AAZStrType() + + nfs_protocol_properties = _schema_file_share_read.properties.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrType( + serialized_name="rootSquash", + ) + + private_endpoint_connections = _schema_file_share_read.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = _schema_file_share_read.properties.private_endpoint_connections.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + cls._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_file_share_read.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = _schema_file_share_read.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = _schema_file_share_read.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = _schema_file_share_read.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + public_access_properties = _schema_file_share_read.properties.public_access_properties + public_access_properties.allowed_subnets = AAZListType( + serialized_name="allowedSubnets", + ) + + allowed_subnets = _schema_file_share_read.properties.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrType() + + tags = _schema_file_share_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_file_share_read.id + _schema.location = cls._schema_file_share_read.location + _schema.name = cls._schema_file_share_read.name + _schema.properties = cls._schema_file_share_read.properties + _schema.system_data = cls._schema_file_share_read.system_data + _schema.tags = cls._schema_file_share_read.tags + _schema.type = cls._schema_file_share_read.type + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Update"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/_wait.py b/src/file-share/azext_file_share/aaz/latest/file_share/_wait.py new file mode 100644 index 00000000000..a0442be41cb --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/_wait.py @@ -0,0 +1,356 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}", "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.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileSharesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class FileSharesGet(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.FileShares/fileShares/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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}, + ) + _WaitHelper._build_schema_system_data_read(_schema_on_200.system_data) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.host_name = AAZStrType( + serialized_name="hostName", + flags={"read_only": True}, + ) + properties.included_burst_io_per_sec = AAZIntType( + serialized_name="includedBurstIOPerSec", + flags={"read_only": True}, + ) + properties.max_burst_io_per_sec_credits = AAZIntType( + serialized_name="maxBurstIOPerSecCredits", + flags={"read_only": True}, + ) + properties.media_tier = AAZStrType( + serialized_name="mediaTier", + ) + properties.mount_name = AAZStrType( + serialized_name="mountName", + ) + properties.nfs_protocol_properties = AAZObjectType( + serialized_name="nfsProtocolProperties", + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.protocol = AAZStrType() + properties.provisioned_io_per_sec = AAZIntType( + serialized_name="provisionedIOPerSec", + ) + properties.provisioned_io_per_sec_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedIOPerSecNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_storage_gi_b = AAZIntType( + serialized_name="provisionedStorageGiB", + ) + properties.provisioned_storage_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedStorageNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioned_throughput_mi_b_per_sec = AAZIntType( + serialized_name="provisionedThroughputMiBPerSec", + ) + properties.provisioned_throughput_next_allowed_downgrade = AAZStrType( + serialized_name="provisionedThroughputNextAllowedDowngrade", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_access_properties = AAZObjectType( + serialized_name="publicAccessProperties", + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.redundancy = AAZStrType() + + nfs_protocol_properties = cls._schema_on_200.properties.nfs_protocol_properties + nfs_protocol_properties.root_squash = AAZStrType( + serialized_name="rootSquash", + ) + + private_endpoint_connections = cls._schema_on_200.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.private_endpoint_connections.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _WaitHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + public_access_properties = cls._schema_on_200.properties.public_access_properties + public_access_properties.allowed_subnets = AAZListType( + serialized_name="allowedSubnets", + ) + + allowed_subnets = cls._schema_on_200.properties.public_access_properties.allowed_subnets + allowed_subnets.Element = AAZStrType() + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Wait"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/__cmd_group.py b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/__cmd_group.py new file mode 100644 index 00000000000..37506a88803 --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/__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( + "file-share snapshot", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage File Share Snapshot + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/__init__.py b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/__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/file-share/azext_file_share/aaz/latest/file_share/snapshot/_create.py b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_create.py new file mode 100644 index 00000000000..09d59008f4b --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_create.py @@ -0,0 +1,193 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share snapshot create", + is_preview=True, +) +class Create(AAZCommand): + """Create a FileShareSnapshot. + + :example: Create a File Share Snapshot + az file-share snapshot create --resource-group rgfileshares --resource-name fileshare --name testfilesharesnapshot --metadata "{key9372:jtc}" + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}/filesharesnapshots/{}", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the FileShareSnapshot", + required=True, + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.metadata = AAZDictArg( + options=["--metadata"], + arg_group="Properties", + help="The metadata", + ) + + metadata = cls._args_schema.metadata + metadata.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.FileShareSnapshotCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class FileShareSnapshotCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + None, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("metadata", AAZDictType, ".metadata") + + metadata = _builder.get(".properties.metadata") + if metadata is not None: + metadata.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_delete.py b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_delete.py new file mode 100644 index 00000000000..0fa98aaf2ae --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_delete.py @@ -0,0 +1,180 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share snapshot delete", + is_preview=True, + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a FileShareSnapshot. + + :example: Delete a File Share Snapshot + az file-share snapshot delete --resource-group rgfileshares --resource-name fileshare --name testfilesharesnapshot + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}/filesharesnapshots/{}", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the FileShareSnapshot", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.FileShareSnapshotDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class FileShareSnapshotDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}", + **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( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_list.py b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_list.py new file mode 100644 index 00000000000..6bdbea6126f --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_list.py @@ -0,0 +1,228 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share snapshot list", + is_preview=True, +) +class List(AAZCommand): + """List FileShareSnapshot by FileShare. + + :example: List File Share Snapshots + az file-share snapshot list --resource-group rgfileshares --resource-name fileshare + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}/filesharesnapshots", "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( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileShareSnapshotList(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 FileShareSnapshotList(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.FileShares/fileShares/{resourceName}/fileShareSnapshots", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.initiator_id = AAZStrType( + serialized_name="initiatorId", + flags={"read_only": True}, + ) + properties.metadata = AAZDictType() + properties.snapshot_time = AAZStrType( + serialized_name="snapshotTime", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.value.Element.properties.metadata + metadata.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_show.py b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_show.py new file mode 100644 index 00000000000..28ee4f52cb6 --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_show.py @@ -0,0 +1,229 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. 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( + "file-share snapshot show", + is_preview=True, +) +class Show(AAZCommand): + """Get a FileShareSnapshot + + :example: Show a File Share Snapshot + az file-share snapshot show --resource-group rgfileshares --resource-name fileshare --name testfilesharesnapshot + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}/filesharesnapshots/{}", "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.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the FileShareSnapshot", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.FileShareSnapshotGet(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 FileShareSnapshotGet(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.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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.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.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.initiator_id = AAZStrType( + serialized_name="initiatorId", + flags={"read_only": True}, + ) + properties.metadata = AAZDictType() + properties.snapshot_time = AAZStrType( + serialized_name="snapshotTime", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.properties.metadata + metadata.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_update.py b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_update.py new file mode 100644 index 00000000000..14ad1a790ad --- /dev/null +++ b/src/file-share/azext_file_share/aaz/latest/file_share/snapshot/_update.py @@ -0,0 +1,280 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "file-share snapshot update", + is_preview=True, +) +class Update(AAZCommand): + """Update a FileShareSnapshot. + + :example: Update a File Share Snapshot + az file-share snapshot create --resource-group rgfileshares --resource-name fileshare --name testfilesharesnapshot --metadata "{key9372:jtc}" + """ + + _aaz_info = { + "version": "2025-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.fileshares/fileshares/{}/filesharesnapshots/{}", "2025-06-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the FileShareSnapshot", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["--resource-name"], + help="The resource name of the file share, as seen by the administrator through Azure Resource Manager.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^([a-z]|[0-9])([a-z]|[0-9]|(-(?!-))){1,61}([a-z]|[0-9])$", + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.metadata = AAZDictArg( + options=["--metadata"], + arg_group="Properties", + help="The metadata", + ) + + metadata = cls._args_schema.metadata + metadata.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.FileShareSnapshotUpdate(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 FileShareSnapshotUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.FileShares/fileShares/{resourceName}/fileShareSnapshots/{name}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "resourceName", self.ctx.args.resource_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "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("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("metadata", AAZDictType, ".metadata") + + metadata = _builder.get(".properties.metadata") + if metadata is not None: + metadata.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.initiator_id = AAZStrType( + serialized_name="initiatorId", + flags={"read_only": True}, + ) + properties.metadata = AAZDictType() + properties.snapshot_time = AAZStrType( + serialized_name="snapshotTime", + flags={"read_only": True}, + ) + + metadata = cls._schema_on_200.properties.metadata + metadata.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/file-share/azext_file_share/azext_metadata.json b/src/file-share/azext_file_share/azext_metadata.json new file mode 100644 index 00000000000..71889bb136b --- /dev/null +++ b/src/file-share/azext_file_share/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/file-share/azext_file_share/commands.py b/src/file-share/azext_file_share/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/file-share/azext_file_share/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/file-share/azext_file_share/custom.py b/src/file-share/azext_file_share/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/file-share/azext_file_share/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/file-share/azext_file_share/tests/__init__.py b/src/file-share/azext_file_share/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/file-share/azext_file_share/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/file-share/azext_file_share/tests/latest/__init__.py b/src/file-share/azext_file_share/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/file-share/azext_file_share/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/file-share/azext_file_share/tests/latest/test_file_share.py b/src/file-share/azext_file_share/tests/latest/test_file_share.py new file mode 100644 index 00000000000..1b9bc09cbc4 --- /dev/null +++ b/src/file-share/azext_file_share/tests/latest/test_file_share.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * + + +class FileShareScenario(ScenarioTest): + # TODO: add tests here + pass diff --git a/src/file-share/setup.cfg b/src/file-share/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/file-share/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/file-share/setup.py b/src/file-share/setup.py new file mode 100644 index 00000000000..4b06af4937a --- /dev/null +++ b/src/file-share/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='file-share', + version=VERSION, + description='Microsoft Azure Command-Line Tools FileShare 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/file-share', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_file_share': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +)