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
21 changes: 18 additions & 3 deletions src/azure-cli/azure/cli/command_modules/sql/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,33 @@
helps['sql db str-policy set'] = """
type: command
short-summary: Update short term retention settings for a live database.
long-summary: Locking backup immutability is irreversible. Confirmation is required only when --lock-immutability is true. Use --yes to skip confirmation. Include --retention-days when locking. To preserve retention, use the current value from str-policy show. When increasing retention on a locked policy, also specify --lock-immutability true. Use str-policy show to check the policy after a --no-wait update.
examples:
- name: Set short term retention for a live database.
text: az sql db str-policy set -g mygroup -s myserver -n mydb --retention-days retentionindays --diffbackup-hours diffbackuphours
text: az sql db str-policy set --resource-group mygroup --server myserver --name mydb --retention-days 7 --diffbackup-hours 24
- name: Lock backup immutability with seven-day retention, skipping confirmation.
text: az sql db str-policy set --resource-group mygroup --server myserver --name mydb --retention-days 7 --lock-immutability true --yes
"""

helps['sql db str-policy show'] = """
type: command
short-summary: Show the short term retention policy for a live database.
long-summary: The immutabilityStatus output property reports Disabled, Enabled or Locked when returned by the service.
examples:
- name: Show short term retention policy for a live database.
text: az sql db str-policy show -g mygroup -s myserver -n mydb
- name: Show the current backup immutability status.
text: az sql db str-policy show --resource-group mygroup --server myserver --name mydb --query immutabilityStatus
"""

helps['sql db str-policy wait'] = """
type: command
short-summary: Place the CLI in a waiting state until the policy is set.
examples:
- name: Wait until the default short term retention policy exists.
text: az sql db str-policy wait --resource-group mygroup --server myserver --name mydb --policy-name default --exists
- name: Wait until backup immutability is locked.
text: az sql db str-policy wait --resource-group mygroup --server myserver --name mydb --policy-name default --custom "immutabilityStatus=='Locked'"
"""

helps['sql db ltr-policy'] = """
Expand Down Expand Up @@ -1212,16 +1223,20 @@
helps['sql midb short-term-retention-policy set'] = """
type: command
short-summary: Update short term retention for automated backups on a single database.
long-summary: Locking backup immutability is irreversible and is supported only for live managed databases. Confirmation is required only when --lock-immutability is true; use --yes to skip it. Do not specify --lock-immutability with --deleted-time, even when false. Retention cannot be reduced on a dropped database whose backup immutability is locked.
examples:
- name: Set backup short term retention for live managed database.
text: az sql midb short-term-retention-policy set -g mygroup --mi myinstance -n mymanageddb --retention-days retentionindays
text: az sql midb short-term-retention-policy set -g mygroup --mi myinstance -n mymanageddb --retention-days 7
- name: Set backup short term retention for dropped managed database.
text: az sql midb short-term-retention-policy set -g mygroup --mi myinstance -n mymanageddb --deleted-time "2018-05-20T05:34:22" --retention-days retentionindays
text: az sql midb short-term-retention-policy set -g mygroup --mi myinstance -n mymanageddb --deleted-time "2018-05-20T05:34:22" --retention-days 7
- name: Lock backup immutability for a live managed database, skipping confirmation.
text: az sql midb short-term-retention-policy set --resource-group mygroup --mi myinstance --name mymanageddb --retention-days 7 --lock-immutability true --yes
"""

helps['sql midb short-term-retention-policy show'] = """
type: command
short-summary: Show short term retention for automated backups on a single database.
long-summary: The immutabilityStatus output property reports Disabled, Enabled or Locked for live and restorable dropped managed databases when returned by the service.
examples:
- name: Shows backup short term retention for live managed database.
text: az sql midb short-term-retention-policy show -g mygroup --mi myinstance -n mymanageddb
Expand Down
47 changes: 28 additions & 19 deletions src/azure-cli/azure/cli/command_modules/sql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,24 +1506,29 @@ def _configure_security_policy_storage_params(arg_ctx):
# sql db str #
###############################################
with self.argument_context('sql db str-policy set') as c:
create_args_for_complex_type(
c, 'parameters', Database, [
'retention_days',
'diffbackup_hours'
])

c.argument(
'retention_days',
options_list=['--retention-days'],
required=True,
type=int,
required=False,
help='New backup short term retention policy retention in days.'
'Valid retention days for live database of (DTU) Basic can be 1-7 days; Rest models can be 1-35 days.')

c.argument(
'diffbackup_hours',
options_list=['--diffbackup-hours'],
type=int,
help='New backup short term retention policy differential backup interval in hours.'
'Valid differential backup interval for live database can be 12 or 24 hours.')
c.argument(
'lock_immutability',
arg_type=get_three_state_flag(),
help='Whether to lock backup immutability. Locking is irreversible. '
'Setting false does not unlock an already locked policy.')
c.argument(
'yes',
options_list=['--yes', '-y'],
action='store_true',
help='Do not prompt for confirmation when locking backup immutability.')

###############################################
# sql dw #
Expand Down Expand Up @@ -2825,24 +2830,28 @@ class ContainerIdentityType(Enum):
help='The id of recoverable database from geo-replicated instance')

with self.argument_context('sql midb short-term-retention-policy set') as c:
create_args_for_complex_type(
c, 'parameters', ManagedDatabase, [
'deleted_time',
'retention_days'
])

c.argument(
'deleted_time',
options_list=['--deleted-time'],
help='If specified, updates retention days for a deleted database, instead of an existing database.'
'Must match the deleted time of a deleted database on the source Managed Instance.')

help='If specified, updates retention days for a deleted database, instead of an existing database. '
'Must match the deleted time of a deleted database on the source Managed Instance.')
c.argument(
'retention_days',
options_list=['--retention-days'],
type=int,
required=True,
help='New backup short term retention policy in days.'
'Valid policy for live database is 7-35 days, valid policy for dropped databases is 0-35 days.')
help='New backup short term retention policy in days. '
'Valid policy for live database is 7-35 days, valid policy for dropped databases is 0-35 days.')
c.argument(
'lock_immutability',
arg_type=get_three_state_flag(),
help='Whether to lock backup immutability for a live managed database. '
'Locking is irreversible. Cannot be used with --deleted-time, even when false.')
c.argument(
'yes',
options_list=['--yes', '-y'],
action='store_true',
help='Do not prompt for confirmation when locking backup immutability.')

with self.argument_context('sql midb short-term-retention-policy show') as c:
c.argument(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------------------------
# 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 *


class __CMDGroup(AAZCommandGroup):
"""Manage databases.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------------------------
# 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 *


class __CMDGroup(AAZCommandGroup):
"""Manage SQL database short-term retention policies.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._set import *
from ._show import *
Loading
Loading