-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Storage] az storage advanced-platform-metric create/update/show/list/delete: Support Advanced Platform Metrics
#33224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
calvinhzy
merged 4 commits into
Azure:dev
from
calvinhzy:storage-advanced-platform-metric
Apr 27, 2026
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...re/cli/command_modules/storage/aaz/latest/storage/advanced_platform_metric/__cmd_group.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| @register_command_group( | ||
| "storage advanced-platform-metric", | ||
| is_preview=True, | ||
| ) | ||
| class __CMDGroup(AAZCommandGroup): | ||
| """Manage Advanced Platform Metric | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| __all__ = ["__CMDGroup"] |
16 changes: 16 additions & 0 deletions
16
...azure/cli/command_modules/storage/aaz/latest/storage/advanced_platform_metric/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 * |
310 changes: 310 additions & 0 deletions
310
.../azure/cli/command_modules/storage/aaz/latest/storage/advanced_platform_metric/_create.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,310 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. 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 advanced-platform-metric create", | ||
| is_preview=True, | ||
| ) | ||
| class Create(AAZCommand): | ||
| """Create the advanced platform metrics rule for the storage account. | ||
|
|
||
| :example: Create AllContainersFilter AdvancedPlatformMetric | ||
| az storage advanced-platform-metric create -g resource_group_name --account-name storage_account_name --enabled --rule-config-filter-type AllContainersFilter | ||
|
|
||
| :example: Create ContainerPrefixFilter AdvancedPlatformMetric | ||
| az storage advanced-platform-metric create -g resource_group_name --account-name storage_account_name --enabled --rule-config-filter-type ContainerPrefixFilter --rule-config-filter-value logsprefix dataprefix | ||
|
|
||
| :example: Create ContainerListFilter AdvancedPlatformMetric | ||
| az storage advanced-platform-metric create -g resource_group_name --account-name storage_account_name --enabled --rule-config-filter-type ContainerListFilter --rule-config-filter-value logs data | ||
| """ | ||
|
|
||
| _aaz_info = { | ||
| "version": "2026-04-01", | ||
| "resources": [ | ||
| ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.storage/storageaccounts/{}/advancedplatformmetrics/{}", "2026-04-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, | ||
| fmt=AAZStrArgFormat( | ||
| pattern="^[a-z0-9]+$", | ||
| max_length=24, | ||
| min_length=3, | ||
| ), | ||
| ) | ||
| _args_schema.advanced_platform_metrics_rule_type = AAZStrArg( | ||
| options=["-n", "--name", "--advanced-platform-metrics-rule-type"], | ||
| help="The type of the advanced platform metrics rule.", | ||
| required=True, | ||
| default="ContainerLevelCapacityMetrics", | ||
| enum={"ContainerLevelCapacityMetrics": "ContainerLevelCapacityMetrics"}, | ||
| ) | ||
| _args_schema.resource_group = AAZResourceGroupNameArg( | ||
| required=True, | ||
| ) | ||
|
|
||
| # define Arg Group "Properties" | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.enabled = AAZBoolArg( | ||
| options=["--enabled"], | ||
| arg_group="Properties", | ||
| help="A boolean flag which enables the advanced platform metrics rule.", | ||
| ) | ||
|
|
||
| # define Arg Group "RuleConfig" | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.rule_config_filter_type = AAZStrArg( | ||
| options=["--filter-type", "--rule-config-filter-type"], | ||
| arg_group="RuleConfig", | ||
| help="The type of filter applied to the rule. Possible values include: AllContainersFilter, ContainerPrefixFilter, ContainerListFilter.", | ||
| enum={"AllContainersFilter": "AllContainersFilter", "ContainerListFilter": "ContainerListFilter", "ContainerPrefixFilter": "ContainerPrefixFilter"}, | ||
| ) | ||
| _args_schema.rule_config_filter_values = AAZListArg( | ||
| options=["--filter-values", "--rule-config-filter-values"], | ||
| arg_group="RuleConfig", | ||
| help="The values for the filter applied to the rule. If filter type is AllContainersFilter, filter values should be empty. If filter type is ContainerPrefixFilter, filter values should contain a list of container prefixes. If filter type is ContainerListFilter, filter values should contain a list of container names.", | ||
| ) | ||
|
|
||
| rule_config_filter_values = cls._args_schema.rule_config_filter_values | ||
| rule_config_filter_values.Element = AAZStrArg() | ||
| return cls._args_schema | ||
|
|
||
| def _execute_operations(self): | ||
| self.pre_operations() | ||
| self.AdvancedPlatformMetricsCreateOrUpdate(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 AdvancedPlatformMetricsCreateOrUpdate(AAZHttpOperation): | ||
| CLIENT_TYPE = "MgmtClient" | ||
|
|
||
| def __call__(self, *args, **kwargs): | ||
| request = self.make_request() | ||
| session = self.client.send_request(request=request, stream=False, **kwargs) | ||
| if session.http_response.status_code in [200, 201]: | ||
| return self.on_200_201(session) | ||
|
|
||
| return self.on_error(session.http_response) | ||
|
|
||
| @property | ||
| def url(self): | ||
| return self.client.format_url( | ||
| "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/advancedPlatformMetrics/{advancedPlatformMetricsRuleType}", | ||
| **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( | ||
| "advancedPlatformMetricsRuleType", self.ctx.args.advanced_platform_metrics_rule_type, | ||
| 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", "2026-04-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) | ||
|
|
||
| properties = _builder.get(".properties") | ||
| if properties is not None: | ||
| properties.set_prop("enabled", AAZBoolType, ".enabled", typ_kwargs={"flags": {"required": True}}) | ||
| properties.set_prop("ruleConfig", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) | ||
|
|
||
| rule_config = _builder.get(".properties.ruleConfig") | ||
| if rule_config is not None: | ||
| rule_config.set_prop("filterType", AAZStrType, ".rule_config_filter_type") | ||
| rule_config.set_prop("filterValues", AAZListType, ".rule_config_filter_values") | ||
|
|
||
| filter_values = _builder.get(".properties.ruleConfig.filterValues") | ||
| if filter_values is not None: | ||
| filter_values.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.name = AAZStrType( | ||
| flags={"read_only": True}, | ||
| ) | ||
| _schema_on_200_201.properties = AAZObjectType() | ||
| _schema_on_200_201.system_data = AAZObjectType( | ||
| serialized_name="systemData", | ||
| flags={"read_only": True}, | ||
| ) | ||
| _schema_on_200_201.type = AAZStrType( | ||
| flags={"read_only": True}, | ||
| ) | ||
|
|
||
| properties = cls._schema_on_200_201.properties | ||
| properties.enabled = AAZBoolType( | ||
| flags={"required": True}, | ||
| ) | ||
| properties.last_modified_time = AAZStrType( | ||
| serialized_name="lastModifiedTime", | ||
| flags={"read_only": True}, | ||
| ) | ||
| properties.metrics_emitted = AAZListType( | ||
| serialized_name="metricsEmitted", | ||
| flags={"read_only": True}, | ||
| ) | ||
| properties.rule_config = AAZObjectType( | ||
| serialized_name="ruleConfig", | ||
| flags={"required": True}, | ||
| ) | ||
| properties.rule_type = AAZStrType( | ||
| serialized_name="ruleType", | ||
| flags={"read_only": True}, | ||
| ) | ||
|
|
||
| metrics_emitted = cls._schema_on_200_201.properties.metrics_emitted | ||
| metrics_emitted.Element = AAZStrType() | ||
|
|
||
| rule_config = cls._schema_on_200_201.properties.rule_config | ||
| rule_config.filter_type = AAZStrType( | ||
| serialized_name="filterType", | ||
| ) | ||
| rule_config.filter_values = AAZListType( | ||
| serialized_name="filterValues", | ||
| ) | ||
|
|
||
| filter_values = cls._schema_on_200_201.properties.rule_config.filter_values | ||
| filter_values.Element = AAZStrType() | ||
|
|
||
| system_data = cls._schema_on_200_201.system_data | ||
| system_data.created_at = AAZStrType( | ||
| serialized_name="createdAt", | ||
| ) | ||
| system_data.created_by = AAZStrType( | ||
| serialized_name="createdBy", | ||
| ) | ||
| system_data.created_by_type = AAZStrType( | ||
| serialized_name="createdByType", | ||
| ) | ||
| system_data.last_modified_at = AAZStrType( | ||
| serialized_name="lastModifiedAt", | ||
| ) | ||
| system_data.last_modified_by = AAZStrType( | ||
| serialized_name="lastModifiedBy", | ||
| ) | ||
| system_data.last_modified_by_type = AAZStrType( | ||
| serialized_name="lastModifiedByType", | ||
| ) | ||
|
|
||
| return cls._schema_on_200_201 | ||
|
|
||
|
|
||
| class _CreateHelper: | ||
| """Helper class for Create""" | ||
|
|
||
|
|
||
| __all__ = ["Create"] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.