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
20 changes: 20 additions & 0 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,26 @@ datafactory pipeline create-run:
reference_pipeline_run_id:
rule_exclusions:
- option_length_too_long
dataprotection backup-instance restore initialize-for-data-recovery-as-files:
parameters:
target_blob_container_url:
rule_exclusions:
- option_length_too_long
dataprotection backup-vault create:
parameters:
alerts_for_all_job_failures:
rule_exclusions:
- option_length_too_long
dataprotection backup-vault update:
parameters:
alerts_for_all_job_failures:
rule_exclusions:
- option_length_too_long
dataprotection resource-guard update:
parameters:
critical_operation_exclusion_list:
rule_exclusions:
- option_length_too_long
datashare consumer dataset-mapping create:
parameters:
share_subscription_name:
Expand Down
5 changes: 5 additions & 0 deletions src/dataprotection/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.4.0
++++++
* `az dataprotection resource-guard`: Onboard ResourceGuard to dataprotection extension
* `az dataprotection backup-vault create/update`: Add support for Azure Monitor based alerts

0.3.0
++++++
* API version upgrade with bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ def cf_job(cli_ctx, *_):

def cf_restorable_time_range(cli_ctx, *_):
return cf_dataprotection_cl(cli_ctx).restorable_time_ranges


def cf_resource_guard(cli_ctx, *_):
return cf_dataprotection_cl(cli_ctx).resource_guards
51 changes: 43 additions & 8 deletions src/dataprotection/azext_dataprotection/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
examples:
- name: Create BackupVault
text: |-
az dataprotection backup-vault create --type "None" --location "WestUS" --storage-settings \
type="LocallyRedundant" datastore-type="VaultStore" --tags key1="val1" --resource-group "SampleResourceGroup" \
--vault-name "swaggerExample"
az dataprotection backup-vault create --type "None" --location "WestUS" --azure-monitor-alerts-for-job-f\
ailures "Enabled" --storage-settings type="LocallyRedundant" datastore-type="VaultStore" --tags key1="val1" \
--resource-group "SampleResourceGroup" --vault-name "swaggerExample"
- name: Create BackupVault With MSI
text: |-
az dataprotection backup-vault create --type "systemAssigned" --location "WestUS" --storage-settings \
type="LocallyRedundant" datastore-type="VaultStore" --tags key1="val1" --resource-group "SampleResourceGroup" \
--vault-name "swaggerExample"
az dataprotection backup-vault create --type "systemAssigned" --location "WestUS" \
--azure-monitor-alerts-for-job-failures "Enabled" --storage-settings type="LocallyRedundant" \
datastore-type="VaultStore" --tags key1="val1" --resource-group "SampleResourceGroup" --vault-name "swaggerExample"
"""

helps['dataprotection backup-vault update'] = """
Expand All @@ -69,8 +69,8 @@
examples:
- name: Patch BackupVault
text: |-
az dataprotection backup-vault update --tags newKey="newVal" --resource-group "SampleResourceGroup" \
--vault-name "swaggerExample"
az dataprotection backup-vault update --azure-monitor-alerts-for-job-failures "Enabled" --tags \
newKey="newVal" --resource-group "SampleResourceGroup" --vault-name "swaggerExample"
"""

helps['dataprotection backup-vault delete'] = """
Expand Down Expand Up @@ -527,3 +527,38 @@
"2021-02-24T00:35:17.6829685Z" --source-data-store-type "OperationalStore" --start-time "2020-10-17T23:28:17.6829685Z" \
--resource-group "Blob-Backup" --vault-name "ZBlobBackupVaultBVTD3"
"""

helps['dataprotection resource-guard'] = """
type: group
short-summary: Manage resource guard with dataprotection
"""

helps['dataprotection resource-guard show'] = """
type: command
short-summary: "Returns a ResourceGuard belonging to a resource group."
examples:
- name: Get ResourceGuard
text: |-
az dataprotection resource-guard show --resource-group "SampleResourceGroup" --resource-guard-name \
"swaggerExample"
"""

helps['dataprotection resource-guard create'] = """
type: command
short-summary: "Creates or updates a ResourceGuard resource belonging to a resource group."
examples:
- name: Create ResourceGuard
text: |-
az dataprotection resource-guard create --location "WestUS" --tags key1="val1" --resource-group \
"SampleResourceGroup" --resource-guard-name "swaggerExample"
"""

helps['dataprotection resource-guard delete'] = """
type: command
short-summary: "Deletes a ResourceGuard resource from the resource group."
examples:
- name: Delete ResourceGuard
text: |-
az dataprotection resource-guard delete --resource-group "SampleResourceGroup" --resource-guard-name \
"swaggerExample"
"""
31 changes: 31 additions & 0 deletions src/dataprotection/azext_dataprotection/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ def load_arguments(self, _):
c.argument('type_', options_list=['--type'], type=str, help='The identityType which can be either '
'SystemAssigned or None', arg_group='Identity')
c.argument('storage_settings', action=AddStorageSettings, nargs='+', help='Storage Settings')
c.argument('alerts_for_all_job_failures', options_list=['--azure-monitor-alerts-for-job-failures'],
arg_type=get_enum_type(['Enabled', 'Disabled']), help='Property that specifies whether built-in '
'Azure Monitor alerts should be fired for all failed jobs', arg_group='Monitoring Settings Azure '
'Monitor Alert Settings')

with self.argument_context('dataprotection backup-vault update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('vault_name', type=str, help='The name of the backup vault.', id_part='name')
c.argument('tags', tags_type)
c.argument('alerts_for_all_job_failures', options_list=['--azure-monitor-alerts-for-job-failures'],
arg_type=get_enum_type(['Enabled', 'Disabled']), help='Property that specifies whether built-in '
'Azure Monitor alerts should be fired for all failed jobs', arg_group='Monitoring Settings Azure '
'Monitor Alert Settings')
c.argument('type_', options_list=['--type'], type=str, help='The identityType which can be either '
'SystemAssigned or None', arg_group='Identity')

Expand Down Expand Up @@ -221,3 +229,26 @@ def load_arguments(self, _):
arg_type=get_enum_type(['OperationalStore', 'VaultStore', 'ArchiveStore']))
c.argument('start_time', type=str, help='Start time for the List Restore Ranges request. ISO 8601 format.')
c.argument('end_time', type=str, help='End time for the List Restore Ranges request. ISO 8601 format.')

with self.argument_context('dataprotection resource-guard show') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('resource_guards_name', options_list=['--resource-guard-name', '--name', '-n'], type=str, help='The '
'name of ResourceGuard', id_part='name')

with self.argument_context('dataprotection resource-guard create') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('resource_guards_name', options_list=['--resource-guard-name', '--name', '-n'], type=str, help='The '
'name of ResourceGuard')
c.argument('e_tag', type=str, help='Optional ETag.')
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
c.argument('type_', options_list=['--type'], type=str, help='The identityType which can be either '
'SystemAssigned or None', arg_group='Identity')
c.argument('vault_critical_operation_exclusion_list', nargs='+', help='List of critical operations which are '
'not protected by this resourceGuard')

with self.argument_context('dataprotection resource-guard delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('resource_guards_name', options_list=['--resource-guard-name', '--name', '-n'], type=str, help='The '
'name of ResourceGuard', id_part='name')
14 changes: 14 additions & 0 deletions src/dataprotection/azext_dataprotection/generated/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
cf_recovery_point,
cf_job,
cf_restorable_time_range,
cf_resource_guard,
)


Expand Down Expand Up @@ -59,6 +60,12 @@
)


dataprotection_resource_guard = CliCommandType(
operations_tmpl='azext_dataprotection.vendored_sdks.dataprotection.operations._resource_guards_operations#ResourceGuardsOperations.{}',
client_factory=cf_resource_guard,
)


def load_command_table(self, _):

with self.command_group(
Expand Down Expand Up @@ -115,5 +122,12 @@ def load_command_table(self, _):
) as g:
g.custom_command('find', 'dataprotection_restorable_time_range_find')

with self.command_group(
'dataprotection resource-guard', dataprotection_resource_guard, client_factory=cf_resource_guard
) as g:
g.custom_show_command('show', 'dataprotection_resource_guard_show')
g.custom_command('create', 'dataprotection_resource_guard_create')
g.custom_command('delete', 'dataprotection_resource_guard_delete', confirmation=True)

with self.command_group('dataprotection', is_experimental=True):
pass
42 changes: 42 additions & 0 deletions src/dataprotection/azext_dataprotection/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=line-too-long
# pylint: disable=too-many-lines

from knack.util import CLIError
Expand All @@ -28,6 +29,7 @@ def dataprotection_backup_vault_create(client,
location=None,
tags=None,
type_=None,
alerts_for_all_job_failures=None,
no_wait=False):
parameters = {}
parameters['e_tag'] = e_tag
Expand All @@ -37,6 +39,8 @@ def dataprotection_backup_vault_create(client,
parameters['identity']['type'] = type_
parameters['properties'] = {}
parameters['properties']['storage_settings'] = storage_settings
parameters['properties']['azure_monitor_alert_settings'] = {}
parameters['properties']['azure_monitor_alert_settings']['alerts_for_all_job_failures'] = alerts_for_all_job_failures
return sdk_no_wait(no_wait,
client.begin_create_or_update,
resource_group_name=resource_group_name,
Expand All @@ -48,10 +52,13 @@ def dataprotection_backup_vault_update(client,
resource_group_name,
vault_name,
tags=None,
alerts_for_all_job_failures=None,
type_=None,
no_wait=False):
parameters = {}
parameters['tags'] = tags
parameters['azure_monitor_alert_settings'] = {}
parameters['azure_monitor_alert_settings']['alerts_for_all_job_failures'] = alerts_for_all_job_failures
parameters['identity'] = {}
parameters['identity']['type'] = type_
return sdk_no_wait(no_wait,
Expand Down Expand Up @@ -357,3 +364,38 @@ def dataprotection_restorable_time_range_find(client,
vault_name=vault_name,
backup_instance_name=backup_instance_name,
parameters=parameters)


def dataprotection_resource_guard_show(client,
resource_group_name,
resource_guards_name):
return client.get(resource_group_name=resource_group_name,
resource_guards_name=resource_guards_name)


def dataprotection_resource_guard_create(client,
resource_group_name,
resource_guards_name,
e_tag=None,
location=None,
tags=None,
type_=None,
vault_critical_operation_exclusion_list=None):
parameters = {}
parameters['e_tag'] = e_tag
parameters['location'] = location
parameters['tags'] = tags
parameters['identity'] = {}
parameters['identity']['type'] = type_
parameters['properties'] = {}
parameters['properties']['vault_critical_operation_exclusion_list'] = vault_critical_operation_exclusion_list
return client.put(resource_group_name=resource_group_name,
resource_guards_name=resource_guards_name,
parameters=parameters)


def dataprotection_resource_guard_delete(client,
resource_group_name,
resource_guards_name):
return client.delete(resource_group_name=resource_group_name,
resource_guards_name=resource_guards_name)
26 changes: 26 additions & 0 deletions src/dataprotection/azext_dataprotection/manual/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,32 @@
text: az dataprotection backup-vault list -g sarath-rg
"""

helps['dataprotection resource-guard list'] = """
type: command
short-summary: Gets list of ResourceGuards in a subscription or in a resource group.
examples:
- name: List ResourceGuards in a subscription
text: az dataprotection resource-guard list
- name: List ResourceGuards in a resource group
text: az dataprotection resource-guard list -g sarath-rg
"""

helps['dataprotection resource-guard list-protected-operations'] = """
type: command
short-summary: Lists protected operations associated with a ResourceGuard .
examples:
- name: List ResourceGuard protected operations
text: az dataprotection resource-guard list-protected-operations --resource-group "SampleResourceGroup" --resource-guard-name "swaggerExample" --resource-type "Microsoft.RecoveryServices/vaults"
"""

helps['dataprotection resource-guard update'] = """
type: command
short-summary: Updates protected operations associated with a ResourceGuard .
examples:
- name: Update ResourceGuard
text: az dataprotection resource-guard update --resource-group "SampleResourceGroup" --resource-guard-name "swaggerExample" --resource-type "Microsoft.RecoveryServices/vaults" --critical-operation-exclusion-list deleteProtection getSecurityPIN updatePolicy
"""

helps['dataprotection backup-instance restore trigger'] = """
type: command
short-summary: Triggers restore for a BackupInstance.
Expand Down
25 changes: 24 additions & 1 deletion src/dataprotection/azext_dataprotection/manual/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# pylint: disable=too-many-statements

from azure.cli.core.commands.parameters import (
tags_type,
get_enum_type,
resource_group_name_type,
get_location_type
Expand All @@ -33,7 +34,9 @@
get_job_operation_values,
get_datasource_types,
get_rehydration_priority_values,
get_secret_store_type_values
get_secret_store_type_values,
get_resource_type_values,
get_critical_operation_values
)


Expand Down Expand Up @@ -171,3 +174,23 @@ def load_arguments(self, _):

with self.argument_context('dataprotection backup-vault list') as c:
c.argument('resource_group_name', resource_group_name_type)

with self.argument_context('dataprotection resource-guard list') as c:
c.argument('resource_group_name', resource_group_name_type)

with self.argument_context('dataprotection resource-guard list-protected-operations') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('resource_guards_name', options_list=['--resource-guard-name', '--name', '-n'], type=str, help='The name of '
'ResourceGuard', id_part='name')
c.argument('resource_type', arg_type=get_enum_type(get_resource_type_values()), help='Type of the resource associated with the protected operations')

with self.argument_context('dataprotection resource-guard update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('resource_guards_name', options_list=['--resource-guard-name', '--name', '-n'], type=str, help='The name of '
'ResourceGuard', id_part='name')
c.argument('tags', tags_type)
c.argument('type_', options_list=['--type'], type=str, help='The identityType which can be either '
'SystemAssigned or None', arg_group='Identity')
c.argument('resource_type', arg_type=get_enum_type(get_resource_type_values()), help='Type of the resource associated with the protected operations')
c.argument('critical_operation_exclusion_list', arg_type=get_enum_type(get_critical_operation_values()), nargs='+', help='List of critical operations which are '
'not protected by this resourceGuard')
7 changes: 6 additions & 1 deletion src/dataprotection/azext_dataprotection/manual/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from azure.cli.core.commands import CliCommandType
from azext_dataprotection.generated._client_factory import (
cf_backup_instance, cf_backup_vault, cf_backup_policy
cf_backup_instance, cf_backup_vault, cf_backup_policy, cf_resource_guard
)

from azext_dataprotection.manual._client_factory import cf_resource_graph_client
Expand Down Expand Up @@ -67,3 +67,8 @@ def load_command_table(self, _):
g.custom_command('list', 'dataprotection_backup_vault_list')
g.custom_command('create', 'dataprotection_backup_vault_create', supports_no_wait=True)
g.custom_command('update', 'dataprotection_backup_vault_update', supports_no_wait=True)

with self.command_group('dataprotection resource-guard', exception_handler=exception_handler, client_factory=cf_resource_guard) as g:
g.custom_command('list', 'dataprotection_resource_guard_list')
g.custom_command('list-protected-operations', 'resource_guard_list_protected_operations')
g.custom_command('update', 'dataprotection_resource_guard_update')
Loading