Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('properties', or_policy_type, validator=validate_or_policy)
c.argument('prefix_match', prefix_math_type)
c.argument('min_creation_time', min_creation_time_type)
c.argument('enable_metrics', arg_type=get_three_state_flag(),
help='Indicates whether object replication metrics feature is enabled for the policy.')
Comment on lines +797 to +798
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help message should start with a verb in the imperative voice. Consider changing 'Indicates whether...' to 'Enable or disable object replication metrics for the policy.'

Copilot uses AI. Check for mistakes.

for item in ['create', 'update']:
with self.argument_context('storage account or-policy {}'.format(item),
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/storage/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.MGM
operations_tmpl='azure.cli.command_modules.storage.operations.account#{}',
client_factory=cf_or_policy)

with self.command_group('storage account or-policy', or_policy_sdk, is_preview=True,
with self.command_group('storage account or-policy', or_policy_sdk,
resource_type=ResourceType.MGMT_STORAGE,
custom_command_type=or_policy_custom_type) as g:
g.show_command('show', 'get')
Expand All @@ -222,7 +222,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.MGM
g.generic_update_command('update', setter_name='update_or_policy', setter_type=or_policy_custom_type)
g.command('delete', 'delete')

with self.command_group('storage account or-policy rule', or_policy_sdk, is_preview=True,
with self.command_group('storage account or-policy rule', or_policy_sdk,
resource_type=ResourceType.MGMT_STORAGE,
custom_command_type=or_policy_custom_type) as g:
g.custom_show_command('show', 'get_or_rule')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,14 +988,15 @@ def list_encryption_scope(client, resource_group_name, account_name,
# pylint: disable=no-member
def create_or_policy(cmd, client, account_name, resource_group_name=None, properties=None, source_account=None,
destination_account=None, policy_id="default", rule_id=None, source_container=None,
destination_container=None, min_creation_time=None, prefix_match=None):
destination_container=None, min_creation_time=None, prefix_match=None, enable_metrics=None):
from azure.core.exceptions import HttpResponseError
ObjectReplicationPolicy = cmd.get_models('ObjectReplicationPolicy')

if properties is None:
rules = []
ObjectReplicationPolicyRule, ObjectReplicationPolicyFilter = \
cmd.get_models('ObjectReplicationPolicyRule', 'ObjectReplicationPolicyFilter')
ObjectReplicationPolicyRule, ObjectReplicationPolicyFilter, ObjectReplicationPolicyPropertiesMetrics = \
cmd.get_models('ObjectReplicationPolicyRule', 'ObjectReplicationPolicyFilter',
'ObjectReplicationPolicyPropertiesMetrics')
if source_container and destination_container:
rule = ObjectReplicationPolicyRule(
rule_id=rule_id,
Expand All @@ -1006,7 +1007,8 @@ def create_or_policy(cmd, client, account_name, resource_group_name=None, proper
rules.append(rule)
or_policy = ObjectReplicationPolicy(source_account=source_account,
destination_account=destination_account,
rules=rules)
rules=rules,
metrics=ObjectReplicationPolicyPropertiesMetrics(enabled=enable_metrics))
else:
or_policy = properties
try:
Expand All @@ -1021,8 +1023,8 @@ def create_or_policy(cmd, client, account_name, resource_group_name=None, proper
raise ex


def update_or_policy(client, parameters, resource_group_name, account_name, object_replication_policy_id=None,
properties=None, source_account=None, destination_account=None, ):
def update_or_policy(cmd, client, parameters, resource_group_name, account_name, object_replication_policy_id=None,
properties=None, source_account=None, destination_account=None, enable_metrics=None):

if source_account is not None:
parameters.source_account = source_account
Expand All @@ -1034,6 +1036,10 @@ def update_or_policy(client, parameters, resource_group_name, account_name, obje
if "policyId" in properties.keys() and properties["policyId"]:
object_replication_policy_id = properties["policyId"]

if enable_metrics is not None:
ObjectReplicationPolicyPropertiesMetrics = cmd.get_models('ObjectReplicationPolicyPropertiesMetrics')
parameters.metrics = ObjectReplicationPolicyPropertiesMetrics(enabled=enable_metrics)

return client.create_or_update(resource_group_name=resource_group_name, account_name=account_name,
object_replication_policy_id=object_replication_policy_id, properties=parameters)

Expand Down
Loading