Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -55,52 +55,4 @@ def _register_network_resource_breaking_change(command_name):
# Name of new backup no longer required in backup create command
register_other_breaking_change('postgres flexible-server backup create',
message='The argument for backup name will no longer be required '
'in next breaking change release(2.86.0) scheduled for May 2026.')

# LTR command argument changes
register_other_breaking_change('postgres flexible-server long-term-retention',
message='The --backup-name/-b argument has been deprecated and will be removed '
'in next breaking change release(2.86.0) scheduled for May 2026.')
register_other_breaking_change('postgres flexible-server long-term-retention',
message='The --name/-n argument will be repurposed to specify the backup name. '
'The --server-name/-s argument will be introduced to specify the server name '
'in next breaking change release(2.86.0) scheduled for May 2026.')

# Backup command argument changes
register_other_breaking_change('postgres flexible-server backup',
message='The --backup-name/-b argument has been deprecated and will be removed '
'in next breaking change release(2.86.0) scheduled for May 2026.')
register_other_breaking_change('postgres flexible-server backup',
message='The --name/-n argument will be repurposed to specify the backup name. '
'The --server-name/-s argument will be introduced to specify the server name '
'in next breaking change release(2.86.0) scheduled for May 2026.')

# Database command argument changes
register_other_breaking_change('postgres flexible-server db',
message='The --database-name/-d argument has been deprecated and will be removed '
'in next breaking change release(2.86.0) scheduled for May 2026.')
register_other_breaking_change('postgres flexible-server db',
message='The --name/-n argument will be repurposed to specify the database name. '
'The --server-name/-s argument will be introduced to specify the server name '
'in next breaking change release(2.86.0) scheduled for May 2026.')

# Firewall rule command argument changes
register_other_breaking_change('postgres flexible-server firewall-rule',
message='The --name/-n argument will be repurposed to specify the firewall rule '
'name. The --server-name/-s argument will be introduced to specify the server '
'name in next breaking change release(2.86.0) scheduled for May 2026.')
register_other_breaking_change('postgres flexible-server firewall-rule',
message='The --rule-name/-r argument has been deprecated and will be removed '
'in next breaking change release(2.86.0) scheduled for May 2026.')

# Migration command argument changes
register_other_breaking_change('postgres flexible-server migration',
message='The --migration-name argument has been deprecated and will be removed '
'in next breaking change release(2.86.0) scheduled for May 2026.')
register_other_breaking_change('postgres flexible-server migration',
message='The --name/-n argument will be repurposed to specify the migration name. '
'The --server-name/-s argument will be introduced to specify the server name '
'in next breaking change release(2.86.0) scheduled for May 2026.')

# Replica command argument changes
register_argument_deprecate('postgres flexible-server replica create', '--replica-name', redirect='--name')
'in the next breaking change release (2.86.0) scheduled for May 2026.')
78 changes: 39 additions & 39 deletions src/azure-cli/azure/cli/command_modules/postgresql/_help.py

Large diffs are not rendered by default.

40 changes: 30 additions & 10 deletions src/azure-cli/azure/cli/command_modules/postgresql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ def _flexible_server_params(command_group):
actions=[LocalContextAction.GET, LocalContextAction.SET],
scopes=['{} flexible-server'.format(command_group)]))

database_object_name_arg_type = CLIArgumentType(
metavar='NAME',
options_list=['--name', '-n'],
id_part='child_name_1',
help='The name of the database',
local_context_attribute=LocalContextAttribute(
name='database_name',
actions=[LocalContextAction.GET, LocalContextAction.SET],
scopes=['{} flexible-server'.format(command_group)]))

database_name_arg_type_cluster = CLIArgumentType(
metavar='NAME',
options_list=['--database-name', '-d'],
Expand Down Expand Up @@ -544,13 +554,17 @@ def _flexible_server_params(command_group):
for scope in ['create', 'delete', 'show', 'update']:
argument_context_string = '{} flexible-server firewall-rule {}'.format(command_group, scope)
with self.argument_context(argument_context_string) as c:
c.argument('firewall_rule_name', id_part='child_name_1', options_list=['--rule-name', '-r'], validator=postgres_firewall_rule_name_validator,
help='The name of the firewall rule. If name is omitted, default name will be chosen for firewall name. The firewall rule name can only contain 0-9, a-z, A-Z, \'-\' and \'_\'. Additionally, the name of the firewall rule must be at least 3 characters and no more than 128 characters in length. ')
c.argument('server_name', arg_type=server_name_resource_arg_type)
c.argument('firewall_rule_name', id_part='child_name_1', options_list=['--name', '-n'], validator=postgres_firewall_rule_name_validator,
help='The name of the firewall rule. If name is omitted, default name will be chosen for firewall rule name. The firewall rule name can only contain 0-9, a-z, A-Z, \'-\' and \'_\'. Additionally, the name of the firewall rule must be at least 3 characters and no more than 128 characters in length. ')
c.argument('end_ip_address', options_list=['--end-ip-address'], validator=ip_address_validator,
Comment thread
nachoalonsoportillo marked this conversation as resolved.
help='The end IP address of the firewall rule. Must be IPv4 format. Use value \'0.0.0.0\' to represent all Azure-internal IP addresses. ')
c.argument('start_ip_address', options_list=['--start-ip-address'], validator=ip_address_validator,
help='The start IP address of the firewall rule. Must be IPv4 format. Use value \'0.0.0.0\' to represent all Azure-internal IP addresses. ')

with self.argument_context('{} flexible-server firewall-rule list'.format(command_group)) as c:
c.argument('server_name', arg_type=server_name_resource_arg_type)

with self.argument_context('{} flexible-server firewall-rule delete'.format(command_group)) as c:
c.argument('yes', arg_type=yes_arg_type)

Expand All @@ -559,7 +573,7 @@ def _flexible_server_params(command_group):
argument_context_string = '{} flexible-server db {}'.format(command_group, scope)
with self.argument_context(argument_context_string) as c:
c.argument('server_name', arg_type=server_name_resource_arg_type)
c.argument('database_name', arg_type=database_name_arg_type)
c.argument('database_name', arg_type=database_object_name_arg_type)

with self.argument_context('{} flexible-server db create'.format(command_group)) as c:
c.argument('charset', help='The charset of the database. The default value is UTF8')
Expand Down Expand Up @@ -589,7 +603,11 @@ def _flexible_server_params(command_group):
for scope in ['show', 'start', 'pre-check']:
argument_context_string = '{} flexible-server long-term-retention {}'.format(command_group, scope)
with self.argument_context(argument_context_string) as c:
c.argument('backup_name', options_list=['--backup-name', '-b'], help='Long-term retention backup name.')
c.argument('server_name', arg_type=server_name_resource_arg_type)
c.argument('backup_name', options_list=['--name', '-n'], help='Long-term retention backup name.')

with self.argument_context('{} flexible-server long-term-retention list'.format(command_group)) as c:
c.argument('server_name', arg_type=server_name_resource_arg_type)

with self.argument_context('{} flexible-server long-term-retention start'.format(command_group)) as c:
c.argument('sas_url', options_list=['--sas-url', '-u'], help='Container SAS URL.')
Expand All @@ -605,9 +623,7 @@ def _flexible_server_params(command_group):
# replica
with self.argument_context('{} flexible-server replica create'.format(command_group)) as c:
c.argument('source_server', arg_type=source_server_arg_type)
c.argument('replica_name', options_list=['--replica-name'],
help='The name of the read replica.')
c.argument('name', options_list=['--name', '-n'],
c.argument('name', options_list=['--name', '-n'], required=True,
help='The name of the read replica.')
c.argument('zone', arg_type=zone_arg_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx))
Expand Down Expand Up @@ -651,7 +667,11 @@ def _flexible_server_params(command_group):
for scope in ['show', 'create', 'delete']:
argument_context_string = '{} flexible-server backup {}'.format(command_group, scope)
with self.argument_context(argument_context_string) as c:
c.argument('backup_name', id_part='child_name_1', options_list=['--backup-name', '-b'], help='The name of the backup.')
c.argument('server_name', arg_type=server_name_resource_arg_type)
c.argument('backup_name', id_part='child_name_1', options_list=['--name', '-n'], help='The name of the backup.')

with self.argument_context('{} flexible-server backup list'.format(command_group)) as c:
c.argument('server_name', arg_type=server_name_resource_arg_type)

with self.argument_context('{} flexible-server backup delete'.format(command_group)) as c:
c.argument('yes', arg_type=yes_arg_type)
Expand Down Expand Up @@ -810,7 +830,7 @@ def _flexible_server_params(command_group):
help='Value of the tuning setting.')

# migration
handle_migration_parameters(command_group, server_name_arg_type, migration_id_arg_type)
handle_migration_parameters(command_group, server_name_resource_arg_type, migration_id_arg_type)

def handle_migration_parameters(command_group, server_name_arg_type, migration_id_arg_type):
for scope in ['create', 'show', 'list', 'update', 'check-name-availability']:
Expand All @@ -819,7 +839,7 @@ def handle_migration_parameters(command_group, server_name_arg_type, migration_i
c.argument('server_name', arg_type=server_name_arg_type, help='Migration target server name.')

if scope == "create" or scope == "update" or scope == "show" or scope == "check-name-availability":
c.argument('migration_name', arg_type=migration_id_arg_type, options_list=['--migration-name'],
c.argument('migration_name', arg_type=migration_id_arg_type, options_list=['--name', '-n'],
help='Name of the migration.')

if scope == "create":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def database_delete_func(cmd, client, resource_group_name=None, server_name=None

result = None
if resource_group_name is None or server_name is None or database_name is None:
raise CLIError("Incorrect Usage : Deleting a database needs resource-group, server-name and database-name. "
raise CLIError("Incorrect Usage : Deleting a database needs --resource-group, --server-name and --name. "
"If your parameter persistence is turned ON, make sure these three parameters exist in "
"persistent parameters using \'az config param-persist show\'. "
"If your parameter persistence is turned OFF, consider passing them explicitly.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# --------------------------------------------------------------------------------------------

# pylint: disable=unused-argument, line-too-long
from azure.cli.core.azclierror import MutuallyExclusiveArgumentError, RequiredArgumentMissingError, ValidationError
from azure.cli.core.azclierror import RequiredArgumentMissingError, ValidationError
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import CLIError, sdk_no_wait
from azure.core.exceptions import ResourceNotFoundError
Expand All @@ -29,19 +29,17 @@


# pylint: disable=too-many-locals
def flexible_replica_create(cmd, client, resource_group_name, source_server, replica_name=None, name=None, zone=None,
def flexible_replica_create(cmd, client, resource_group_name, source_server, name=None, zone=None,
location=None, vnet=None, vnet_address_prefix=None, subnet=None,
subnet_address_prefix=None, private_dns_zone_arguments=None, no_wait=False,
byok_identity=None, byok_key=None,
sku_name=None, tier=None, storage_type=None,
storage_gb=None, performance_tier=None, yes=False, tags=None):
validate_resource_group(resource_group_name)

if replica_name is None and name is None:
if name is None:
raise RequiredArgumentMissingError('the following arguments are required: --name')
if replica_name is not None and name is not None:
raise MutuallyExclusiveArgumentError('usage error: --name and --replica-name cannot be used together. Please use --name.')
replica_name = replica_name.lower() if name is None else name.lower()
replica_name = name.lower()

if not is_valid_resource_id(source_server):
if _is_resource_name(source_server):
Expand Down
Loading
Loading