Skip to content

Commit

Permalink
[dataprotection] AKS Hooks for backup and restore, time validation fix (
Browse files Browse the repository at this point in the history
#6562)

* Generated 2023-05-01 for BI CRUD, Restore, validates

* Fixes to helptext in AAZ

* string-list prototype, won't work, filler code

* backupconfig is now generated fine

* fix format issue, fix time format issue (unrelated), restore boilerplate

* Fixed time validation properly + AKS Hooks is complete

* Upgraded all files to 2023-05-01

* regenerated code with correct swagger

* Minor changes fixing breaks

* recorded tests

* Should fix most issues

* Fix static analysis issues

* Added test for AKS hooks

* Tests passing for aks hooks

* Updated history and setup for release

---------

Co-authored-by: Zubair Abid <[email protected]>
  • Loading branch information
zubairabid and Zubair Abid authored Aug 14, 2023
1 parent 26d0c92 commit 8655f76
Show file tree
Hide file tree
Showing 65 changed files with 5,199 additions and 2,722 deletions.
6 changes: 6 additions & 0 deletions src/dataprotection/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Release History
===============
0.9.2
++++++
* Updated API version to 2023-05-01 across the board
* `az dataprotection backup-instance initialize-backupconfig`: Added support for AKS Hooks
* `az dataprotection backup-instance initialize-restoreconfig`: Added support for AKS Hooks

0.9.1
+++++
* `az dataprotection update-msi-permissions`: Fixed bug in fetching AKS workload resource group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class AdhocBackup(AAZCommand):
"""

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

Expand Down Expand Up @@ -167,7 +167,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01",
"api-version", "2023-05-01",
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Create(AAZCommand):
"""

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

Expand Down Expand Up @@ -65,6 +65,25 @@ def _build_arguments_schema(cls, *args, **kwargs):
# define Arg Group "Properties"
return cls._args_schema

_args_base_resource_properties_create = None

@classmethod
def _build_args_base_resource_properties_create(cls, _schema):
if cls._args_base_resource_properties_create is not None:
_schema.object_type = cls._args_base_resource_properties_create.object_type
return

cls._args_base_resource_properties_create = AAZObjectArg()

base_resource_properties_create = cls._args_base_resource_properties_create
base_resource_properties_create.object_type = AAZStrArg(
options=["object-type"],
help="Type of the specific object - used for deserializing",
required=True,
)

_schema.object_type = cls._args_base_resource_properties_create.object_type

def _execute_operations(self):
self.pre_operations()
yield self.BackupInstancesCreateOrUpdate(ctx=self.ctx)()
Expand Down Expand Up @@ -150,7 +169,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01",
"api-version", "2023-05-01",
required=True,
),
}
Expand Down Expand Up @@ -231,6 +250,9 @@ def _build_schema_on_200_201(cls):
properties.friendly_name = AAZStrType(
serialized_name="friendlyName",
)
properties.identity_details = AAZObjectType(
serialized_name="identityDetails",
)
properties.object_type = AAZStrType(
serialized_name="objectType",
flags={"required": True},
Expand Down Expand Up @@ -271,6 +293,10 @@ def _build_schema_on_200_201(cls):
data_source_info.resource_name = AAZStrType(
serialized_name="resourceName",
)
data_source_info.resource_properties = AAZObjectType(
serialized_name="resourceProperties",
)
_CreateHelper._build_schema_base_resource_properties_read(data_source_info.resource_properties)
data_source_info.resource_type = AAZStrType(
serialized_name="resourceType",
)
Expand All @@ -295,6 +321,10 @@ def _build_schema_on_200_201(cls):
data_source_set_info.resource_name = AAZStrType(
serialized_name="resourceName",
)
data_source_set_info.resource_properties = AAZObjectType(
serialized_name="resourceProperties",
)
_CreateHelper._build_schema_base_resource_properties_read(data_source_set_info.resource_properties)
data_source_set_info.resource_type = AAZStrType(
serialized_name="resourceType",
)
Expand All @@ -321,6 +351,14 @@ def _build_schema_on_200_201(cls):
secret_store_resource.uri = AAZStrType()
secret_store_resource.value = AAZStrType()

identity_details = cls._schema_on_200_201.properties.identity_details
identity_details.use_system_assigned_identity = AAZBoolType(
serialized_name="useSystemAssignedIdentity",
)
identity_details.user_assigned_identity_arm_url = AAZStrType(
serialized_name="userAssignedIdentityArmUrl",
)

policy_info = cls._schema_on_200_201.properties.policy_info
policy_info.policy_id = AAZStrType(
serialized_name="policyId",
Expand Down Expand Up @@ -361,6 +399,9 @@ def _build_schema_on_200_201(cls):
containers_list.Element = AAZStrType()

disc_kubernetes_cluster_backup_datasource_parameters = cls._schema_on_200_201.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters")
disc_kubernetes_cluster_backup_datasource_parameters.backup_hook_references = AAZListType(
serialized_name="backupHookReferences",
)
disc_kubernetes_cluster_backup_datasource_parameters.excluded_namespaces = AAZListType(
serialized_name="excludedNamespaces",
)
Expand All @@ -385,6 +426,13 @@ def _build_schema_on_200_201(cls):
flags={"required": True},
)

backup_hook_references = cls._schema_on_200_201.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters").backup_hook_references
backup_hook_references.Element = AAZObjectType()

_element = cls._schema_on_200_201.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters").backup_hook_references.Element
_element.name = AAZStrType()
_element.namespace = AAZStrType()

excluded_namespaces = cls._schema_on_200_201.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters").excluded_namespaces
excluded_namespaces.Element = AAZStrType()

Expand Down Expand Up @@ -454,6 +502,30 @@ def _build_schema_on_200_201(cls):
class _CreateHelper:
"""Helper class for Create"""

@classmethod
def _build_schema_base_resource_properties_create(cls, _builder):
if _builder is None:
return
_builder.set_prop("objectType", AAZStrType, ".object_type", typ_kwargs={"flags": {"required": True}})

_schema_base_resource_properties_read = None

@classmethod
def _build_schema_base_resource_properties_read(cls, _schema):
if cls._schema_base_resource_properties_read is not None:
_schema.object_type = cls._schema_base_resource_properties_read.object_type
return

cls._schema_base_resource_properties_read = _schema_base_resource_properties_read = AAZObjectType()

base_resource_properties_read = _schema_base_resource_properties_read
base_resource_properties_read.object_type = AAZStrType(
serialized_name="objectType",
flags={"required": True},
)

_schema.object_type = cls._schema_base_resource_properties_read.object_type

_schema_inner_error_read = None

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Delete(AAZCommand):
"""

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

Expand Down Expand Up @@ -154,7 +154,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01",
"api-version", "2023-05-01",
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class List(AAZCommand):
"""

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

Expand All @@ -45,7 +45,6 @@ def _build_arguments_schema(cls, *args, **kwargs):

_args_schema = cls._args_schema
_args_schema.resource_group = AAZResourceGroupNameArg(
help="Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.",
required=True,
)
_args_schema.vault_name = AAZStrArg(
Expand Down Expand Up @@ -121,7 +120,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01",
"api-version", "2023-05-01",
required=True,
),
}
Expand Down Expand Up @@ -197,6 +196,9 @@ def _build_schema_on_200(cls):
properties.friendly_name = AAZStrType(
serialized_name="friendlyName",
)
properties.identity_details = AAZObjectType(
serialized_name="identityDetails",
)
properties.object_type = AAZStrType(
serialized_name="objectType",
flags={"required": True},
Expand Down Expand Up @@ -237,6 +239,10 @@ def _build_schema_on_200(cls):
data_source_info.resource_name = AAZStrType(
serialized_name="resourceName",
)
data_source_info.resource_properties = AAZObjectType(
serialized_name="resourceProperties",
)
_ListHelper._build_schema_base_resource_properties_read(data_source_info.resource_properties)
data_source_info.resource_type = AAZStrType(
serialized_name="resourceType",
)
Expand All @@ -261,6 +267,10 @@ def _build_schema_on_200(cls):
data_source_set_info.resource_name = AAZStrType(
serialized_name="resourceName",
)
data_source_set_info.resource_properties = AAZObjectType(
serialized_name="resourceProperties",
)
_ListHelper._build_schema_base_resource_properties_read(data_source_set_info.resource_properties)
data_source_set_info.resource_type = AAZStrType(
serialized_name="resourceType",
)
Expand All @@ -287,6 +297,14 @@ def _build_schema_on_200(cls):
secret_store_resource.uri = AAZStrType()
secret_store_resource.value = AAZStrType()

identity_details = cls._schema_on_200.value.Element.properties.identity_details
identity_details.use_system_assigned_identity = AAZBoolType(
serialized_name="useSystemAssignedIdentity",
)
identity_details.user_assigned_identity_arm_url = AAZStrType(
serialized_name="userAssignedIdentityArmUrl",
)

policy_info = cls._schema_on_200.value.Element.properties.policy_info
policy_info.policy_id = AAZStrType(
serialized_name="policyId",
Expand Down Expand Up @@ -327,6 +345,9 @@ def _build_schema_on_200(cls):
containers_list.Element = AAZStrType()

disc_kubernetes_cluster_backup_datasource_parameters = cls._schema_on_200.value.Element.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters")
disc_kubernetes_cluster_backup_datasource_parameters.backup_hook_references = AAZListType(
serialized_name="backupHookReferences",
)
disc_kubernetes_cluster_backup_datasource_parameters.excluded_namespaces = AAZListType(
serialized_name="excludedNamespaces",
)
Expand All @@ -351,6 +372,13 @@ def _build_schema_on_200(cls):
flags={"required": True},
)

backup_hook_references = cls._schema_on_200.value.Element.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters").backup_hook_references
backup_hook_references.Element = AAZObjectType()

_element = cls._schema_on_200.value.Element.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters").backup_hook_references.Element
_element.name = AAZStrType()
_element.namespace = AAZStrType()

excluded_namespaces = cls._schema_on_200.value.Element.properties.policy_info.policy_parameters.backup_datasource_parameters_list.Element.discriminate_by("object_type", "KubernetesClusterBackupDatasourceParameters").excluded_namespaces
excluded_namespaces.Element = AAZStrType()

Expand Down Expand Up @@ -420,6 +448,24 @@ def _build_schema_on_200(cls):
class _ListHelper:
"""Helper class for List"""

_schema_base_resource_properties_read = None

@classmethod
def _build_schema_base_resource_properties_read(cls, _schema):
if cls._schema_base_resource_properties_read is not None:
_schema.object_type = cls._schema_base_resource_properties_read.object_type
return

cls._schema_base_resource_properties_read = _schema_base_resource_properties_read = AAZObjectType()

base_resource_properties_read = _schema_base_resource_properties_read
base_resource_properties_read.object_type = AAZStrType(
serialized_name="objectType",
flags={"required": True},
)

_schema.object_type = cls._schema_base_resource_properties_read.object_type

_schema_inner_error_read = None

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class ResumeProtection(AAZCommand):
"""

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

Expand Down Expand Up @@ -53,7 +53,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
id_part="child_name_1",
)
_args_schema.resource_group = AAZResourceGroupNameArg(
help="Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.",
required=True,
)
_args_schema.vault_name = AAZStrArg(
Expand Down Expand Up @@ -145,7 +144,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01",
"api-version", "2023-05-01",
required=True,
),
}
Expand Down
Loading

0 comments on commit 8655f76

Please sign in to comment.