Skip to content

Commit

Permalink
[NetAppFiles] Add splitclonefromparent and list-quota-report commands…
Browse files Browse the repository at this point in the history
… to volume (#8022)

* Add splitclonefromparent and list-quota-report commands to volume

* bump version

* fix version number in history

* import unittest
  • Loading branch information
audunn authored Oct 8, 2024
1 parent c48c6fe commit 3ce6ffb
Show file tree
Hide file tree
Showing 8 changed files with 783 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/netappfiles-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
Release History
===============
1.0.0b3
+++++
Add new command `az netappfiles volume list-quota-report`
Add new command `az netappfiles volume splitclonefromparent`

1.0.0b2
+++++
Support for api-version 2024-03-01-preview
`az netappfiles account backup-vault backup update removed parameter use_existing_snapshot
`az netappfiles account backup-vault backup update` removed parameter `use_existing_snapshot`
`az netappfiles volume create` removed parameter `backup-enabled`
`az netappfiles volume create` removed parameter `replication-id`
`az netappfiles volume create` update parameter `usage-threshold`: updated property default from 107374182400 to 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class List(AAZCommand):
_aaz_info = {
"version": "2024-03-01-preview",
"resources": [
["mgmt-plane", "/subscriptions/{}/providers/microsoft.netapp/netappaccounts", "2024-03-01-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.netapp/netappaccounts", "2024-03-01-preview"],
]
}
Expand All @@ -46,14 +47,17 @@ def _build_arguments_schema(cls, *args, **kwargs):
# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.resource_group = AAZResourceGroupNameArg()
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.AccountsList(ctx=self.ctx)()
condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id)
condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True
if condition_0:
self.AccountsList(ctx=self.ctx)()
if condition_1:
self.AccountsListBySubscription(ctx=self.ctx)()
self.post_operations()

@register_callback
Expand Down Expand Up @@ -388,6 +392,321 @@ def _build_schema_on_200(cls):

return cls._schema_on_200

class AccountsListBySubscription(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 [200]:
return self.on_200(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/netAppAccounts",
**self.url_parameters
)

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

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

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2024-03-01-preview",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

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.next_link = AAZStrType(
serialized_name="nextLink",
)
_schema_on_200.value = AAZListType()

value = cls._schema_on_200.value
value.Element = AAZObjectType()

_element = cls._schema_on_200.value.Element
_element.etag = AAZStrType(
flags={"read_only": True},
)
_element.id = AAZStrType(
flags={"read_only": True},
)
_element.identity = AAZObjectType()
_element.location = AAZStrType(
flags={"required": True},
)
_element.name = AAZStrType(
flags={"read_only": True},
)
_element.properties = AAZObjectType(
flags={"client_flatten": True},
)
_element.system_data = AAZObjectType(
serialized_name="systemData",
flags={"read_only": True},
)
_element.tags = AAZDictType()
_element.type = AAZStrType(
flags={"read_only": True},
)

identity = cls._schema_on_200.value.Element.identity
identity.principal_id = AAZStrType(
serialized_name="principalId",
flags={"read_only": True},
)
identity.tenant_id = AAZStrType(
serialized_name="tenantId",
flags={"read_only": True},
)
identity.type = AAZStrType(
flags={"required": True},
)
identity.user_assigned_identities = AAZDictType(
serialized_name="userAssignedIdentities",
)

user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities
user_assigned_identities.Element = AAZObjectType(
nullable=True,
)

_element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element
_element.client_id = AAZStrType(
serialized_name="clientId",
flags={"read_only": True},
)
_element.principal_id = AAZStrType(
serialized_name="principalId",
flags={"read_only": True},
)

properties = cls._schema_on_200.value.Element.properties
properties.active_directories = AAZListType(
serialized_name="activeDirectories",
)
properties.disable_showmount = AAZBoolType(
serialized_name="disableShowmount",
nullable=True,
flags={"read_only": True},
)
properties.encryption = AAZObjectType()
properties.is_multi_ad_enabled = AAZBoolType(
serialized_name="isMultiAdEnabled",
nullable=True,
flags={"read_only": True},
)
properties.nfs_v4_id_domain = AAZStrType(
serialized_name="nfsV4IDDomain",
nullable=True,
)
properties.provisioning_state = AAZStrType(
serialized_name="provisioningState",
flags={"read_only": True},
)

active_directories = cls._schema_on_200.value.Element.properties.active_directories
active_directories.Element = AAZObjectType()

_element = cls._schema_on_200.value.Element.properties.active_directories.Element
_element.active_directory_id = AAZStrType(
serialized_name="activeDirectoryId",
nullable=True,
)
_element.ad_name = AAZStrType(
serialized_name="adName",
)
_element.administrators = AAZListType()
_element.aes_encryption = AAZBoolType(
serialized_name="aesEncryption",
)
_element.allow_local_nfs_users_with_ldap = AAZBoolType(
serialized_name="allowLocalNfsUsersWithLdap",
)
_element.backup_operators = AAZListType(
serialized_name="backupOperators",
)
_element.dns = AAZStrType()
_element.domain = AAZStrType()
_element.encrypt_dc_connections = AAZBoolType(
serialized_name="encryptDCConnections",
)
_element.kdc_ip = AAZStrType(
serialized_name="kdcIP",
)
_element.ldap_over_tls = AAZBoolType(
serialized_name="ldapOverTLS",
)
_element.ldap_search_scope = AAZObjectType(
serialized_name="ldapSearchScope",
)
_element.ldap_signing = AAZBoolType(
serialized_name="ldapSigning",
)
_element.organizational_unit = AAZStrType(
serialized_name="organizationalUnit",
)
_element.password = AAZStrType(
flags={"secret": True},
)
_element.preferred_servers_for_ldap_client = AAZStrType(
serialized_name="preferredServersForLdapClient",
)
_element.security_operators = AAZListType(
serialized_name="securityOperators",
)
_element.server_root_ca_certificate = AAZStrType(
serialized_name="serverRootCACertificate",
flags={"secret": True},
)
_element.site = AAZStrType()
_element.smb_server_name = AAZStrType(
serialized_name="smbServerName",
)
_element.status = AAZStrType(
flags={"read_only": True},
)
_element.status_details = AAZStrType(
serialized_name="statusDetails",
flags={"read_only": True},
)
_element.username = AAZStrType()

administrators = cls._schema_on_200.value.Element.properties.active_directories.Element.administrators
administrators.Element = AAZStrType()

backup_operators = cls._schema_on_200.value.Element.properties.active_directories.Element.backup_operators
backup_operators.Element = AAZStrType()

ldap_search_scope = cls._schema_on_200.value.Element.properties.active_directories.Element.ldap_search_scope
ldap_search_scope.group_dn = AAZStrType(
serialized_name="groupDN",
)
ldap_search_scope.group_membership_filter = AAZStrType(
serialized_name="groupMembershipFilter",
)
ldap_search_scope.user_dn = AAZStrType(
serialized_name="userDN",
)

security_operators = cls._schema_on_200.value.Element.properties.active_directories.Element.security_operators
security_operators.Element = AAZStrType()

encryption = cls._schema_on_200.value.Element.properties.encryption
encryption.identity = AAZObjectType()
encryption.key_source = AAZStrType(
serialized_name="keySource",
)
encryption.key_vault_properties = AAZObjectType(
serialized_name="keyVaultProperties",
)

identity = cls._schema_on_200.value.Element.properties.encryption.identity
identity.federated_client_id = AAZStrType(
serialized_name="federatedClientId",
)
identity.principal_id = AAZStrType(
serialized_name="principalId",
flags={"read_only": True},
)
identity.user_assigned_identity = AAZStrType(
serialized_name="userAssignedIdentity",
)

key_vault_properties = cls._schema_on_200.value.Element.properties.encryption.key_vault_properties
key_vault_properties.key_name = AAZStrType(
serialized_name="keyName",
flags={"required": True},
)
key_vault_properties.key_vault_id = AAZStrType(
serialized_name="keyVaultId",
flags={"read_only": True},
)
key_vault_properties.key_vault_resource_id = AAZStrType(
serialized_name="keyVaultResourceId",
)
key_vault_properties.key_vault_uri = AAZStrType(
serialized_name="keyVaultUri",
flags={"required": True},
)
key_vault_properties.status = AAZStrType(
flags={"read_only": True},
)

system_data = cls._schema_on_200.value.Element.system_data
system_data.created_at = AAZStrType(
serialized_name="createdAt",
)
system_data.created_by = AAZStrType(
serialized_name="createdBy",
)
system_data.created_by_type = AAZStrType(
serialized_name="createdByType",
)
system_data.last_modified_at = AAZStrType(
serialized_name="lastModifiedAt",
)
system_data.last_modified_by = AAZStrType(
serialized_name="lastModifiedBy",
)
system_data.last_modified_by_type = AAZStrType(
serialized_name="lastModifiedByType",
)

tags = cls._schema_on_200.value.Element.tags
tags.Element = AAZStrType()

return cls._schema_on_200


class _ListHelper:
"""Helper class for List"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from ._create import *
from ._delete import *
from ._list import *
from ._list_quota_report import *
from ._migrate_backup import *
from ._show import *
from ._splitclonefromparent import *
from ._update import *
from ._wait import *
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.volume_type = AAZStrArg(
options=["--volume-type"],
arg_group="Properties",
help="What type of volume is this. For destination volumes in Cross Region Replication, set type to DataProtection",
help="What type of volume is this. For destination volumes in Cross Region Replication, set type to DataProtection. For creating clone volume, set type to ShortTermClone",
)

placement_rules = cls._args_schema.placement_rules
Expand Down
Loading

0 comments on commit 3ce6ffb

Please sign in to comment.