From 667be6cec79957e639d6df9ab68f5913381ba2a0 Mon Sep 17 00:00:00 2001 From: Zhiyi Huang <17182306+calvinhzy@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:29:12 +0800 Subject: [PATCH] add task assignment preview, remove `storage account migration` as it is GA --- .../aaz/latest/__init__.py | 4 + .../latest/storage/account/migration/_show.py | 207 ------ .../__cmd_group.py | 4 +- .../__init__.py | 7 +- .../account/task_assignment/_create.py | 503 ++++++++++++++ .../_start.py => task_assignment/_delete.py} | 107 ++- .../storage/account/task_assignment/_list.py | 329 +++++++++ .../account/task_assignment/_list_report.py | 276 ++++++++ .../storage/account/task_assignment/_show.py | 324 +++++++++ .../account/task_assignment/_update.py | 650 ++++++++++++++++++ .../storage/account/task_assignment/_wait.py | 322 +++++++++ .../azext_storage_preview/azext_metadata.json | 2 +- 12 files changed, 2459 insertions(+), 276 deletions(-) delete mode 100644 src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/_show.py rename src/storage-preview/azext_storage_preview/aaz/latest/storage/account/{migration => task_assignment}/__cmd_group.py (87%) rename src/storage-preview/azext_storage_preview/aaz/latest/storage/account/{migration => task_assignment}/__init__.py (77%) create mode 100644 src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_create.py rename src/storage-preview/azext_storage_preview/aaz/latest/storage/account/{migration/_start.py => task_assignment/_delete.py} (57%) create mode 100644 src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list.py create mode 100644 src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list_report.py create mode 100644 src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_show.py create mode 100644 src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_update.py create mode 100644 src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_wait.py diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/__init__.py b/src/storage-preview/azext_storage_preview/aaz/latest/__init__.py index 5757aea3175..f6acc11aa4e 100644 --- a/src/storage-preview/azext_storage_preview/aaz/latest/__init__.py +++ b/src/storage-preview/azext_storage_preview/aaz/latest/__init__.py @@ -4,3 +4,7 @@ # # Code generated by aaz-dev-tools # -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/_show.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/_show.py deleted file mode 100644 index 483db27df43..00000000000 --- a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/_show.py +++ /dev/null @@ -1,207 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "storage account migration show", - is_preview=True, -) -class Show(AAZCommand): - """Get the status of the ongoing migration for the specified storage account. - """ - - _aaz_info = { - "version": "2023-01-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/accountmigrations/{}", "2023-01-01"], - ] - } - - def _handler(self, command_args): - super()._handler(command_args) - self._execute_operations() - return self._output() - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.account_name = AAZStrArg( - options=["--account-name"], - help="The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - pattern="^[a-z0-9]+$", - max_length=24, - min_length=3, - ), - ) - _args_schema.migration_name = AAZStrArg( - options=["-n", "--name", "--migration-name"], - help="The name of the Storage Account Migration. It should always be 'default'", - required=True, - id_part="child_name_1", - enum={"default": "default"}, - fmt=AAZStrArgFormat( - pattern="^[a-z][a-z0-9]*$", - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.StorageAccountsGetCustomerInitiatedMigration(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 StorageAccountsGetCustomerInitiatedMigration(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.Storage/storageAccounts/{accountName}/accountMigrations/{migrationName}", - **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( - "accountName", self.ctx.args.account_name, - required=True, - ), - **self.serialize_url_param( - "migrationName", self.ctx.args.migration_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-01-01", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.id = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.name = AAZStrType() - _schema_on_200.properties = AAZObjectType( - flags={"required": True, "client_flatten": True}, - ) - _schema_on_200.type = AAZStrType() - - properties = cls._schema_on_200.properties - properties.migration_failed_detailed_reason = AAZStrType( - serialized_name="migrationFailedDetailedReason", - flags={"read_only": True}, - ) - properties.migration_failed_reason = AAZStrType( - serialized_name="migrationFailedReason", - flags={"read_only": True}, - ) - properties.migration_status = AAZStrType( - serialized_name="migrationStatus", - flags={"read_only": True}, - ) - properties.target_sku_name = AAZStrType( - serialized_name="targetSkuName", - flags={"required": True}, - ) - - return cls._schema_on_200 - - -class _ShowHelper: - """Helper class for Show""" - - -__all__ = ["Show"] diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/__cmd_group.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/__cmd_group.py similarity index 87% rename from src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/__cmd_group.py rename to src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/__cmd_group.py index d7e47628926..145a63ed90b 100644 --- a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/__cmd_group.py +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/__cmd_group.py @@ -12,11 +12,11 @@ @register_command_group( - "storage account migration", + "storage account task-assignment", is_preview=True, ) class __CMDGroup(AAZCommandGroup): - """Manage Storage Account Migration + """Manage storage account task assignment. """ pass diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/__init__.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/__init__.py similarity index 77% rename from src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/__init__.py rename to src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/__init__.py index 1a94969d1a6..4289e8e9c14 100644 --- a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/__init__.py +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/__init__.py @@ -9,5 +9,10 @@ # flake8: noqa from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._list_report import * from ._show import * -from ._start import * +from ._update import * +from ._wait import * diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_create.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_create.py new file mode 100644 index 00000000000..8375b37b1ee --- /dev/null +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_create.py @@ -0,0 +1,503 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage account task-assignment create", + is_preview=True, +) +class Create(AAZCommand): + """Create creates a new storage task assignment sub-resource with the specified parameters. If a storage task assignment is already created and a subsequent create request is issued with different properties, the storage task assignment properties will be updated. If a storage task assignment is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + """ + + _aaz_info = { + "version": "2023-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/storagetaskassignments/{}", "2023-05-01"], + ] + } + + 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.account_name = AAZStrArg( + options=["--account-name"], + help="The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]+$", + max_length=24, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_task_assignment_name = AAZStrArg( + options=["-n", "--name", "--storage-task-assignment-name"], + help="The name of the storage task assignment within the specified resource group. Storage task assignment names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]{3,24}$", + max_length=24, + min_length=3, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Text that describes the purpose of the storage task assignment", + required=True, + ) + _args_schema.enabled = AAZBoolArg( + options=["--enabled"], + arg_group="Properties", + help="Whether the storage task assignment is enabled or not", + required=True, + ) + _args_schema.execution_context = AAZObjectArg( + options=["--execution-context"], + arg_group="Properties", + help="The storage task assignment execution context", + required=True, + ) + _args_schema.report = AAZObjectArg( + options=["--report"], + arg_group="Properties", + help="The storage task assignment report", + required=True, + ) + _args_schema.task_id = AAZResourceIdArg( + options=["--task-id"], + arg_group="Properties", + help="Id of the corresponding storage task", + required=True, + ) + + execution_context = cls._args_schema.execution_context + execution_context.target = AAZObjectArg( + options=["target"], + help="Execution target of the storage task assignment", + ) + execution_context.trigger = AAZObjectArg( + options=["trigger"], + help="Execution trigger of the storage task assignment", + required=True, + ) + + target = cls._args_schema.execution_context.target + target.exclude_prefix = AAZListArg( + options=["exclude-prefix"], + help="List of object prefixes to be excluded from task execution. If there is a conflict between include and exclude prefixes, the exclude prefix will be the determining factor", + ) + target.prefix = AAZListArg( + options=["prefix"], + help="Required list of object prefixes to be included for task execution", + ) + + exclude_prefix = cls._args_schema.execution_context.target.exclude_prefix + exclude_prefix.Element = AAZStrArg() + + prefix = cls._args_schema.execution_context.target.prefix + prefix.Element = AAZStrArg() + + trigger = cls._args_schema.execution_context.trigger + trigger.parameters = AAZObjectArg( + options=["parameters"], + help="The trigger parameters of the storage task assignment execution", + required=True, + ) + trigger.type = AAZStrArg( + options=["type"], + help="The trigger type of the storage task assignment execution", + required=True, + enum={"OnSchedule": "OnSchedule", "RunOnce": "RunOnce"}, + ) + + parameters = cls._args_schema.execution_context.trigger.parameters + parameters.end_by = AAZDateTimeArg( + options=["end-by"], + help="When to end task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + ) + parameters.interval = AAZIntArg( + options=["interval"], + help="Run interval of task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + fmt=AAZIntArgFormat( + minimum=1, + ), + ) + parameters.interval_unit = AAZStrArg( + options=["interval-unit"], + help="Run interval unit of task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + enum={"Days": "Days"}, + ) + parameters.start_from = AAZDateTimeArg( + options=["start-from"], + help="When to start task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + ) + parameters.start_on = AAZDateTimeArg( + options=["start-on"], + help="When to start task execution. This is an optional field when ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when ExecutionTrigger.properties.type is 'OnSchedule'", + ) + + report = cls._args_schema.report + report.prefix = AAZStrArg( + options=["prefix"], + help="The container prefix for the location of storage task assignment report", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.StorageTaskAssignmentsCreate(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 StorageTaskAssignmentsCreate(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 [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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + **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( + "accountName", self.ctx.args.account_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "storageTaskAssignmentName", self.ctx.args.storage_task_assignment_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("executionContext", AAZObjectType, ".execution_context", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("report", AAZObjectType, ".report", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("taskId", AAZStrType, ".task_id", typ_kwargs={"flags": {"required": True}}) + + execution_context = _builder.get(".properties.executionContext") + if execution_context is not None: + execution_context.set_prop("target", AAZObjectType, ".target") + execution_context.set_prop("trigger", AAZObjectType, ".trigger", typ_kwargs={"flags": {"required": True}}) + + target = _builder.get(".properties.executionContext.target") + if target is not None: + target.set_prop("excludePrefix", AAZListType, ".exclude_prefix") + target.set_prop("prefix", AAZListType, ".prefix") + + exclude_prefix = _builder.get(".properties.executionContext.target.excludePrefix") + if exclude_prefix is not None: + exclude_prefix.set_elements(AAZStrType, ".") + + prefix = _builder.get(".properties.executionContext.target.prefix") + if prefix is not None: + prefix.set_elements(AAZStrType, ".") + + trigger = _builder.get(".properties.executionContext.trigger") + if trigger is not None: + trigger.set_prop("parameters", AAZObjectType, ".parameters", typ_kwargs={"flags": {"required": True}}) + trigger.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + parameters = _builder.get(".properties.executionContext.trigger.parameters") + if parameters is not None: + parameters.set_prop("endBy", AAZStrType, ".end_by") + parameters.set_prop("interval", AAZIntType, ".interval") + parameters.set_prop("intervalUnit", AAZStrType, ".interval_unit") + parameters.set_prop("startFrom", AAZStrType, ".start_from") + parameters.set_prop("startOn", AAZStrType, ".start_on") + + report = _builder.get(".properties.report") + if report is not None: + report.set_prop("prefix", AAZStrType, ".prefix", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.execution_context = AAZObjectType( + serialized_name="executionContext", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.report = AAZObjectType( + flags={"required": True}, + ) + properties.run_status = AAZObjectType( + serialized_name="runStatus", + ) + properties.task_id = AAZStrType( + serialized_name="taskId", + flags={"required": True}, + ) + + execution_context = cls._schema_on_200_201.properties.execution_context + execution_context.target = AAZObjectType() + execution_context.trigger = AAZObjectType( + flags={"required": True}, + ) + + target = cls._schema_on_200_201.properties.execution_context.target + target.exclude_prefix = AAZListType( + serialized_name="excludePrefix", + ) + target.prefix = AAZListType() + + exclude_prefix = cls._schema_on_200_201.properties.execution_context.target.exclude_prefix + exclude_prefix.Element = AAZStrType() + + prefix = cls._schema_on_200_201.properties.execution_context.target.prefix + prefix.Element = AAZStrType() + + trigger = cls._schema_on_200_201.properties.execution_context.trigger + trigger.parameters = AAZObjectType( + flags={"required": True}, + ) + trigger.type = AAZStrType( + flags={"required": True}, + ) + + parameters = cls._schema_on_200_201.properties.execution_context.trigger.parameters + parameters.end_by = AAZStrType( + serialized_name="endBy", + ) + parameters.interval = AAZIntType() + parameters.interval_unit = AAZStrType( + serialized_name="intervalUnit", + ) + parameters.start_from = AAZStrType( + serialized_name="startFrom", + ) + parameters.start_on = AAZStrType( + serialized_name="startOn", + ) + + report = cls._schema_on_200_201.properties.report + report.prefix = AAZStrType( + flags={"required": True}, + ) + + run_status = cls._schema_on_200_201.properties.run_status + run_status.finish_time = AAZStrType( + serialized_name="finishTime", + flags={"read_only": True}, + ) + run_status.object_failed_count = AAZStrType( + serialized_name="objectFailedCount", + flags={"read_only": True}, + ) + run_status.objects_operated_on_count = AAZStrType( + serialized_name="objectsOperatedOnCount", + flags={"read_only": True}, + ) + run_status.objects_succeeded_count = AAZStrType( + serialized_name="objectsSucceededCount", + flags={"read_only": True}, + ) + run_status.objects_targeted_count = AAZStrType( + serialized_name="objectsTargetedCount", + flags={"read_only": True}, + ) + run_status.run_result = AAZStrType( + serialized_name="runResult", + flags={"read_only": True}, + ) + run_status.run_status_enum = AAZStrType( + serialized_name="runStatusEnum", + flags={"read_only": True}, + ) + run_status.run_status_error = AAZStrType( + serialized_name="runStatusError", + flags={"read_only": True}, + ) + run_status.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + run_status.storage_account_id = AAZStrType( + serialized_name="storageAccountId", + flags={"read_only": True}, + ) + run_status.summary_report_path = AAZStrType( + serialized_name="summaryReportPath", + flags={"read_only": True}, + ) + run_status.task_assignment_id = AAZStrType( + serialized_name="taskAssignmentId", + flags={"read_only": True}, + ) + run_status.task_id = AAZStrType( + serialized_name="taskId", + flags={"read_only": True}, + ) + run_status.task_version = AAZStrType( + serialized_name="taskVersion", + flags={"read_only": True}, + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/_start.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_delete.py similarity index 57% rename from src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/_start.py rename to src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_delete.py index 6101e2c2510..5155c1b55c6 100644 --- a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/migration/_start.py +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_delete.py @@ -12,17 +12,18 @@ @register_command( - "storage account migration start", + "storage account task-assignment delete", is_preview=True, + confirmation="Are you sure you want to perform this operation?", ) -class Start(AAZCommand): - """Account Migration request can be triggered for a storage account to change its redundancy level. The migration updates the non-zonal redundant storage account to a zonal redundant account or vice-versa in order to have better reliability and availability. Zone-redundant storage (ZRS) replicates your storage account synchronously across three Azure availability zones in the primary region. +class Delete(AAZCommand): + """Delete the storage task assignment sub-resource """ _aaz_info = { - "version": "2023-01-01", + "version": "2023-05-01", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/startaccountmigration", "2023-01-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/storagetaskassignments/{}", "2023-05-01"], ] } @@ -57,36 +58,22 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.resource_group = AAZResourceGroupNameArg( required=True, ) - - # define Arg Group "Parameters" - - _args_schema = cls._args_schema - _args_schema.name = AAZStrArg( - options=["--name"], - arg_group="Parameters", - help="current value is 'default' for customer initiated migration", - ) - _args_schema.type = AAZStrArg( - options=["--type"], - arg_group="Parameters", - help="SrpAccountMigrationType in ARM contract which is 'accountMigrations'", - ) - - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.target_sku_name = AAZStrArg( - options=["--sku", "--target-sku-name"], - arg_group="Properties", - help="Target sku name for the account", + _args_schema.storage_task_assignment_name = AAZStrArg( + options=["-n", "--name", "--storage-task-assignment-name"], + help="The name of the storage task assignment within the specified resource group. Storage task assignment names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", required=True, - enum={"Premium_LRS": "Premium_LRS", "Premium_ZRS": "Premium_ZRS", "Standard_GRS": "Standard_GRS", "Standard_GZRS": "Standard_GZRS", "Standard_LRS": "Standard_LRS", "Standard_RAGRS": "Standard_RAGRS", "Standard_RAGZRS": "Standard_RAGZRS", "Standard_ZRS": "Standard_ZRS"}, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]{3,24}$", + max_length=24, + min_length=3, + ), ) return cls._args_schema def _execute_operations(self): self.pre_operations() - yield self.StorageAccountsCustomerInitiatedMigration(ctx=self.ctx)() + yield self.StorageTaskAssignmentsDelete(ctx=self.ctx)() self.post_operations() @register_callback @@ -97,7 +84,7 @@ def pre_operations(self): def post_operations(self): pass - class StorageAccountsCustomerInitiatedMigration(AAZHttpOperation): + class StorageTaskAssignmentsDelete(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -107,16 +94,25 @@ def __call__(self, *args, **kwargs): return self.client.build_lro_polling( self.ctx.args.no_wait, session, - self.on_200, + 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 [200]: + if session.http_response.status_code in [204]: return self.client.build_lro_polling( self.ctx.args.no_wait, session, - self.on_200, + 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, @@ -127,13 +123,13 @@ def __call__(self, *args, **kwargs): @property def url(self): return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/startAccountMigration", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", **self.url_parameters ) @property def method(self): - return "POST" + return "DELETE" @property def error_format(self): @@ -150,6 +146,10 @@ def url_parameters(self): "resourceGroupName", self.ctx.args.resource_group, required=True, ), + **self.serialize_url_param( + "storageTaskAssignmentName", self.ctx.args.storage_task_assignment_name, + required=True, + ), **self.serialize_url_param( "subscriptionId", self.ctx.subscription_id, required=True, @@ -161,44 +161,21 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-01-01", + "api-version", "2023-05-01", 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("name", AAZStrType, ".name") - _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) - _builder.set_prop("type", AAZStrType, ".type") - - properties = _builder.get(".properties") - if properties is not None: - properties.set_prop("targetSkuName", AAZStrType, ".target_sku_name", typ_kwargs={"flags": {"required": True}}) - - return self.serialize_content(_content_value) + def on_204(self, session): + pass - def on_200(self, session): + def on_200_201(self, session): pass -class _StartHelper: - """Helper class for Start""" +class _DeleteHelper: + """Helper class for Delete""" -__all__ = ["Start"] +__all__ = ["Delete"] diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list.py new file mode 100644 index 00000000000..142093234bb --- /dev/null +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list.py @@ -0,0 +1,329 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage account task-assignment list", + is_preview=True, +) +class List(AAZCommand): + """List all the storage task assignments in an account + """ + + _aaz_info = { + "version": "2023-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/storagetaskassignments", "2023-05-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.account_name = AAZStrArg( + options=["--account-name"], + help="The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]+$", + max_length=24, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.maxpagesize = AAZIntArg( + options=["--maxpagesize"], + help="Optional, specifies the maximum number of storage task assignment Ids to be included in the list response.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageTaskAssignmentsList(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 StorageTaskAssignmentsList(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.Storage/storageAccounts/{accountName}/storageTaskAssignments", + **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( + "accountName", self.ctx.args.account_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$maxpagesize", self.ctx.args.maxpagesize, + ), + **self.serialize_query_param( + "api-version", "2023-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.execution_context = AAZObjectType( + serialized_name="executionContext", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.report = AAZObjectType( + flags={"required": True}, + ) + properties.run_status = AAZObjectType( + serialized_name="runStatus", + ) + properties.task_id = AAZStrType( + serialized_name="taskId", + flags={"required": True}, + ) + + execution_context = cls._schema_on_200.value.Element.properties.execution_context + execution_context.target = AAZObjectType() + execution_context.trigger = AAZObjectType( + flags={"required": True}, + ) + + target = cls._schema_on_200.value.Element.properties.execution_context.target + target.exclude_prefix = AAZListType( + serialized_name="excludePrefix", + ) + target.prefix = AAZListType() + + exclude_prefix = cls._schema_on_200.value.Element.properties.execution_context.target.exclude_prefix + exclude_prefix.Element = AAZStrType() + + prefix = cls._schema_on_200.value.Element.properties.execution_context.target.prefix + prefix.Element = AAZStrType() + + trigger = cls._schema_on_200.value.Element.properties.execution_context.trigger + trigger.parameters = AAZObjectType( + flags={"required": True}, + ) + trigger.type = AAZStrType( + flags={"required": True}, + ) + + parameters = cls._schema_on_200.value.Element.properties.execution_context.trigger.parameters + parameters.end_by = AAZStrType( + serialized_name="endBy", + ) + parameters.interval = AAZIntType() + parameters.interval_unit = AAZStrType( + serialized_name="intervalUnit", + ) + parameters.start_from = AAZStrType( + serialized_name="startFrom", + ) + parameters.start_on = AAZStrType( + serialized_name="startOn", + ) + + report = cls._schema_on_200.value.Element.properties.report + report.prefix = AAZStrType( + flags={"required": True}, + ) + + run_status = cls._schema_on_200.value.Element.properties.run_status + run_status.finish_time = AAZStrType( + serialized_name="finishTime", + flags={"read_only": True}, + ) + run_status.object_failed_count = AAZStrType( + serialized_name="objectFailedCount", + flags={"read_only": True}, + ) + run_status.objects_operated_on_count = AAZStrType( + serialized_name="objectsOperatedOnCount", + flags={"read_only": True}, + ) + run_status.objects_succeeded_count = AAZStrType( + serialized_name="objectsSucceededCount", + flags={"read_only": True}, + ) + run_status.objects_targeted_count = AAZStrType( + serialized_name="objectsTargetedCount", + flags={"read_only": True}, + ) + run_status.run_result = AAZStrType( + serialized_name="runResult", + flags={"read_only": True}, + ) + run_status.run_status_enum = AAZStrType( + serialized_name="runStatusEnum", + flags={"read_only": True}, + ) + run_status.run_status_error = AAZStrType( + serialized_name="runStatusError", + flags={"read_only": True}, + ) + run_status.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + run_status.storage_account_id = AAZStrType( + serialized_name="storageAccountId", + flags={"read_only": True}, + ) + run_status.summary_report_path = AAZStrType( + serialized_name="summaryReportPath", + flags={"read_only": True}, + ) + run_status.task_assignment_id = AAZStrType( + serialized_name="taskAssignmentId", + flags={"read_only": True}, + ) + run_status.task_id = AAZStrType( + serialized_name="taskId", + flags={"read_only": True}, + ) + run_status.task_version = AAZStrType( + serialized_name="taskVersion", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list_report.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list_report.py new file mode 100644 index 00000000000..e44a9082b46 --- /dev/null +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_list_report.py @@ -0,0 +1,276 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage account task-assignment list-report", + is_preview=True, +) +class ListReport(AAZCommand): + """List the report summary of a single storage task assignment's instances + """ + + _aaz_info = { + "version": "2023-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/storagetaskassignments/{}/reports", "2023-05-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.account_name = AAZStrArg( + options=["--account-name"], + help="The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]+$", + max_length=24, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_task_assignment_name = AAZStrArg( + options=["--storage-task-assignment-name"], + help="The name of the storage task assignment within the specified resource group. Storage task assignment names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]{3,24}$", + max_length=24, + min_length=3, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="Optional. When specified, it can be used to query using reporting properties. See [Constructing Filter Strings](https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#constructing-filter-strings) for details.", + ) + _args_schema.maxpagesize = AAZIntArg( + options=["--maxpagesize"], + help="Optional, specifies the maximum number of storage task assignment instances to be included in the list response.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageTaskAssignmentInstancesReportList(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 StorageTaskAssignmentInstancesReportList(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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}/reports", + **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( + "accountName", self.ctx.args.account_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "storageTaskAssignmentName", self.ctx.args.storage_task_assignment_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( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "$maxpagesize", self.ctx.args.maxpagesize, + ), + **self.serialize_query_param( + "api-version", "2023-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.finish_time = AAZStrType( + serialized_name="finishTime", + flags={"read_only": True}, + ) + properties.object_failed_count = AAZStrType( + serialized_name="objectFailedCount", + flags={"read_only": True}, + ) + properties.objects_operated_on_count = AAZStrType( + serialized_name="objectsOperatedOnCount", + flags={"read_only": True}, + ) + properties.objects_succeeded_count = AAZStrType( + serialized_name="objectsSucceededCount", + flags={"read_only": True}, + ) + properties.objects_targeted_count = AAZStrType( + serialized_name="objectsTargetedCount", + flags={"read_only": True}, + ) + properties.run_result = AAZStrType( + serialized_name="runResult", + flags={"read_only": True}, + ) + properties.run_status_enum = AAZStrType( + serialized_name="runStatusEnum", + flags={"read_only": True}, + ) + properties.run_status_error = AAZStrType( + serialized_name="runStatusError", + flags={"read_only": True}, + ) + properties.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + properties.storage_account_id = AAZStrType( + serialized_name="storageAccountId", + flags={"read_only": True}, + ) + properties.summary_report_path = AAZStrType( + serialized_name="summaryReportPath", + flags={"read_only": True}, + ) + properties.task_assignment_id = AAZStrType( + serialized_name="taskAssignmentId", + flags={"read_only": True}, + ) + properties.task_id = AAZStrType( + serialized_name="taskId", + flags={"read_only": True}, + ) + properties.task_version = AAZStrType( + serialized_name="taskVersion", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListReportHelper: + """Helper class for ListReport""" + + +__all__ = ["ListReport"] diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_show.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_show.py new file mode 100644 index 00000000000..5dcc86d5b86 --- /dev/null +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_show.py @@ -0,0 +1,324 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage account task-assignment show", + is_preview=True, +) +class Show(AAZCommand): + """Get the storage task assignment properties + """ + + _aaz_info = { + "version": "2023-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/storagetaskassignments/{}", "2023-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.account_name = AAZStrArg( + options=["--account-name"], + help="The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]+$", + max_length=24, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_task_assignment_name = AAZStrArg( + options=["-n", "--name", "--storage-task-assignment-name"], + help="The name of the storage task assignment within the specified resource group. Storage task assignment names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]{3,24}$", + max_length=24, + min_length=3, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageTaskAssignmentsGet(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 StorageTaskAssignmentsGet(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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + **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( + "accountName", self.ctx.args.account_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "storageTaskAssignmentName", self.ctx.args.storage_task_assignment_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.execution_context = AAZObjectType( + serialized_name="executionContext", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.report = AAZObjectType( + flags={"required": True}, + ) + properties.run_status = AAZObjectType( + serialized_name="runStatus", + ) + properties.task_id = AAZStrType( + serialized_name="taskId", + flags={"required": True}, + ) + + execution_context = cls._schema_on_200.properties.execution_context + execution_context.target = AAZObjectType() + execution_context.trigger = AAZObjectType( + flags={"required": True}, + ) + + target = cls._schema_on_200.properties.execution_context.target + target.exclude_prefix = AAZListType( + serialized_name="excludePrefix", + ) + target.prefix = AAZListType() + + exclude_prefix = cls._schema_on_200.properties.execution_context.target.exclude_prefix + exclude_prefix.Element = AAZStrType() + + prefix = cls._schema_on_200.properties.execution_context.target.prefix + prefix.Element = AAZStrType() + + trigger = cls._schema_on_200.properties.execution_context.trigger + trigger.parameters = AAZObjectType( + flags={"required": True}, + ) + trigger.type = AAZStrType( + flags={"required": True}, + ) + + parameters = cls._schema_on_200.properties.execution_context.trigger.parameters + parameters.end_by = AAZStrType( + serialized_name="endBy", + ) + parameters.interval = AAZIntType() + parameters.interval_unit = AAZStrType( + serialized_name="intervalUnit", + ) + parameters.start_from = AAZStrType( + serialized_name="startFrom", + ) + parameters.start_on = AAZStrType( + serialized_name="startOn", + ) + + report = cls._schema_on_200.properties.report + report.prefix = AAZStrType( + flags={"required": True}, + ) + + run_status = cls._schema_on_200.properties.run_status + run_status.finish_time = AAZStrType( + serialized_name="finishTime", + flags={"read_only": True}, + ) + run_status.object_failed_count = AAZStrType( + serialized_name="objectFailedCount", + flags={"read_only": True}, + ) + run_status.objects_operated_on_count = AAZStrType( + serialized_name="objectsOperatedOnCount", + flags={"read_only": True}, + ) + run_status.objects_succeeded_count = AAZStrType( + serialized_name="objectsSucceededCount", + flags={"read_only": True}, + ) + run_status.objects_targeted_count = AAZStrType( + serialized_name="objectsTargetedCount", + flags={"read_only": True}, + ) + run_status.run_result = AAZStrType( + serialized_name="runResult", + flags={"read_only": True}, + ) + run_status.run_status_enum = AAZStrType( + serialized_name="runStatusEnum", + flags={"read_only": True}, + ) + run_status.run_status_error = AAZStrType( + serialized_name="runStatusError", + flags={"read_only": True}, + ) + run_status.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + run_status.storage_account_id = AAZStrType( + serialized_name="storageAccountId", + flags={"read_only": True}, + ) + run_status.summary_report_path = AAZStrType( + serialized_name="summaryReportPath", + flags={"read_only": True}, + ) + run_status.task_assignment_id = AAZStrType( + serialized_name="taskAssignmentId", + flags={"read_only": True}, + ) + run_status.task_id = AAZStrType( + serialized_name="taskId", + flags={"read_only": True}, + ) + run_status.task_version = AAZStrType( + serialized_name="taskVersion", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_update.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_update.py new file mode 100644 index 00000000000..900206f341f --- /dev/null +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_update.py @@ -0,0 +1,650 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage account task-assignment update", + is_preview=True, +) +class Update(AAZCommand): + """Update creates a new storage task assignment sub-resource with the specified parameters. If a storage task assignment is already created and a subsequent create request is issued with different properties, the storage task assignment properties will be updated. If a storage task assignment is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + """ + + _aaz_info = { + "version": "2023-05-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/storagetaskassignments/{}", "2023-05-01"], + ] + } + + 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.account_name = AAZStrArg( + options=["--account-name"], + help="The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]+$", + max_length=24, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_task_assignment_name = AAZStrArg( + options=["-n", "--name", "--storage-task-assignment-name"], + help="The name of the storage task assignment within the specified resource group. Storage task assignment names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]{3,24}$", + max_length=24, + min_length=3, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Text that describes the purpose of the storage task assignment", + ) + _args_schema.enabled = AAZBoolArg( + options=["--enabled"], + arg_group="Properties", + help="Whether the storage task assignment is enabled or not", + ) + _args_schema.execution_context = AAZObjectArg( + options=["--execution-context"], + arg_group="Properties", + help="The storage task assignment execution context", + ) + _args_schema.report = AAZObjectArg( + options=["--report"], + arg_group="Properties", + help="The storage task assignment report", + ) + _args_schema.task_id = AAZResourceIdArg( + options=["--task-id"], + arg_group="Properties", + help="Id of the corresponding storage task", + ) + + execution_context = cls._args_schema.execution_context + execution_context.target = AAZObjectArg( + options=["target"], + help="Execution target of the storage task assignment", + nullable=True, + ) + execution_context.trigger = AAZObjectArg( + options=["trigger"], + help="Execution trigger of the storage task assignment", + ) + + target = cls._args_schema.execution_context.target + target.exclude_prefix = AAZListArg( + options=["exclude-prefix"], + help="List of object prefixes to be excluded from task execution. If there is a conflict between include and exclude prefixes, the exclude prefix will be the determining factor", + nullable=True, + ) + target.prefix = AAZListArg( + options=["prefix"], + help="Required list of object prefixes to be included for task execution", + nullable=True, + ) + + exclude_prefix = cls._args_schema.execution_context.target.exclude_prefix + exclude_prefix.Element = AAZStrArg( + nullable=True, + ) + + prefix = cls._args_schema.execution_context.target.prefix + prefix.Element = AAZStrArg( + nullable=True, + ) + + trigger = cls._args_schema.execution_context.trigger + trigger.parameters = AAZObjectArg( + options=["parameters"], + help="The trigger parameters of the storage task assignment execution", + ) + trigger.type = AAZStrArg( + options=["type"], + help="The trigger type of the storage task assignment execution", + enum={"OnSchedule": "OnSchedule", "RunOnce": "RunOnce"}, + ) + + parameters = cls._args_schema.execution_context.trigger.parameters + parameters.end_by = AAZDateTimeArg( + options=["end-by"], + help="When to end task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + nullable=True, + ) + parameters.interval = AAZIntArg( + options=["interval"], + help="Run interval of task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + nullable=True, + fmt=AAZIntArgFormat( + minimum=1, + ), + ) + parameters.interval_unit = AAZStrArg( + options=["interval-unit"], + help="Run interval unit of task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + nullable=True, + enum={"Days": "Days"}, + ) + parameters.start_from = AAZDateTimeArg( + options=["start-from"], + help="When to start task execution. This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce'", + nullable=True, + ) + parameters.start_on = AAZDateTimeArg( + options=["start-on"], + help="When to start task execution. This is an optional field when ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when ExecutionTrigger.properties.type is 'OnSchedule'", + nullable=True, + ) + + report = cls._args_schema.report + report.prefix = AAZStrArg( + options=["prefix"], + help="The container prefix for the location of storage task assignment report", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageTaskAssignmentsGet(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.StorageTaskAssignmentsCreate(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 StorageTaskAssignmentsGet(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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + **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( + "accountName", self.ctx.args.account_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "storageTaskAssignmentName", self.ctx.args.storage_task_assignment_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_storage_task_assignment_read(cls._schema_on_200) + + return cls._schema_on_200 + + class StorageTaskAssignmentsCreate(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 [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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + **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( + "accountName", self.ctx.args.account_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "storageTaskAssignmentName", self.ctx.args.storage_task_assignment_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_storage_task_assignment_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("executionContext", AAZObjectType, ".execution_context", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("report", AAZObjectType, ".report", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("taskId", AAZStrType, ".task_id", typ_kwargs={"flags": {"required": True}}) + + execution_context = _builder.get(".properties.executionContext") + if execution_context is not None: + execution_context.set_prop("target", AAZObjectType, ".target") + execution_context.set_prop("trigger", AAZObjectType, ".trigger", typ_kwargs={"flags": {"required": True}}) + + target = _builder.get(".properties.executionContext.target") + if target is not None: + target.set_prop("excludePrefix", AAZListType, ".exclude_prefix") + target.set_prop("prefix", AAZListType, ".prefix") + + exclude_prefix = _builder.get(".properties.executionContext.target.excludePrefix") + if exclude_prefix is not None: + exclude_prefix.set_elements(AAZStrType, ".") + + prefix = _builder.get(".properties.executionContext.target.prefix") + if prefix is not None: + prefix.set_elements(AAZStrType, ".") + + trigger = _builder.get(".properties.executionContext.trigger") + if trigger is not None: + trigger.set_prop("parameters", AAZObjectType, ".parameters", typ_kwargs={"flags": {"required": True}}) + trigger.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + + parameters = _builder.get(".properties.executionContext.trigger.parameters") + if parameters is not None: + parameters.set_prop("endBy", AAZStrType, ".end_by") + parameters.set_prop("interval", AAZIntType, ".interval") + parameters.set_prop("intervalUnit", AAZStrType, ".interval_unit") + parameters.set_prop("startFrom", AAZStrType, ".start_from") + parameters.set_prop("startOn", AAZStrType, ".start_on") + + report = _builder.get(".properties.report") + if report is not None: + report.set_prop("prefix", AAZStrType, ".prefix", typ_kwargs={"flags": {"required": True}}) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_storage_task_assignment_read = None + + @classmethod + def _build_schema_storage_task_assignment_read(cls, _schema): + if cls._schema_storage_task_assignment_read is not None: + _schema.id = cls._schema_storage_task_assignment_read.id + _schema.name = cls._schema_storage_task_assignment_read.name + _schema.properties = cls._schema_storage_task_assignment_read.properties + _schema.type = cls._schema_storage_task_assignment_read.type + return + + cls._schema_storage_task_assignment_read = _schema_storage_task_assignment_read = AAZObjectType() + + storage_task_assignment_read = _schema_storage_task_assignment_read + storage_task_assignment_read.id = AAZStrType( + flags={"read_only": True}, + ) + storage_task_assignment_read.name = AAZStrType( + flags={"read_only": True}, + ) + storage_task_assignment_read.properties = AAZObjectType( + flags={"required": True}, + ) + storage_task_assignment_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_storage_task_assignment_read.properties + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.execution_context = AAZObjectType( + serialized_name="executionContext", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.report = AAZObjectType( + flags={"required": True}, + ) + properties.run_status = AAZObjectType( + serialized_name="runStatus", + ) + properties.task_id = AAZStrType( + serialized_name="taskId", + flags={"required": True}, + ) + + execution_context = _schema_storage_task_assignment_read.properties.execution_context + execution_context.target = AAZObjectType() + execution_context.trigger = AAZObjectType( + flags={"required": True}, + ) + + target = _schema_storage_task_assignment_read.properties.execution_context.target + target.exclude_prefix = AAZListType( + serialized_name="excludePrefix", + ) + target.prefix = AAZListType() + + exclude_prefix = _schema_storage_task_assignment_read.properties.execution_context.target.exclude_prefix + exclude_prefix.Element = AAZStrType() + + prefix = _schema_storage_task_assignment_read.properties.execution_context.target.prefix + prefix.Element = AAZStrType() + + trigger = _schema_storage_task_assignment_read.properties.execution_context.trigger + trigger.parameters = AAZObjectType( + flags={"required": True}, + ) + trigger.type = AAZStrType( + flags={"required": True}, + ) + + parameters = _schema_storage_task_assignment_read.properties.execution_context.trigger.parameters + parameters.end_by = AAZStrType( + serialized_name="endBy", + ) + parameters.interval = AAZIntType() + parameters.interval_unit = AAZStrType( + serialized_name="intervalUnit", + ) + parameters.start_from = AAZStrType( + serialized_name="startFrom", + ) + parameters.start_on = AAZStrType( + serialized_name="startOn", + ) + + report = _schema_storage_task_assignment_read.properties.report + report.prefix = AAZStrType( + flags={"required": True}, + ) + + run_status = _schema_storage_task_assignment_read.properties.run_status + run_status.finish_time = AAZStrType( + serialized_name="finishTime", + flags={"read_only": True}, + ) + run_status.object_failed_count = AAZStrType( + serialized_name="objectFailedCount", + flags={"read_only": True}, + ) + run_status.objects_operated_on_count = AAZStrType( + serialized_name="objectsOperatedOnCount", + flags={"read_only": True}, + ) + run_status.objects_succeeded_count = AAZStrType( + serialized_name="objectsSucceededCount", + flags={"read_only": True}, + ) + run_status.objects_targeted_count = AAZStrType( + serialized_name="objectsTargetedCount", + flags={"read_only": True}, + ) + run_status.run_result = AAZStrType( + serialized_name="runResult", + flags={"read_only": True}, + ) + run_status.run_status_enum = AAZStrType( + serialized_name="runStatusEnum", + flags={"read_only": True}, + ) + run_status.run_status_error = AAZStrType( + serialized_name="runStatusError", + flags={"read_only": True}, + ) + run_status.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + run_status.storage_account_id = AAZStrType( + serialized_name="storageAccountId", + flags={"read_only": True}, + ) + run_status.summary_report_path = AAZStrType( + serialized_name="summaryReportPath", + flags={"read_only": True}, + ) + run_status.task_assignment_id = AAZStrType( + serialized_name="taskAssignmentId", + flags={"read_only": True}, + ) + run_status.task_id = AAZStrType( + serialized_name="taskId", + flags={"read_only": True}, + ) + run_status.task_version = AAZStrType( + serialized_name="taskVersion", + flags={"read_only": True}, + ) + + _schema.id = cls._schema_storage_task_assignment_read.id + _schema.name = cls._schema_storage_task_assignment_read.name + _schema.properties = cls._schema_storage_task_assignment_read.properties + _schema.type = cls._schema_storage_task_assignment_read.type + + +__all__ = ["Update"] diff --git a/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_wait.py b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_wait.py new file mode 100644 index 00000000000..e19139abfca --- /dev/null +++ b/src/storage-preview/azext_storage_preview/aaz/latest/storage/account/task_assignment/_wait.py @@ -0,0 +1,322 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "storage account task-assignment 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.storage/storageaccounts/{}/storagetaskassignments/{}", "2023-05-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.account_name = AAZStrArg( + options=["--account-name"], + help="The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]+$", + max_length=24, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.storage_task_assignment_name = AAZStrArg( + options=["-n", "--name", "--storage-task-assignment-name"], + help="The name of the storage task assignment within the specified resource group. Storage task assignment names must be between 3 and 24 characters in length and use numbers and lower-case letters only.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9]{3,24}$", + max_length=24, + min_length=3, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.StorageTaskAssignmentsGet(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 StorageTaskAssignmentsGet(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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + **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( + "accountName", self.ctx.args.account_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "storageTaskAssignmentName", self.ctx.args.storage_task_assignment_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-05-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType( + flags={"required": True}, + ) + properties.enabled = AAZBoolType( + flags={"required": True}, + ) + properties.execution_context = AAZObjectType( + serialized_name="executionContext", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.report = AAZObjectType( + flags={"required": True}, + ) + properties.run_status = AAZObjectType( + serialized_name="runStatus", + ) + properties.task_id = AAZStrType( + serialized_name="taskId", + flags={"required": True}, + ) + + execution_context = cls._schema_on_200.properties.execution_context + execution_context.target = AAZObjectType() + execution_context.trigger = AAZObjectType( + flags={"required": True}, + ) + + target = cls._schema_on_200.properties.execution_context.target + target.exclude_prefix = AAZListType( + serialized_name="excludePrefix", + ) + target.prefix = AAZListType() + + exclude_prefix = cls._schema_on_200.properties.execution_context.target.exclude_prefix + exclude_prefix.Element = AAZStrType() + + prefix = cls._schema_on_200.properties.execution_context.target.prefix + prefix.Element = AAZStrType() + + trigger = cls._schema_on_200.properties.execution_context.trigger + trigger.parameters = AAZObjectType( + flags={"required": True}, + ) + trigger.type = AAZStrType( + flags={"required": True}, + ) + + parameters = cls._schema_on_200.properties.execution_context.trigger.parameters + parameters.end_by = AAZStrType( + serialized_name="endBy", + ) + parameters.interval = AAZIntType() + parameters.interval_unit = AAZStrType( + serialized_name="intervalUnit", + ) + parameters.start_from = AAZStrType( + serialized_name="startFrom", + ) + parameters.start_on = AAZStrType( + serialized_name="startOn", + ) + + report = cls._schema_on_200.properties.report + report.prefix = AAZStrType( + flags={"required": True}, + ) + + run_status = cls._schema_on_200.properties.run_status + run_status.finish_time = AAZStrType( + serialized_name="finishTime", + flags={"read_only": True}, + ) + run_status.object_failed_count = AAZStrType( + serialized_name="objectFailedCount", + flags={"read_only": True}, + ) + run_status.objects_operated_on_count = AAZStrType( + serialized_name="objectsOperatedOnCount", + flags={"read_only": True}, + ) + run_status.objects_succeeded_count = AAZStrType( + serialized_name="objectsSucceededCount", + flags={"read_only": True}, + ) + run_status.objects_targeted_count = AAZStrType( + serialized_name="objectsTargetedCount", + flags={"read_only": True}, + ) + run_status.run_result = AAZStrType( + serialized_name="runResult", + flags={"read_only": True}, + ) + run_status.run_status_enum = AAZStrType( + serialized_name="runStatusEnum", + flags={"read_only": True}, + ) + run_status.run_status_error = AAZStrType( + serialized_name="runStatusError", + flags={"read_only": True}, + ) + run_status.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + run_status.storage_account_id = AAZStrType( + serialized_name="storageAccountId", + flags={"read_only": True}, + ) + run_status.summary_report_path = AAZStrType( + serialized_name="summaryReportPath", + flags={"read_only": True}, + ) + run_status.task_assignment_id = AAZStrType( + serialized_name="taskAssignmentId", + flags={"read_only": True}, + ) + run_status.task_id = AAZStrType( + serialized_name="taskId", + flags={"read_only": True}, + ) + run_status.task_version = AAZStrType( + serialized_name="taskVersion", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/storage-preview/azext_storage_preview/azext_metadata.json b/src/storage-preview/azext_storage_preview/azext_metadata.json index 8138e860821..b1e08d1f4b1 100644 --- a/src/storage-preview/azext_storage_preview/azext_metadata.json +++ b/src/storage-preview/azext_storage_preview/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isPreview": true, - "azext.minCliCoreVersion": "2.50.0" + "azext.minCliCoreVersion": "2.61.0" } \ No newline at end of file