Skip to content
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

[dataprotection] dataprotection migrated to AAZ. #6385

Merged
merged 97 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
a6d02d3
recovery-point and job migrated
vishesh155 May 29, 2023
c49d4ea
Cleaned up client factory for job, recovery-point
vishesh155 May 29, 2023
2edd644
Also cleaned up client factory for backup-vault
vishesh155 May 29, 2023
2afc69b
AKS Test Success
vishesh155 May 30, 2023
af360ab
Merge branch 'Azure:main' into migrate-dataprotection-aaz
vishesh155 May 30, 2023
477cdc3
Merge branch 'Azure:main' into migrate-dataprotection-aaz
vishesh155 May 30, 2023
5bd56c3
Version changes to 0.8.1
vishesh155 May 30, 2023
11f737b
Merge branch 'migrate-dataprotection-aaz' of https://github.com/vishe…
vishesh155 May 30, 2023
e4ac247
Added license header in recovery_point.py
vishesh155 May 30, 2023
ce49ce6
Removed unused import in recovery_point.py
vishesh155 May 31, 2023
c120617
Removed unused import in recovery_point.py
vishesh155 May 31, 2023
23e69a3
Merge branch 'migrate-dataprotection-aaz' of https://github.com/vishe…
vishesh155 May 31, 2023
4784701
Updated dataprotection short summary
vishesh155 May 31, 2023
e5942af
Deleted manual version.py
vishesh155 Jun 1, 2023
7934612
Removed manual VERSION from setup.py
vishesh155 Jun 1, 2023
c40c349
Merge branch 'migrate-dataprotection-aaz' of https://github.com/vishe…
vishesh155 Jun 4, 2023
7dae165
Minor aaz generation change job, recovery-point
vishesh155 Jun 4, 2023
377a368
Migrated restorable-time-range
vishesh155 Jun 4, 2023
e5e461e
Migrated resource-guard
vishesh155 Jun 4, 2023
9a228ec
Migrated backup-policy
vishesh155 Jun 4, 2023
10bf8d0
Edit to pass flaker
vishesh155 Jun 4, 2023
b13d2ff
Recorded live tests, added sleep in aks workload test
vishesh155 Jun 4, 2023
6fc73c1
Fixed 'Bad Request' error (absent HTTP response)
vishesh155 Jun 5, 2023
c4db078
Completed backup-instance migration
vishesh155 Jun 6, 2023
7dd2d77
Fixed adhoc-backup, scenario test recorded
vishesh155 Jun 7, 2023
9b13d85
Updated backup-instance create, validate-for-restore, restore trigger…
vishesh155 Jun 9, 2023
203388e
Removed generated dir and made required updates.
vishesh155 Jun 9, 2023
b4c7324
Changed for loop range and len to enumerate.
vishesh155 Jun 9, 2023
937f7c6
Tests recorded
vishesh155 Jun 9, 2023
444edc2
Removed timestamp prints from scenario test.
vishesh155 Jun 9, 2023
2fa4b28
Updated version and changelog
vishesh155 Jun 9, 2023
06c9aed
recovery-point and job migrated
vishesh155 May 29, 2023
952586b
Cleaned up client factory for job, recovery-point
vishesh155 May 29, 2023
faaaea8
Also cleaned up client factory for backup-vault
vishesh155 May 29, 2023
cc7ccf4
AKS Test Success
vishesh155 May 30, 2023
1391e6f
Version changes to 0.8.1
vishesh155 May 30, 2023
9db10d6
Added license header in recovery_point.py
vishesh155 May 30, 2023
42aee5c
Removed unused import in recovery_point.py
vishesh155 May 31, 2023
bc68186
Updated dataprotection short summary
vishesh155 May 31, 2023
4a2a755
Deleted manual version.py
vishesh155 Jun 1, 2023
bec2b17
Removed manual VERSION from setup.py
vishesh155 Jun 1, 2023
15956a1
Minor aaz generation change job, recovery-point
vishesh155 Jun 4, 2023
714c184
Migrated restorable-time-range
vishesh155 Jun 4, 2023
33d76b5
Migrated resource-guard
vishesh155 Jun 4, 2023
1e2cdaf
Migrated backup-policy
vishesh155 Jun 4, 2023
e1ff00c
Edit to pass flaker
vishesh155 Jun 4, 2023
7394bd1
Recorded live tests, added sleep in aks workload test
vishesh155 Jun 4, 2023
444a502
Fixed 'Bad Request' error (absent HTTP response)
vishesh155 Jun 5, 2023
9c03b97
Completed backup-instance migration
vishesh155 Jun 6, 2023
d89b960
Fixed adhoc-backup, scenario test recorded
vishesh155 Jun 7, 2023
6557b47
Updated backup-instance create, validate-for-restore, restore trigger…
vishesh155 Jun 9, 2023
0fd1f9d
Removed generated dir and made required updates.
vishesh155 Jun 9, 2023
d72476f
Changed for loop range and len to enumerate.
vishesh155 Jun 9, 2023
2b7dee7
Tests recorded
vishesh155 Jun 9, 2023
987bc22
Removed timestamp prints from scenario test.
vishesh155 Jun 9, 2023
9959875
Updated version and changelog
vishesh155 Jun 9, 2023
2c5800f
Merge branch 'migrate-dataprotection-aaz' of https://github.com/vishe…
vishesh155 Jun 9, 2023
78eb400
Merged upstream/main
vishesh155 Jun 9, 2023
50e7018
Updated scenario test recording
vishesh155 Jun 9, 2023
cfdab55
Validate for backup help text fixed.
vishesh155 Jun 9, 2023
1449b3b
Fix resource-guard update bug
vishesh155 Jun 12, 2023
6e90803
Fixed AAZ error handling for backup-vault update
vishesh155 Jun 12, 2023
17cf09a
Merged dataprotection 0.9.0
vishesh155 Jun 13, 2023
a7f3b08
Updated to verison 0.9.1
vishesh155 Jun 13, 2023
2eca5ac
Recorded tests
vishesh155 Jun 13, 2023
8e9c693
Static analysis fix
vishesh155 Jun 13, 2023
b23442b
Removed unused import.
vishesh155 Jun 16, 2023
abf57a6
Added warning for invalid input for recovery-point list
vishesh155 Jun 16, 2023
e655190
Fixed cleanup for oss test
vishesh155 Jun 21, 2023
3245de3
Fixed cleanup for oss test
vishesh155 Jun 21, 2023
32c96fc
Merge branch 'Azure:main' into migrate-dataprotection-aaz
vishesh155 Jun 21, 2023
a0587c7
Merge branch 'main' into migrate-dataprotection-aaz
vishesh155 Jun 21, 2023
b218de3
Custom function bug fixes
vishesh155 Jun 28, 2023
75e37f2
Merge branch 'migrate-dataprotection-aaz' of https://github.com/vishe…
vishesh155 Jun 28, 2023
6bb6dc0
Merge branch 'Azure:main' into migrate-dataprotection-aaz
vishesh155 Jun 28, 2023
ccc5964
Fixed backup-vault create BadRequest
vishesh155 Jun 30, 2023
fadc27c
Minor update in naming convention
vishesh155 Jun 30, 2023
f89d5b8
Updated release history
vishesh155 Jun 30, 2023
3a9b4a7
static analysis fixes
vishesh155 Jun 30, 2023
5ebc306
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
vishesh155 Jul 3, 2023
7d49caf
Revert "static analysis fixes"
vishesh155 Jul 3, 2023
1c00e9a
Import sequence fixed.
vishesh155 Jul 3, 2023
700afd4
Import sequence fixed.
vishesh155 Jul 3, 2023
6c2dadd
Removed error handling workaround
vishesh155 Jul 3, 2023
f71e930
Removed error handling workaround and command regs
vishesh155 Jul 3, 2023
2d4cc9b
Fixed import bug
vishesh155 Jul 3, 2023
b0aee44
Removed dataprotection vendored SDK
vishesh155 Jul 3, 2023
d33c1b6
Removed error handling workaround
vishesh155 Jul 3, 2023
eb5fb06
Removed use of CLIError
vishesh155 Jul 4, 2023
823feb9
Static analysis fixes.
vishesh155 Jul 4, 2023
8536e6a
Resource guard override update
vishesh155 Jul 6, 2023
b9705b1
Swagger generated fixes, code cleanup
vishesh155 Jul 6, 2023
b6681da
Recorded tests
vishesh155 Jul 6, 2023
d801f38
Undoed resource-guard edit
vishesh155 Jul 6, 2023
4ec4f34
Post final swagger changes, enum removed.
vishesh155 Jul 6, 2023
4d25ce2
resource-guard update used assign_aaz_list_arg()
vishesh155 Jul 7, 2023
6411cff
Merge branch 'Azure:main' into migrate-dataprotection-aaz
vishesh155 Jul 7, 2023
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
10 changes: 10 additions & 0 deletions src/dataprotection/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Release History
===============
0.9.1
+++++
* `az dataprotection update-msi-permissions`: Fixed bug in fetching AKS workload resource group
* `az dataprotection backup-policy create-generic-criteria`: Bug-fix in day-of-month argument validation
* `az dataprotection recovery-point`: Added user warning when start-time is after end-time
* `az dataprotection backup-instance`: Migrated to AAZ-dev-tools
* `az dataprotection backup-policy`: Migrated to AAZ-dev-tools
* `az dataprotection resource-guard`: Migrated to AAZ-dev-tools
* `az dataprotection restorable-time-range`: Migrated to AAZ-dev-tools

0.9.0
+++++
* Add support for cross-subscription-restore for Dataprotection.
Expand Down
15 changes: 2 additions & 13 deletions src/dataprotection/azext_dataprotection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,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 Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_dataprotection.generated._help import helps # pylint: disable=unused-import
try:
from azext_dataprotection.manual._help import helps # pylint: disable=reimported
from azext_dataprotection.manual._help import helps # pylint: disable=unused-import
except ImportError as e:
if e.name.endswith('manual._help'):
pass
Expand All @@ -23,15 +18,12 @@ class DataProtectionClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_dataprotection.generated._client_factory import cf_dataprotection_cl
dataprotection_custom = CliCommandType(
operations_tmpl='azext_dataprotection.custom#{}',
client_factory=cf_dataprotection_cl)
operations_tmpl='azext_dataprotection.custom#{}')
parent = super()
parent.__init__(cli_ctx=cli_ctx, custom_command_type=dataprotection_custom)

def load_command_table(self, args):
from azext_dataprotection.generated.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
Expand All @@ -43,7 +35,6 @@ def load_command_table(self, args):
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
try:
from azext_dataprotection.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
Expand All @@ -55,8 +46,6 @@ def load_command_table(self, args):
return self.command_table

def load_arguments(self, command):
from azext_dataprotection.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_dataprotection.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
# flake8: noqa

from .__cmd_group import *
from ._adhoc_backup import *
from ._create import *
from ._delete import *
from ._list import *
from ._resume_protection import *
from ._show import *
from ._stop_protection import *
from ._suspend_backup import *
from ._update import *
from ._validate_for_backup import *
from ._validate_for_restore import *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# --------------------------------------------------------------------------------------------
# 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(
"dataprotection backup-instance adhoc-backup",
is_experimental=True,
)
class AdhocBackup(AAZCommand):
"""Trigger adhoc backup.

:example: Trigger Adhoc Backup
az dataprotection backup-instance adhoc-backup --name "testInstance1" --rule-name "BackupWeekly" --retention-tag-override "yearly" --resource-group "000pikumar" --vault-name "PratikPrivatePreviewVault1"
"""

_aaz_info = {
"version": "2023-01-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.dataprotection/backupvaults/{}/backupinstances/{}/backup", "2023-01-01"],
]
}

AZ_SUPPORT_NO_WAIT = True

def _handler(self, command_args):
super()._handler(command_args)
return self.build_lro_poller(self._execute_operations, 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.backup_instance_name = AAZStrArg(
options=["-n", "--name", "--backup-instance-name"],
help="The name of the backup instance.",
required=True,
id_part="child_name_1",
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.vault_name = AAZStrArg(
options=["--vault-name"],
help="The name of the backup vault.",
required=True,
id_part="name",
)

# define Arg Group "Backup Rule Options"

_args_schema = cls._args_schema
_args_schema.rule_name = AAZStrArg(
options=["--rule-name"],
arg_group="Backup Rule Options",
help="Specify backup policy rule name.",
required=True,
)

# define Arg Group "Backup Rule Options Trigger Option"

_args_schema = cls._args_schema
_args_schema.retention_tag_override = AAZStrArg(
options=["--retention-tag-override"],
arg_group="Backup Rule Options Trigger Option",
help="Specify retention override tag.",
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
yield self.BackupInstancesAdhocBackup(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 BackupInstancesAdhocBackup(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 [202]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200,
self.on_error,
lro_options={"final-state-via": "location"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [200]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200,
self.on_error,
lro_options={"final-state-via": "location"},
path_format_arguments=self.url_parameters,
)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup",
**self.url_parameters
)

@property
def method(self):
return "POST"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"backupInstanceName", self.ctx.args.backup_instance_name,
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,
),
**self.serialize_url_param(
"vaultName", self.ctx.args.vault_name,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-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("backupRuleOptions", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}})

backup_rule_options = _builder.get(".backupRuleOptions")
if backup_rule_options is not None:
backup_rule_options.set_prop("ruleName", AAZStrType, ".rule_name", typ_kwargs={"flags": {"required": True}})
backup_rule_options.set_prop("triggerOption", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}})

trigger_option = _builder.get(".backupRuleOptions.triggerOption")
if trigger_option is not None:
trigger_option.set_prop("retentionTagOverride", AAZStrType, ".retention_tag_override")

return self.serialize_content(_content_value)

def on_200(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200
)

_schema_on_200 = None

@classmethod
def _build_schema_on_200(cls):
if cls._schema_on_200 is not None:
return cls._schema_on_200

cls._schema_on_200 = AAZObjectType()

_schema_on_200 = cls._schema_on_200
_schema_on_200.job_id = AAZStrType(
serialized_name="jobId",
)
_schema_on_200.object_type = AAZStrType(
serialized_name="objectType",
flags={"required": True},
)

return cls._schema_on_200


class _AdhocBackupHelper:
"""Helper class for AdhocBackup"""


__all__ = ["AdhocBackup"]
Loading