Skip to content

Commit 17d75d0

Browse files
authored
[dataprotection] dataprotection migrated to AAZ. (#6385)
* recovery-point and job migrated * Cleaned up client factory for job, recovery-point * Also cleaned up client factory for backup-vault * AKS Test Success * Version changes to 0.8.1 * Added license header in recovery_point.py * Removed unused import in recovery_point.py * Removed unused import in recovery_point.py * Updated dataprotection short summary * Deleted manual version.py * Removed manual VERSION from setup.py * Minor aaz generation change job, recovery-point * Migrated restorable-time-range * Migrated resource-guard * Migrated backup-policy * Edit to pass flaker * Recorded live tests, added sleep in aks workload test * Fixed 'Bad Request' error (absent HTTP response) * Completed backup-instance migration * Fixed adhoc-backup, scenario test recorded * Updated backup-instance create, validate-for-restore, restore trigger to class override * Removed generated dir and made required updates. * Changed for loop range and len to enumerate. * Tests recorded * Removed timestamp prints from scenario test. * Updated version and changelog * recovery-point and job migrated * Cleaned up client factory for job, recovery-point * Also cleaned up client factory for backup-vault * AKS Test Success * Version changes to 0.8.1 * Added license header in recovery_point.py * Removed unused import in recovery_point.py * Updated dataprotection short summary * Deleted manual version.py * Removed manual VERSION from setup.py * Minor aaz generation change job, recovery-point * Migrated restorable-time-range * Migrated resource-guard * Migrated backup-policy * Edit to pass flaker * Recorded live tests, added sleep in aks workload test * Fixed 'Bad Request' error (absent HTTP response) * Completed backup-instance migration * Fixed adhoc-backup, scenario test recorded * Updated backup-instance create, validate-for-restore, restore trigger to class override * Removed generated dir and made required updates. * Changed for loop range and len to enumerate. * Tests recorded * Removed timestamp prints from scenario test. * Updated version and changelog * Updated scenario test recording * Validate for backup help text fixed. * Fix resource-guard update bug * Fixed AAZ error handling for backup-vault update * Updated to verison 0.9.1 * Recorded tests * Static analysis fix * Removed unused import. * Added warning for invalid input for recovery-point list * Fixed cleanup for oss test * Fixed cleanup for oss test * Custom function bug fixes * Fixed backup-vault create BadRequest * Minor update in naming convention * Updated release history * static analysis fixes * Revert "static analysis fixes" This reverts commit 3a9b4a7. * Import sequence fixed. * Import sequence fixed. * Removed error handling workaround * Removed error handling workaround and command regs * Fixed import bug * Removed dataprotection vendored SDK * Removed error handling workaround * Removed use of CLIError * Static analysis fixes. * Resource guard override update * Swagger generated fixes, code cleanup * Recorded tests * Undoed resource-guard edit * Post final swagger changes, enum removed. * resource-guard update used assign_aaz_list_arg()
1 parent c66191a commit 17d75d0

File tree

99 files changed

+16544
-39994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+16544
-39994
lines changed

src/dataprotection/HISTORY.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
33
Release History
44
===============
5+
0.9.1
6+
+++++
7+
* `az dataprotection update-msi-permissions`: Fixed bug in fetching AKS workload resource group
8+
* `az dataprotection backup-policy create-generic-criteria`: Bug-fix in day-of-month argument validation
9+
* `az dataprotection recovery-point`: Added user warning when start-time is after end-time
10+
* `az dataprotection backup-instance`: Migrated to AAZ-dev-tools
11+
* `az dataprotection backup-policy`: Migrated to AAZ-dev-tools
12+
* `az dataprotection resource-guard`: Migrated to AAZ-dev-tools
13+
* `az dataprotection restorable-time-range`: Migrated to AAZ-dev-tools
14+
515
0.9.0
616
+++++
717
* Add support for cross-subscription-restore for Dataprotection.

src/dataprotection/azext_dataprotection/__init__.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
5-
#
6-
# Code generated by Microsoft (R) AutoRest Code Generator.
7-
# Changes may cause incorrect behavior and will be lost if the code is
8-
# regenerated.
95
# --------------------------------------------------------------------------
106

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

2419
def __init__(self, cli_ctx=None):
2520
from azure.cli.core.commands import CliCommandType
26-
from azext_dataprotection.generated._client_factory import cf_dataprotection_cl
2721
dataprotection_custom = CliCommandType(
28-
operations_tmpl='azext_dataprotection.custom#{}',
29-
client_factory=cf_dataprotection_cl)
22+
operations_tmpl='azext_dataprotection.custom#{}')
3023
parent = super()
3124
parent.__init__(cli_ctx=cli_ctx, custom_command_type=dataprotection_custom)
3225

3326
def load_command_table(self, args):
34-
from azext_dataprotection.generated.commands import load_command_table
3527
from azure.cli.core.aaz import load_aaz_command_table
3628
try:
3729
from . import aaz
@@ -43,7 +35,6 @@ def load_command_table(self, args):
4335
aaz_pkg_name=aaz.__name__,
4436
args=args
4537
)
46-
load_command_table(self, args)
4738
try:
4839
from azext_dataprotection.manual.commands import load_command_table as load_command_table_manual
4940
load_command_table_manual(self, args)
@@ -55,8 +46,6 @@ def load_command_table(self, args):
5546
return self.command_table
5647

5748
def load_arguments(self, command):
58-
from azext_dataprotection.generated._params import load_arguments
59-
load_arguments(self, command)
6049
try:
6150
from azext_dataprotection.manual._params import load_arguments as load_arguments_manual
6251
load_arguments_manual(self, command)

src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_instance/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
# flake8: noqa
1010

1111
from .__cmd_group import *
12+
from ._adhoc_backup import *
1213
from ._create import *
1314
from ._delete import *
15+
from ._list import *
16+
from ._resume_protection import *
1417
from ._show import *
18+
from ._stop_protection import *
19+
from ._suspend_backup import *
1520
from ._update import *
1621
from ._validate_for_backup import *
1722
from ._validate_for_restore import *
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command(
15+
"dataprotection backup-instance adhoc-backup",
16+
is_experimental=True,
17+
)
18+
class AdhocBackup(AAZCommand):
19+
"""Trigger adhoc backup.
20+
21+
:example: Trigger Adhoc Backup
22+
az dataprotection backup-instance adhoc-backup --name "testInstance1" --rule-name "BackupWeekly" --retention-tag-override "yearly" --resource-group "000pikumar" --vault-name "PratikPrivatePreviewVault1"
23+
"""
24+
25+
_aaz_info = {
26+
"version": "2023-01-01",
27+
"resources": [
28+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.dataprotection/backupvaults/{}/backupinstances/{}/backup", "2023-01-01"],
29+
]
30+
}
31+
32+
AZ_SUPPORT_NO_WAIT = True
33+
34+
def _handler(self, command_args):
35+
super()._handler(command_args)
36+
return self.build_lro_poller(self._execute_operations, self._output)
37+
38+
_args_schema = None
39+
40+
@classmethod
41+
def _build_arguments_schema(cls, *args, **kwargs):
42+
if cls._args_schema is not None:
43+
return cls._args_schema
44+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
45+
46+
# define Arg Group ""
47+
48+
_args_schema = cls._args_schema
49+
_args_schema.backup_instance_name = AAZStrArg(
50+
options=["-n", "--name", "--backup-instance-name"],
51+
help="The name of the backup instance.",
52+
required=True,
53+
id_part="child_name_1",
54+
)
55+
_args_schema.resource_group = AAZResourceGroupNameArg(
56+
required=True,
57+
)
58+
_args_schema.vault_name = AAZStrArg(
59+
options=["--vault-name"],
60+
help="The name of the backup vault.",
61+
required=True,
62+
id_part="name",
63+
)
64+
65+
# define Arg Group "Backup Rule Options"
66+
67+
_args_schema = cls._args_schema
68+
_args_schema.rule_name = AAZStrArg(
69+
options=["--rule-name"],
70+
arg_group="Backup Rule Options",
71+
help="Specify backup policy rule name.",
72+
required=True,
73+
)
74+
75+
# define Arg Group "Backup Rule Options Trigger Option"
76+
77+
_args_schema = cls._args_schema
78+
_args_schema.retention_tag_override = AAZStrArg(
79+
options=["--retention-tag-override"],
80+
arg_group="Backup Rule Options Trigger Option",
81+
help="Specify retention override tag.",
82+
)
83+
return cls._args_schema
84+
85+
def _execute_operations(self):
86+
self.pre_operations()
87+
yield self.BackupInstancesAdhocBackup(ctx=self.ctx)()
88+
self.post_operations()
89+
90+
@register_callback
91+
def pre_operations(self):
92+
pass
93+
94+
@register_callback
95+
def post_operations(self):
96+
pass
97+
98+
def _output(self, *args, **kwargs):
99+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
100+
return result
101+
102+
class BackupInstancesAdhocBackup(AAZHttpOperation):
103+
CLIENT_TYPE = "MgmtClient"
104+
105+
def __call__(self, *args, **kwargs):
106+
request = self.make_request()
107+
session = self.client.send_request(request=request, stream=False, **kwargs)
108+
if session.http_response.status_code in [202]:
109+
return self.client.build_lro_polling(
110+
self.ctx.args.no_wait,
111+
session,
112+
self.on_200,
113+
self.on_error,
114+
lro_options={"final-state-via": "location"},
115+
path_format_arguments=self.url_parameters,
116+
)
117+
if session.http_response.status_code in [200]:
118+
return self.client.build_lro_polling(
119+
self.ctx.args.no_wait,
120+
session,
121+
self.on_200,
122+
self.on_error,
123+
lro_options={"final-state-via": "location"},
124+
path_format_arguments=self.url_parameters,
125+
)
126+
127+
return self.on_error(session.http_response)
128+
129+
@property
130+
def url(self):
131+
return self.client.format_url(
132+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup",
133+
**self.url_parameters
134+
)
135+
136+
@property
137+
def method(self):
138+
return "POST"
139+
140+
@property
141+
def error_format(self):
142+
return "MgmtErrorFormat"
143+
144+
@property
145+
def url_parameters(self):
146+
parameters = {
147+
**self.serialize_url_param(
148+
"backupInstanceName", self.ctx.args.backup_instance_name,
149+
required=True,
150+
),
151+
**self.serialize_url_param(
152+
"resourceGroupName", self.ctx.args.resource_group,
153+
required=True,
154+
),
155+
**self.serialize_url_param(
156+
"subscriptionId", self.ctx.subscription_id,
157+
required=True,
158+
),
159+
**self.serialize_url_param(
160+
"vaultName", self.ctx.args.vault_name,
161+
required=True,
162+
),
163+
}
164+
return parameters
165+
166+
@property
167+
def query_parameters(self):
168+
parameters = {
169+
**self.serialize_query_param(
170+
"api-version", "2023-01-01",
171+
required=True,
172+
),
173+
}
174+
return parameters
175+
176+
@property
177+
def header_parameters(self):
178+
parameters = {
179+
**self.serialize_header_param(
180+
"Content-Type", "application/json",
181+
),
182+
**self.serialize_header_param(
183+
"Accept", "application/json",
184+
),
185+
}
186+
return parameters
187+
188+
@property
189+
def content(self):
190+
_content_value, _builder = self.new_content_builder(
191+
self.ctx.args,
192+
typ=AAZObjectType,
193+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
194+
)
195+
_builder.set_prop("backupRuleOptions", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}})
196+
197+
backup_rule_options = _builder.get(".backupRuleOptions")
198+
if backup_rule_options is not None:
199+
backup_rule_options.set_prop("ruleName", AAZStrType, ".rule_name", typ_kwargs={"flags": {"required": True}})
200+
backup_rule_options.set_prop("triggerOption", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}})
201+
202+
trigger_option = _builder.get(".backupRuleOptions.triggerOption")
203+
if trigger_option is not None:
204+
trigger_option.set_prop("retentionTagOverride", AAZStrType, ".retention_tag_override")
205+
206+
return self.serialize_content(_content_value)
207+
208+
def on_200(self, session):
209+
data = self.deserialize_http_content(session)
210+
self.ctx.set_var(
211+
"instance",
212+
data,
213+
schema_builder=self._build_schema_on_200
214+
)
215+
216+
_schema_on_200 = None
217+
218+
@classmethod
219+
def _build_schema_on_200(cls):
220+
if cls._schema_on_200 is not None:
221+
return cls._schema_on_200
222+
223+
cls._schema_on_200 = AAZObjectType()
224+
225+
_schema_on_200 = cls._schema_on_200
226+
_schema_on_200.job_id = AAZStrType(
227+
serialized_name="jobId",
228+
)
229+
_schema_on_200.object_type = AAZStrType(
230+
serialized_name="objectType",
231+
flags={"required": True},
232+
)
233+
234+
return cls._schema_on_200
235+
236+
237+
class _AdhocBackupHelper:
238+
"""Helper class for AdhocBackup"""
239+
240+
241+
__all__ = ["AdhocBackup"]

0 commit comments

Comments
 (0)