feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The super-group for the Cloud NetApp Files CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
DETAILED_HELP = {
'DESCRIPTION':
"""\
The gcloud netapp command group lets you create, configure and manipulate
Cloud NetApp Volumes resources such as Volumes, Storage Pools, Active Directories,
KMS Configs, Volume Snapshots, and Volume Replications etc.
With Cloud NetApp Volumes, you can take advantage of Google Cloud Platform's
scale, performance and value to manage and run on-prem NetApp Files
solutions on Google infrastructure, so you don't have to modernize your
file workloads, and allow for legacy feature support.
More information on Cloud NetApp Files can be found here:
https://cloud.google.com/netapp/docs/reference/rest
""",
}
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class Netapp(base.Group):
"""Create and manipulate Cloud NetApp Files resources."""
detailed_help = DETAILED_HELP
category = base.STORAGE_CATEGORY

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Active Directories."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ActiveDirectories(base.Group):
"""Create and manage Cloud NetApp Active Directories."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ActiveDirectoriesBeta(ActiveDirectories):
"""Create and manage Cloud NetApp Active Directories."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ActiveDirectoriesAlpha(ActiveDirectoriesBeta):
"""Create and manage Cloud NetApp Active Directories."""

View File

@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Creates a Cloud NetApp Active Directory."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.active_directories import client as ad_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.active_directories import flags as activedirectories_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Create(base.CreateCommand):
"""Create a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Creates an AD (Active Directory) config for Cloud NetApp Volumes.
""",
'EXAMPLES': """\
The following command creates an AD named AD_NAME with the required arguments:
$ {command} AD_NAME --location=us-central1 --domain=example-domain.com --dns=0.0.0.0 --net-bios-prefix=prefix-1 --enable-aes=true --username=user1 --password="secure1" --backup-operators=backup_op1,backup_op2 --security-operators=sec_op1,sec_op2 --enable-ldap-signing=false
""",
}
@staticmethod
def Args(parser):
activedirectories_flags.AddActiveDirectoryCreateArgs(parser)
def Run(self, args):
"""Create a Cloud NetApp Active Directory in the current project."""
activedirectory_ref = args.CONCEPTS.active_directory.Parse()
client = ad_client.ActiveDirectoriesClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.ActiveDirectory.LabelsValue)
active_directory = client.ParseActiveDirectoryConfig(
name=activedirectory_ref.RelativeName(),
domain=args.domain,
site=args.site,
dns=args.dns,
net_bios_prefix=args.net_bios_prefix,
organizational_unit=args.organizational_unit,
aes_encryption=args.enable_aes,
username=args.username,
password=args.password,
backup_operators=args.backup_operators,
security_operators=args.security_operators,
administrators=args.administrators,
kdc_hostname=args.kdc_hostname,
kdc_ip=args.kdc_ip,
nfs_users_with_ldap=args.nfs_users_with_ldap,
ldap_signing=args.enable_ldap_signing,
encrypt_dc_connections=args.encrypt_dc_connections,
description=args.description,
labels=labels,
)
result = client.CreateActiveDirectory(activedirectory_ref,
args.async_,
active_directory)
if args.async_:
command = 'gcloud {} netapp active-directories list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the new active directory by listing all active'
' directories:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Create a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Deletes a Cloud NetApp Active Directory."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.active_directories import client as ad_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.active_directories import flags as activedirectories_flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Deletes an AD (Active Directory) config for Cloud NetApp Volumes.
""",
'EXAMPLES': """\
The following command deletes an AD named AD_NAME with the required arguments:
$ {command} AD_NAME --location=us-central1
To delete a AD Config asynchronously, run the following command:
$ {command} AD_NAME --location=us-central1 --async
""",
}
@staticmethod
def Args(parser):
activedirectories_flags.AddActiveDirectoryDeleteArgs(parser)
def Run(self, args):
"""Delete a Cloud NetApp Active Directory."""
activedirectory_ref = args.CONCEPTS.active_directory.Parse()
if not args.quiet:
delete_warning = ('You are about to delete an Active Directory {}.\n'
'Are you sure?'.format(
activedirectory_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = ad_client.ActiveDirectoriesClient(
release_track=self._RELEASE_TRACK)
result = client.DeleteActiveDirectory(activedirectory_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp active-directories list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the deletion by listing all active directories:'
'\n $ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(DeleteBeta):
"""Delete a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command to show metadata for a Cloud NetApp Active Directory."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.active_directories import client as ad_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Show metadata for a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describes an AD (Active Directory) config for Cloud NetApp Volumes.
""",
'EXAMPLES': """\
The following command describes an AD named AD_NAME with the required arguments:
$ {command} AD_NAME --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetActiveDirectoryPresentationSpec(
'The Active Directory to describe.')]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
activedirectory_ref = args.CONCEPTS.active_directory.Parse()
client = ad_client.ActiveDirectoriesClient(
release_track=self._RELEASE_TRACK)
return client.GetActiveDirectory(activedirectory_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Show metadata for a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Show metadata for a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Lists Cloud NetApp Active Directories."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.active_directories import client as ad_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Active Directories."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists AD (Active Directory) configs for Cloud NetApp Volumes.
""",
'EXAMPLES': """\
The following command lists AD configs in the given project and location:
$ {command} --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Active Directories.')
]).AddToParser(parser)
# TODO(b/242744672) Define List format for gcloud netapp active-directories
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
# Default to listing all Cloud NetApp Active Directories in all locations.
location = args.location if args.location else '-'
location_list = location_ref.split('/')
location_list[-1] = location
location_ref = '/'.join(location_list)
client = ad_client.ActiveDirectoriesClient(
release_track=self._RELEASE_TRACK)
return list(client.ListActiveDirectories(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Active Directories."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Active Directories."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,150 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Active Directory."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.active_directories import client as ad_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.active_directories import flags as activedirectories_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Updates AD (Active Directory) configs for Cloud NetApp Volumes.
""",
'EXAMPLES': """\
The following command updates an AD config in the given project and location with specified arguments:
$ {command} AD_NAME --location=us-central1 --domain=new-domain.com --dns=1.1.1.1 --site=new_site --net-bios-prefix=new_prefix --organizational-unit=ou2 --enable-aes=true --username=user2 --password="secure2" --backup-operators=backup_op1,backup_op2 --security-operators=secure_op1,secure_op2 --administrators=admin_op1,admin_op2 --enable-ldap-signing=true --encrypt-dc-connections=yes --kdc-hostname=kdc-host1
""",
}
@staticmethod
def Args(parser):
activedirectories_flags.AddActiveDirectoryUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Storage Pool in the current project."""
activedirectory_ref = args.CONCEPTS.active_directory.Parse()
client = ad_client.ActiveDirectoriesClient(self._RELEASE_TRACK)
orig_activedirectory = client.GetActiveDirectory(activedirectory_ref)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(client.messages.ActiveDirectory.LabelsValue,
orig_activedirectory.labels).GetOrNone()
else:
labels = None
active_directory = client.ParseUpdatedActiveDirectoryConfig(
orig_activedirectory,
domain=args.domain,
site=args.site,
dns=args.dns,
net_bios_prefix=args.net_bios_prefix,
organizational_unit=args.organizational_unit,
aes_encryption=args.enable_aes,
username=args.username,
password=args.password,
backup_operators=args.backup_operators,
security_operators=args.security_operators,
administrators=args.administrators,
kdc_hostname=args.kdc_hostname,
kdc_ip=args.kdc_ip,
nfs_users_with_ldap=args.nfs_users_with_ldap,
ldap_signing=args.enable_ldap_signing,
encrypt_dc_connections=args.encrypt_dc_connections,
description=args.description,
labels=labels)
updated_fields = []
# TODO(b/243601146) add config mapping and separate config file for update
if args.IsSpecified('domain'):
updated_fields.append('domain')
if args.IsSpecified('site'):
updated_fields.append('site')
if args.IsSpecified('dns'):
updated_fields.append('dns')
if args.IsSpecified('net_bios_prefix'):
updated_fields.append('netBiosPrefix')
if args.IsSpecified('organizational_unit'):
updated_fields.append('organizationalUnit')
if args.IsSpecified('enable_aes'):
updated_fields.append('aesEncryption')
if args.IsSpecified('username'):
updated_fields.append('username')
if args.IsSpecified('password'):
updated_fields.append('password')
if args.IsSpecified('backup_operators'):
updated_fields.append('backupOperators')
if args.IsSpecified('security_operators'):
updated_fields.append('securityOperators')
if args.IsSpecified('administrators'):
updated_fields.append('administrators')
if args.IsSpecified('kdc_hostname'):
updated_fields.append('kdcHostname')
if args.IsSpecified('kdc_ip'):
updated_fields.append('kdcIp')
if args.IsSpecified('nfs_users_with_ldap'):
updated_fields.append('nfsUsersWithLdap')
if args.IsSpecified('enable_ldap_signing'):
updated_fields.append('ldapSigning')
if args.IsSpecified('encrypt_dc_connections'):
updated_fields.append('encryptDcConnections')
if args.IsSpecified('description'):
updated_fields.append('description')
if (args.IsSpecified('update_labels') or
args.IsSpecified('remove_labels') or args.IsSpecified('clear_labels')):
updated_fields.append('labels')
update_mask = ','.join(updated_fields)
result = client.UpdateActiveDirectory(activedirectory_ref, active_directory,
update_mask, args.async_)
if args.async_:
command = 'gcloud {} netapp active-directories list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the updated active directory by listing all'
' active directories:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(UpdateBeta):
"""Update a Cloud NetApp Active Directory."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Backup Policies."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class BackupPolicies(base.Group):
"""Create and manage Cloud NetApp Backup Policies."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class BackupPoliciesBeta(BackupPolicies):
"""Create and manage Cloud NetApp Backup Policies."""

View File

@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Creates a Cloud NetApp Backup Policy."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_policies import client as backuppolicies_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_policies import flags as backuppolicies_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Backup Policy."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Creates a Backup Policy for Cloud NetApp Volumes.
""",
'EXAMPLES': """\
The following command creates a Backup Policy named BACKUP_POLICY with all possible arguments:
$ {command} BACKUP_POLICY --location=us-central1 --enabled=true --daily-backup-limit=3 --weekly-backup-limit=5 --monthly-backup-limit=2 --description="first backup policy" --labels=key1=val1
""",
}
@staticmethod
def Args(parser):
backuppolicies_flags.AddBackupPolicyCreateArgs(parser)
def Run(self, args):
"""Create a Cloud NetApp Backup Policy in the current project."""
backuppolicy_ref = args.CONCEPTS.backup_policy.Parse()
client = backuppolicies_client.BackupPoliciesClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.BackupPolicy.LabelsValue)
backup_policy = client.ParseBackupPolicy(
name=backuppolicy_ref.RelativeName(),
enabled=args.enabled,
daily_backup_limit=args.daily_backup_limit,
weekly_backup_limit=args.weekly_backup_limit,
monthly_backup_limit=args.monthly_backup_limit,
description=args.description,
labels=labels,
)
result = client.CreateBackupPolicy(
backuppolicy_ref, args.async_, backup_policy
)
if args.async_:
command = 'gcloud {} netapp backup-policies list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new backup policy by listing all backup'
' policies:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Backup Policy."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Volumes Backup Policy."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_policies import client as backuppolicies_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_policies import flags as backuppolicies_flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volumes Backup Policy."""
detailed_help = {
'DESCRIPTION': """\
Delete a Backup Policy
""",
'EXAMPLES': """\
The following command deletes a Backup Policy instance named BACKUP_POLICY in the default netapp/location
$ {command} BACKUP_POLICY
To delete a Backup Policy named BACKUP_POLICY asynchronously, run the following command:
$ {command} BACKUP_POLICY --async
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
backuppolicies_flags.AddBackupPolicyDeleteArgs(parser)
def Run(self, args):
"""Delete a Cloud NetApp Volumes Backup Policy."""
backuppolicy_ref = args.CONCEPTS.backup_policy.Parse()
if not args.quiet:
delete_warning = ('You are about to delete a Backup Policy {}.\n'
'Are you sure?'.format(backuppolicy_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = backuppolicies_client.BackupPoliciesClient(
release_track=self._RELEASE_TRACK)
result = client.DeleteBackupPolicy(backuppolicy_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp backup-policies list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the deletion by listing all Backup Policies:\n '
'$ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volumes Backup Policy."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describes a Cloud NetApp Volumes Backup Policy."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_policies import client as backuppolicies_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Show metadata for a Cloud NetApp Volumes Backup Policy."""
detailed_help = {
'DESCRIPTION': """\
Describe a Backup Policy
""",
'EXAMPLES': """\
The following command gets metadata using describe for a Backup Policy named BACKUP_POLICY in the default netapp/location:
$ {command} BACKUP_POLICY
To get metadata on a Backup Policy named BACKUP_POLICY in a specified location, run:
$ {command} BACKUP_POLICY --location=us-central1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetBackupPolicyPresentationSpec(
'The Backup Policy to describe.')]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
backuppolicy_ref = args.CONCEPTS.backup_policy.Parse()
client = backuppolicies_client.BackupPoliciesClient(
release_track=self._RELEASE_TRACK)
return client.GetBackupPolicy(backuppolicy_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Show metadata for a Cloud NetApp Volumes Backup Policy."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,83 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Lists Cloud NetApp Volumes Backup Policies."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_policies import client as backuppolicies_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.backup_policies import flags as backuppolicies_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volumes Backup Policies."""
detailed_help = {
'DESCRIPTION': """\
Lists Backup Policies for Cloud NetApp Volumes
""",
'EXAMPLES': """\
The following command lists all Backup Policies in the default netapp/location
$ {command}
To list all Backup Policies in a specified location, run:
$ {command} --location=us-central1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Backup Policies.'
)
]
).AddToParser(parser)
parser.display_info.AddFormat(
backuppolicies_flags.BACKUP_POLICIES_LIST_FORMAT
)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
# Default to listing all Cloud NetApp Active Directories in all locations.
location = args.location if args.location else '-'
location_list = location_ref.split('/')
location_list[-1] = location
location_ref = '/'.join(location_list)
client = backuppolicies_client.BackupPoliciesClient(
release_track=self._RELEASE_TRACK)
return list(client.ListBackupPolicies(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volumes Backup Policies."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,113 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Volumes Backup Policies."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_policies import client as backuppolicies_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_policies import flags as backuppolicies_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volumes Backup Policies."""
detailed_help = {
'DESCRIPTION': """\
Updates a Backup Policy
""",
'EXAMPLES': """\
The following command updates a Backup Policy named BACKUP_POLICY with all possible arguments
$ {command} BACKUP_POLICY --location=us-central1 --enabled=True --daily-backup-limit=5 --weekly-backup-limit=3 --monthly-backup-limit=2
To update a Backup Policy named BACKUP_POLICY asynchronously, run the following command:
$ {command} BACKUP_POLICY --async --location=us-central1 --enabled=True --daily-backup-limit=5 --weekly-backup-limit=3 --monthly-backup-limit=2
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
backuppolicies_flags.AddBackupPolicyUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Volumes Backup Policy in the current project."""
backuppolicy_ref = args.CONCEPTS.backup_policy.Parse()
client = backuppolicies_client.BackupPoliciesClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
orig_backuppolicy = client.GetBackupPolicy(backuppolicy_ref)
## Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.BackupPolicy.LabelsValue, orig_backuppolicy.labels
).GetOrNone()
else:
labels = None
backup_policy = client.ParseUpdatedBackupPolicy(
orig_backuppolicy,
enabled=args.enabled,
daily_backup_limit=args.daily_backup_limit,
weekly_backup_limit=args.weekly_backup_limit,
monthly_backup_limit=args.monthly_backup_limit,
description=args.description,
labels=labels,
)
updated_fields = []
if args.IsSpecified('enabled'):
updated_fields.append('enabled')
if args.IsSpecified('daily_backup_limit'):
updated_fields.append('dailyBackupLimit')
if args.IsSpecified('weekly_backup_limit'):
updated_fields.append('weeklyBackupLimit')
if args.IsSpecified('monthly_backup_limit'):
updated_fields.append('monthlyBackupLimit')
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
update_mask = ','.join(updated_fields)
result = client.UpdateBackupPolicy(
backuppolicy_ref, backup_policy, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp backup-policies list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated backup policy by listing all kms'
' configs:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volumes Backup Policies."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Backup Vaults."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class BackupVaults(base.Group):
"""Create and manage Cloud NetApp Backup Vaults."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class BackupVaultsBeta(BackupVaults):
"""Create and manage Cloud NetApp Backup Vaults."""

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Backups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Backups(base.Group):
"""Create and manage Cloud NetApp Backups."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class BackupsBeta(Backups):
"""Create and manage Cloud NetApp Backups."""

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a Cloud NetApp Backup."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults.backups import client as backups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_vaults.backups import flags as backups_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Backup.
""",
'EXAMPLES': """\
The following command creates a Backup named BACKUP attached to a Backup Vault named BACKUP_VAULT, and a source volume named SOURCE_VOL asynchronously using the specified arguments:
$ {command} BACKUP --location=LOCATION --async --backup-vault=BACKUP_VAULT --source-volume=SOURCE_VOL
""",
}
@staticmethod
def Args(parser):
backups_flags.AddBackupCreateArgs(parser)
def Run(self, args):
"""Create a Cloud NetApp Backup in the current project."""
backup_ref = args.CONCEPTS.backup.Parse()
client = backups_client.BackupsClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.Backup.LabelsValue
)
backup = client.ParseBackup(
name=backup_ref.RelativeName(),
source_volume=args.source_volume,
source_snapshot=args.source_snapshot,
description=args.description,
labels=labels,
)
result = client.CreateBackup(backup_ref, args.async_, backup)
if args.async_:
command = 'gcloud {} netapp backup-vaults backups list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new backup by listing all backups:\n $ {} '
.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Backup."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults.backups import client as backups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.backup_vaults.backups import flags as backups_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Delete a Cloud NetApp Backup.
""",
'EXAMPLES': """\
The following command deletes a Backup named BACKUP inside a backup vault named BACKUP_VAULT using the required arguments:
$ {command} BACKUP --location=us-central1 --backup-vault=BACKUP_VAULT
To delete a Backup named BACKUP asynchronously, run the following command:
$ {command} BACKUP --location=us-central1 --backup-vault=BACKUP_VAULT --async
""",
}
@staticmethod
def Args(parser):
"""Add args for deleting a Backup."""
concept_parsers.ConceptParser([
flags.GetBackupPresentationSpec('The Backup to delete.')
]).AddToParser(parser)
backups_flags.AddBackupBackupVaultResourceArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Delete a Cloud NetApp Backup in the current project."""
backup_ref = args.CONCEPTS.backup.Parse()
if not args.quiet:
delete_warning = (
'You are about to delete a Backup {}.\nAre you sure?'.format(
backup_ref.RelativeName()
)
)
if not console_io.PromptContinue(message=delete_warning):
return None
client = backups_client.BackupsClient(self._RELEASE_TRACK)
result = client.DeleteBackup(backup_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp backup-vaults backups list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the deletion by listing all backups:\n '
'$ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describe a Cloud NetApp Backup."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults.backups import client as backups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.backup_vaults.backups import flags as backups_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Backup.
""",
'EXAMPLES': """\
The following command describes a Backup named BACKUP in the given location and backup vault:
$ {command} NAME --location=us-central1 --backup-vault=BACKUP_VAULT
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetBackupPresentationSpec('The Backup to describe.')]
).AddToParser(parser)
backups_flags.AddBackupBackupVaultResourceArg(parser)
def Run(self, args):
"""Get a Cloud NetApp Backup in the current project."""
backup_ref = args.CONCEPTS.backup.Parse()
client = backups_client.BackupsClient(
release_track=self._RELEASE_TRACK
)
return client.GetBackup(backup_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""List Cloud NetApp Backups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults.backups import client as backups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.backup_vaults.backups import flags as backups_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Backups."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Backups.
""",
'EXAMPLES': """\
The following command lists all Backups in the given location and Backup Vault named BACKUP_VAULT:
$ {command} --location=us-central1 --backup-vault=BACKUP_VAULT
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Backups.'
)
]
).AddToParser(parser)
backups_flags.AddBackupBackupVaultResourceArg(parser)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
if args.CONCEPTS.backup_vault.Parse() is None:
raise exceptions.RequiredArgumentException(
'--backup-vault', 'Requires a Backup Vault to list Backups of'
)
backupvault_ref = args.CONCEPTS.backup_vault.Parse().RelativeName()
client = backups_client.BackupsClient(
release_track=self._RELEASE_TRACK
)
return list(client.ListBackups(backupvault_ref))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Backups."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Update a Cloud NetApp Backups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults.backups import client as backups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_vaults.backups import flags as backups_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Update a Cloud NetApp Backup and its specified parameters.
""",
'EXAMPLES': """\
The following command updates a Backup named BACKUP and its specified parameters:
$ {command} NAME --location=us-central1 --description="new description"
""",
}
@staticmethod
def Args(parser):
"""Add args for updating a Backup."""
backups_flags.AddBackupUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Backup in the current project."""
backup_ref = args.CONCEPTS.backup.Parse()
client = backups_client.BackupsClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
original_backup = client.GetBackup(backup_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.Backup.LabelsValue, original_backup.labels
).GetOrNone()
else:
labels = None
backup = client.ParseUpdatedBackup(
original_backup, description=args.description, labels=labels,
)
updated_fields = []
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
update_mask = ','.join(updated_fields)
result = client.UpdateBackup(
backup_ref, backup, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp backup-vaults backups list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated backup by listing all'
' backups:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Backup."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,104 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a Cloud NetApp Backup Vault."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults import client as backupvaults_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_vaults import flags as backupvaults_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Create(base.CreateCommand):
"""Create a Cloud NetApp Backup Vault."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Backup Vault.
""",
'EXAMPLES': """\
The following command creates a Backup Vault named BACKUP_VAULT asynchronously using the specified arguments:
$ {command} BACKUP_VAULT --location=LOCATION --async --description="test"
The following command creates a Backup Vault named CMEK_BACKUP_VAULT with a KMS config:
$ {command} CMEK_BACKUP_VAULT --location=LOCATION --kms-config=projects/PROJECT/locations/LOCATION/kmsConfigs/KMS_CONFIG
""",
}
@staticmethod
def Args(parser):
backupvaults_flags.AddBackupVaultCreateArgs(parser, Create._RELEASE_TRACK)
def Run(self, args):
"""Create a Cloud NetApp Backup Vault in the current project."""
backupvault_ref = args.CONCEPTS.backup_vault.Parse()
client = backupvaults_client.BackupVaultsClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.BackupVault.LabelsValue
)
backup_vault_type = None
backup_region = None
kms_config = args.kms_config
if self._RELEASE_TRACK == base.ReleaseTrack.BETA:
backup_vault_type = backupvaults_flags.GetBackupVaultTypeEnumFromArg(
args.backup_vault_type, client.messages
)
backup_region = args.backup_region
backup_vault = client.ParseBackupVault(
name=backupvault_ref.RelativeName(),
description=args.description,
labels=labels,
backup_retention_policy=args.backup_retention_policy,
backup_vault_type=backup_vault_type,
backup_region=backup_region,
kms_config=kms_config,
)
result = client.CreateBackupVault(
backupvault_ref, args.async_, backup_vault
)
if args.async_:
command = 'gcloud {} netapp backup-vaults list'.format(
' ' + self.ReleaseTrack().prefix if self.ReleaseTrack().prefix else ''
)
log.status.Print(
'Check the status of the new backup vault by listing all backup'
' vaults:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Backup Vault."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@staticmethod
def Args(parser):
backupvaults_flags.AddBackupVaultCreateArgs(
parser, CreateBeta._RELEASE_TRACK
)

View File

@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Volumes Backup Vault."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults import client as backupvaults_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_vaults import flags as backupvaults_flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volumes Backup Vault."""
detailed_help = {
'DESCRIPTION': """\
Delete a Backup Vault.
""",
'EXAMPLES': """\
The following command deletes a Backup Vault instance named BACKUP_VAULT in the default netapp/location:
$ {command} BACKUP_VAULT
To delete a Backup Vault named BACKUP_VAULT asynchronously, run the following command:
$ {command} BACKUP_VAULT --async
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
backupvaults_flags.AddBackupVaultDeleteArgs(parser)
def Run(self, args):
"""Delete a Cloud NetApp Volumes Backup Vault."""
backupvault_ref = args.CONCEPTS.backup_vault.Parse()
if not args.quiet:
delete_warning = ('You are about to delete a Backup Vault {}.\n'
'Are you sure?'.format(backupvault_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = backupvaults_client.BackupVaultsClient(
release_track=self._RELEASE_TRACK)
result = client.DeleteBackupVault(backupvault_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp backup-vaults list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the deletion by listing all Backup Vaults:\n '
'$ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volumes Backup Vault."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describes a Cloud NetApp Volumes Backup Vault."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults import client as backupvaults_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Show metadata for a Cloud NetApp Volumes Backup Vault."""
detailed_help = {
'DESCRIPTION': """\
Describe a Backup Vault.
""",
'EXAMPLES': """\
The following command gets metadata using describe for a Backup Vault instance named BACKUP_VAULT in the default netapp/location:
$ {command} BACKUP_VAULT
To get metadata on a Backup Vault named BACKUP_VAULT in a specified location, run:
$ {command} BACKUP_VAULT --location=us-central1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetBackupVaultPresentationSpec(
'The Backup Vault to describe.')]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
backupvault_ref = args.CONCEPTS.backup_vault.Parse()
client = backupvaults_client.BackupVaultsClient(
release_track=self._RELEASE_TRACK)
return client.GetBackupVault(backupvault_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Show metadata for a Cloud NetApp Volumes Backup Vault."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,83 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Lists Cloud NetApp Volumes Backup Vaults."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults import client as backupvaults_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.backup_vaults import flags as backupvaults_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volumes Backup Vaults."""
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Backup Vaults to store Cloud NetApp Volumes Backups.
""",
'EXAMPLES': """\
The following command lists all Backup Vaults in the default netapp/location
$ {command}
To list all Backup Vaults in a specified location, run:
$ {command} --location=us-central1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Backup Vaults.'
)
]
).AddToParser(parser)
parser.display_info.AddFormat(
backupvaults_flags.BACKUP_VAULTS_LIST_FORMAT
)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
# Default to listing all Cloud NetApp Backup Vaults in all locations.
location = args.location if args.location else '-'
location_list = location_ref.split('/')
location_list[-1] = location
location_ref = '/'.join(location_list)
client = backupvaults_client.BackupVaultsClient(
release_track=self._RELEASE_TRACK)
return list(client.ListBackupVaults(location_ref))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volumes Backup Vaults."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,104 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Volumes Backup Vaults."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.backup_vaults import client as backupvaults_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.backup_vaults import flags as backupvaults_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volumes Backup Vault."""
detailed_help = {
'DESCRIPTION': """\
Updates a Backup Vault
""",
'EXAMPLES': """\
The following command updates a Backup Vault instance named BACKUP_VAULT
$ {command} BACKUP_VAULT --location=us-central1 --description="new description" --update-labels=newkey=newval
To update a Backup Vault named BACKUP_VAULT asynchronously, run the following command:
$ {command} BACKUP_VAULT --async --location=us-central1 --description="new description" --update-labels=newkey=newval """,
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
backupvaults_flags.AddBackupVaultUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Backup Vaults in the current project."""
backupvault_ref = args.CONCEPTS.backup_vault.Parse()
client = backupvaults_client.BackupVaultsClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
orig_backupvault = client.GetBackupVault(backupvault_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.BackupVault.LabelsValue, orig_backupvault.labels
).GetOrNone()
else:
labels = None
backup_vault = client.ParseUpdatedBackupVault(
orig_backupvault,
description=args.description,
labels=labels,
backup_retention_policy=args.backup_retention_policy,
)
updated_fields = []
if args.IsSpecified('description'):
updated_fields.append('description')
if args.IsSpecified('backup_retention_policy'):
updated_fields.append('backupRetentionPolicy')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
update_mask = ','.join(updated_fields)
result = client.UpdateBackupVault(
backupvault_ref, backup_vault, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp backup-vaults list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated backup vault by listing all kms'
' configs:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volumes Backup Vault."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Host Groups."""
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class HostGroups(base.Group):
"""Create and manage Cloud NetApp Host Groups."""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class HostGroupsBeta(HostGroups):
"""Create and manage Cloud NetApp Host Groups."""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class HostGroupsAlpha(HostGroupsBeta):
"""Create and manage Cloud NetApp Host Groups."""

View File

@@ -0,0 +1,97 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a Cloud NetApp Host Group."""
from googlecloudsdk.api_lib.netapp.host_groups import client as host_groups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.host_groups import flags as host_groups_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Host Group.
""",
'EXAMPLES': """\
The following command creates a Host Group named NAME using the required arguments:
$ {command} NAME --location=us-central1 --type=ISCSI_INITIATOR --hosts=host1,host2 --os-type=LINUX
""",
}
@staticmethod
def Args(parser):
host_groups_flags.AddHostGroupCreateArgs(parser)
def Run(self, args):
"""Create a Cloud NetApp Host Group in the current project."""
host_group_ref = args.CONCEPTS.host_group.Parse()
client = host_groups_client.HostGroupsClient(self._RELEASE_TRACK)
host_group_type = host_groups_flags.GetHostGroupTypeEnumFromArg(
args.type, client.messages
)
os_type = host_groups_flags.GetHostGroupOsTypeEnumFromArg(
args.os_type, client.messages
)
labels = labels_util.ParseCreateArgs(
args, client.messages.HostGroup.LabelsValue
)
host_group = client.ParseHostGroupConfig(
name=host_group_ref.RelativeName(),
host_group_type=host_group_type,
hosts=args.hosts,
os_type=os_type,
description=args.description,
labels=labels,
)
result = client.CreateHostGroup(host_group_ref, args.async_, host_group)
if args.async_:
command = 'gcloud {} netapp host-groups list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new host group by listing all host groups:\n'
'$ {} '.format(command)
)
return result
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Create a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Host Group."""
from googlecloudsdk.api_lib.netapp.host_groups import client as host_groups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Host Group."""
detailed_help = {
'DESCRIPTION': """\
Delete a Cloud NetApp Host Group.
""",
'EXAMPLES': """\
The following command deletes a Host Group named NAME:
$ {command} NAME --location=us-central1
To delete a Host Group named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --async
""",
}
@staticmethod
def Args(parser):
"""Add args for deleting a Host Group."""
concept_parsers.ConceptParser([
flags.GetHostGroupPresentationSpec('The Host Group to delete.')
]).AddToParser(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Delete a Cloud NetApp Host Group in the current project."""
host_group_ref = args.CONCEPTS.host_group.Parse()
if not args.quiet:
delete_warning = (
'You are about to delete a Host Group {}.\nAre you sure?'.format(
host_group_ref.RelativeName()
)
)
if not console_io.PromptContinue(message=delete_warning):
return None
client = host_groups_client.HostGroupsClient(self.ReleaseTrack())
result = client.DeleteHostGroup(host_group_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp host-groups list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the deletion by listing all host groups:\n '
'$ {} '.format(command)
)
return result
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(DeleteBeta):
"""Delete a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describe a Cloud NetApp Host Group."""
from googlecloudsdk.api_lib.netapp.host_groups import client as host_groups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Host Group."""
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Host Group.
""",
'EXAMPLES': """\
The following command describes a Host Group named NAME in the given location:
$ {command} NAME --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetHostGroupPresentationSpec('The Host Group to describe.')]
).AddToParser(parser)
def Run(self, args):
"""Get a Cloud NetApp Host Group in the current project."""
host_group_ref = args.CONCEPTS.host_group.Parse()
client = host_groups_client.HostGroupsClient(
release_track=self.ReleaseTrack()
)
return client.GetHostGroup(host_group_ref)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Describe a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""List Cloud NetApp Host Groups."""
from googlecloudsdk.api_lib.netapp.host_groups import client as host_groups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Host Groups."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Host Groups.
""",
'EXAMPLES': """\
The following command lists all Host Groups in the given location:
$ {command} --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Host Groups.'
)
]).AddToParser(parser)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
client = host_groups_client.HostGroupsClient(
release_track=self._RELEASE_TRACK
)
return client.ListHostGroups(location_ref)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Host Groups."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Host Groups."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,110 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Host Group."""
from googlecloudsdk.api_lib.netapp.host_groups import client as host_groups_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.host_groups import flags as host_groups_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Host Group."""
detailed_help = {
'DESCRIPTION': """\
Update a Cloud NetApp Host Group and its specified parameters.
""",
'EXAMPLES': """\
The following command updates a Host Group named NAME and its specified parameters:
$ {command} NAME --location=us-central1 --description="new description" --hosts="host3,host4" --update-labels=key2=val2
""",
}
@staticmethod
def Args(parser):
host_groups_flags.AddHostGroupUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Host Group in the current project."""
host_group_ref = args.CONCEPTS.host_group.Parse()
client = host_groups_client.HostGroupsClient(self.ReleaseTrack())
labels_diff = labels_util.Diff.FromUpdateArgs(args)
original_host_group = client.GetHostGroup(host_group_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.HostGroup.LabelsValue, original_host_group.labels
).GetOrNone()
else:
labels = None
host_group = client.ParseUpdatedHostGroupConfig(
original_host_group,
hosts=args.hosts,
description=args.description,
labels=labels,
)
updated_fields = []
if args.IsSpecified('description'):
updated_fields.append('description')
if args.IsSpecified('hosts'):
updated_fields.append('hosts')
if (labels is not None) and (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
update_mask = ','.join(updated_fields)
result = client.UpdateHostGroup(
host_group_ref, host_group, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp host-groups describe {} --location {}'.format(
self.ReleaseTrack().prefix,
host_group_ref.Name(),
host_group_ref.locationsId,
)
log.status.Print(
'Check the status of the updated host group by describing it:\n '
'$ {} '.format(command)
)
return result
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(UpdateBeta):
"""Update a Cloud NetApp Host Group."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Volumes KMS Configs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class KmsConfigs(base.Group):
"""Create and manage Cloud NetApp Volumes KMS Configs."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class KmsConfigsBeta(KmsConfigs):
"""Create and manage Cloud NetApp Volumes KMS Configs."""

View File

@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Creates a Cloud NetApp Volumes KMS Config."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.kms_configs import client as kmsconfigs_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.kms_configs import flags as kmsconfigs_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Volumes KMS Config."""
detailed_help = {
'DESCRIPTION': """\
Creates a KMS (Key Management System) Config to encrypt Cloud NetApp Volumes, Storage Pools etc. using Customer Managed Encryption Keys (CMEK)
""",
'EXAMPLES': """\
The following command creates a KMS Config instance named KMS_CONFIG using specified project, location, Key Ring and Crypto Key
$ {command} KMS_CONFIG --location=us-central1 --kms-location=northamerica-northeast1 --kms-project=kms-project1 --kms-keyring=kms-keyring21 --kms-key=crypto-key1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
kmsconfigs_flags.AddKMSConfigCreateArgs(parser)
def Run(self, args):
"""Create a Cloud NetApp Volumes KMS Config in the current project."""
kmsconfig_ref = args.CONCEPTS.kms_config.Parse()
client = kmsconfigs_client.KmsConfigsClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.KmsConfig.LabelsValue
)
crypto_key_name = kmsconfigs_flags.ConstructCryptoKeyName(
args.kms_project, args.kms_location, args.kms_keyring, args.kms_key
)
kms_config = client.ParseKmsConfig(
name=kmsconfig_ref.RelativeName(),
crypto_key_name=crypto_key_name,
description=args.description,
labels=labels,
)
result = client.CreateKmsConfig(kmsconfig_ref, args.async_, kms_config)
if args.async_:
command = 'gcloud {} netapp kms-configs list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new KMS Config by listing all KMS configs:\n'
' $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Volumes KMS Config."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Volumes KMS Config."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.kms_configs import client as kmsconfigs_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.kms_configs import flags as kmsconfigs_flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volumes KMS Config."""
detailed_help = {
'DESCRIPTION': """\
Delete a KMS (Key Management System) Config
""",
'EXAMPLES': """\
The following command deletes a KMS Config instance named KMS_CONFIG in the default netapp/location.
$ {command} KMS_CONFIG
To delete a KMS Config named KMS_CONFIG asynchronously, run the following command:
$ {command} KMS_CONFIG --async
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
kmsconfigs_flags.AddKMSConfigDeleteArgs(parser)
def Run(self, args):
"""Delete a Cloud NetApp Volumes KMS Config."""
kmsconfig_ref = args.CONCEPTS.kms_config.Parse()
if not args.quiet:
delete_warning = ('You are about to delete a KMS Config {}.\n'
'Are you sure?'.format(kmsconfig_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = kmsconfigs_client.KmsConfigsClient(
release_track=self._RELEASE_TRACK)
result = client.DeleteKmsConfig(kmsconfig_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp kms-configs list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the deletion by listing all KMS configs:\n '
'$ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volumes KMS Config."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describes a Cloud NetApp Volumes KMS Config."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.kms_configs import client as kmsconfigs_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Show metadata for a Cloud NetApp Volumes KMS Config."""
detailed_help = {
'DESCRIPTION': """\
Describe a KMS (Key Management System) Config.
""",
'EXAMPLES': """\
The following command gets metadata using describe for a KMS Config instance named KMS_CONFIG in the default netapp/location.
$ {command} KMS_CONFIG
To get metadata on a KMS Config named KMS_CONFIG in a specified location, run:
$ {command} KMS_CONFIG --location=us-central1s
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetKmsConfigPresentationSpec(
'The KMS Config to describe.')]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
kmsconfig_ref = args.CONCEPTS.kms_config.Parse()
client = kmsconfigs_client.KmsConfigsClient(
release_track=self._RELEASE_TRACK)
return client.GetKmsConfig(kmsconfig_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Show metadata for a Cloud NetApp Volumes KMS Config."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Encrypt volumes under a Cloud NetApp Volumes KMS Config."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.kms_configs import client as kmsconfigs_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.kms_configs import flags as kmsconfigs_flags
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Encrypt(base.Command):
"""Encrypt all existing volumes and storage pools in the same region with the desired Cloud NetApp Volumes KMS Config."""
detailed_help = {
'DESCRIPTION': """\
Encrypt the existing volumes with the desired KMS (Key Management System) Config using Customer Managed Encryption Keys (CMEK).
""",
'EXAMPLES': """\
The following command encrypts the existing volumes with the desired KMS Config instance named KMS_CONFIG using specified project and location.
$ {command} KMS_CONFIG --location=us-central1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
kmsconfigs_flags.AddKMSConfigEncryptArgs(parser)
def Run(self, args):
"""Encrypt all existing volumes and storage pools under a Cloud NetApp Volumes KMS Config in the current project."""
kmsconfig_ref = args.CONCEPTS.kms_config.Parse()
client = kmsconfigs_client.KmsConfigsClient(self._RELEASE_TRACK)
return client.EncryptKmsConfig(kmsconfig_ref, args.async_)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class EncryptBeta(Encrypt):
"""Encrypt all existing volumes and storage pools in the same region with the desired Cloud NetApp Volumes KMS Config."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Lists Cloud NetApp Volumes KMS Configs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.kms_configs import client as kmsconfigs_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.kms_configs import flags as kmsconfigs_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volumes KMS Configs."""
detailed_help = {
'DESCRIPTION': """\
Lists KMS (Key Management System) Configs to encrypt Cloud NetApp Volumes, Storage Pools etc. using Customer Managed Encryption Keys (CMEK).
""",
'EXAMPLES': """\
The following command lists all KMS Config instance in the default netapp/location
$ {command}
To list all KMS Configs in a specified location, run:
$ {command} --location=us-central1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list KMS Configs.'
)
]
).AddToParser(parser)
parser.display_info.AddFormat(
kmsconfigs_flags.KMS_CONFIGS_LIST_FORMAT
)
parser.display_info.AddFormat(kmsconfigs_flags.KMS_CONFIGS_LIST_FORMAT)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
# Default to listing all Cloud NetApp Active Directories in all locations.
location = args.location if args.location else '-'
location_list = location_ref.split('/')
location_list[-1] = location
location_ref = '/'.join(location_list)
client = kmsconfigs_client.KmsConfigsClient(
release_track=self._RELEASE_TRACK)
return list(client.ListKmsConfigs(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volumes KMS Configs."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,136 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Volumes KMS Config."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.kms_configs import client as kmsconfigs_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.kms_configs import flags as kmsconfigs_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volumes KMS Config."""
detailed_help = {
'DESCRIPTION': """\
Updates a KMS (Key Management System) Config.
""",
'EXAMPLES': """\
The following command updates a KMS Config instance named KMS_CONFIG with all possible arguments:
$ {command} KMS_CONFIG --location=us-central1 --kms-location=europe-southwest1 --kms-project=new-kms-project --kms-keyring=kms-keyring2 --kms-key=crypto-key2
To update a KMS Config named KMS_CONFIG asynchronously, run the following command:
$ {command} KMS_CONFIG --async --location=us-central1 --kms-location=europe-southwest1 --kms-project=new-kms-project --kms-keyring=kms-keyring2 --kms-key=crypto-key2 """,
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
kmsconfigs_flags.AddKMSConfigUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Volumes KMS Config in the current project."""
kmsconfig_ref = args.CONCEPTS.kms_config.Parse()
client = kmsconfigs_client.KmsConfigsClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
orig_kmsconfig = client.GetKmsConfig(kmsconfig_ref)
## Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.KmsConfig.LabelsValue, orig_kmsconfig.labels
).GetOrNone()
else:
labels = None
if args.kms_project is not None:
kms_project = args.kms_project
else:
kms_project = kmsconfigs_flags.ExtractKmsProjectFromCryptoKeyName(
orig_kmsconfig.cryptoKeyName
)
if args.kms_location is not None:
kms_location = args.kms_location
else:
kms_location = kmsconfigs_flags.ExtractKmsLocationFromCryptoKeyName(
orig_kmsconfig.cryptoKeyName
)
if args.kms_keyring is not None:
kms_keyring = args.kms_keyring
else:
kms_keyring = kmsconfigs_flags.ExtractKmsKeyRingFromCryptoKeyName(
orig_kmsconfig.cryptoKeyName
)
if args.kms_key is not None:
kms_key = args.kms_key
else:
kms_key = kmsconfigs_flags.ExtractKmsCryptoKeyFromCryptoKeyName(
orig_kmsconfig.cryptoKeyName
)
crypto_key_name = kmsconfigs_flags.ConstructCryptoKeyName(
kms_project, kms_location, kms_keyring, kms_key
)
kms_config = client.ParseUpdatedKmsConfig(
orig_kmsconfig,
crypto_key_name=crypto_key_name,
description=args.description,
labels=labels,
)
updated_fields = []
if (
args.IsSpecified('kms_project')
or args.IsSpecified('kms_location')
or args.IsSpecified('kms_keyring')
or args.IsSpecified('kms_key')
):
updated_fields.append('cryptoKeyName')
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
update_mask = ','.join(updated_fields)
result = client.UpdateKmsConfig(
kmsconfig_ref, kms_config, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp kms-configs list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated kms config by listing all kms'
' configs:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volumes KMS Config."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Verifies Cloud NetApp Volumes KMS Config reachability."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.kms_configs import client as kmsconfigs_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Verify(base.Command):
"""Verify that the Cloud NetApp Volumes KMS Config is reachable."""
detailed_help = {
'DESCRIPTION': """\
Verifies that the Cloud NetApp Volumes KMS (Key Management System) Config is reachable.
""",
'EXAMPLES': """\
The following command verifies that the KMS Config instance named KMS_CONFIG is reachable using specified location.
$ {command} KMS_CONFIG --location=us-central1
""",
}
_RELEASE_TRACK = base.ReleaseTrack.GA
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetKmsConfigPresentationSpec('The KMS Config used to verify')]
).AddToParser(parser)
def Run(self, args):
"""Verify that the Cloud NetApp Volumes KMS Config is reachable."""
kmsconfig_ref = args.CONCEPTS.kms_config.Parse()
client = kmsconfigs_client.KmsConfigsClient(self._RELEASE_TRACK)
return client.VerifyKmsConfig(kmsconfig_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class VerifyBeta(Verify):
"""Verify that the Cloud NetApp Volumes KMS Config is reachable."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp locations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Locations(base.Group):
"""Get and list locations where Cloud NetApp Files is available."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class LocationsBeta(Locations):
"""Get and list locations where Cloud NetApp Files is available."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class LocationsAlpha(LocationsBeta):
"""Get and list locations where Cloud NetApp Files is available."""

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command for describing Cloud NetApp Files locations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp import netapp_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Files location."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION':
'Describe a Cloud NetApp Files location.',
'EXAMPLES':
"""\
The following command shows the details for the NetApp Files location named NAME.
$ {command} NAME
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetLocationPresentationSpec('The location to describe.')
]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
location_ref = args.CONCEPTS.location.Parse().RelativeName()
client = netapp_client.NetAppClient(release_track=self._RELEASE_TRACK)
return client.GetLocation(location_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Files location."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Describe a Cloud NetApp Files location."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command for listing Cloud NetApp Files locations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp import netapp_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.locations import flags
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List all Cloud NetApp Files locations."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION':
'Lists all Cloud NetApp Files locations.',
'EXAMPLES':
"""\
The following command lists NetApp Files locations.
$ {command}
""",
}
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def Run(self, args):
project_ref = resources.REGISTRY.Parse(
properties.VALUES.core.project.GetOrFail(),
collection='netapp.projects')
client = netapp_client.NetAppClient(release_track=self._RELEASE_TRACK)
return list(client.ListLocations(project_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List all Cloud NetApp Files locations."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List all Cloud NetApp Files locations."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Operations(base.Group):
"""Read and manage Cloud NetApp Files Operations."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class OperationsBeta(Operations):
"""Read and manage Cloud NetApp Files Operations."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class OperationsAlpha(OperationsBeta):
"""Read and manage Cloud NetApp Files Operations."""

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command for describing Cloud NetApp Files Operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp import netapp_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Files operation."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION':
'Describe a Cloud NetApp Files operation.',
'EXAMPLES':
"""\
The following command shows the details for the NetApp Files operation named NAME.
$ {command} NAME
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetOperationPresentationSpec('The operation to describe.')
]).AddToParser(parser)
parser.display_info.AddFormat('default')
def Run(self, args):
"""Run the describe command."""
operation_ref = args.CONCEPTS.operation.Parse()
client = netapp_client.NetAppClient(release_track=self._RELEASE_TRACK)
return client.GetOperation(operation_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Files operation."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Describe a Cloud NetApp Files operation."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,110 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command for listing Cloud NetApp Files operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp import netapp_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.operations import flags as operations_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Files operations."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION':
'Lists all Cloud NetApp Files operations.',
'EXAMPLES':
"""\
The following command lists NetApp Files operations under a given location
$ {command} --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list operations.')
]).AddToParser(parser)
parser.display_info.AddFormat(operations_flags.OPERATIONS_LIST_FORMAT)
def Run(self, args):
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
if args.location:
location_list = location_ref.split('/')
location_list[-1] = args.location
location_ref = '/'.join(location_list)
client = netapp_client.NetAppClient(release_track=self._RELEASE_TRACK)
return list(client.ListOperations(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Files operations."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
detailed_help = {
'DESCRIPTION':
'Lists all Cloud NetApp Files operations.',
'EXAMPLES':
"""\
The following command lists NetApp Files operations under a given location
$ {command} --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list operations.')
]).AddToParser(parser)
parser.display_info.AddFormat(operations_flags.OPERATIONS_LIST_FORMAT)
def Run(self, args):
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
if args.location:
location_list = location_ref.split('/')
location_list[-1] = args.location
location_ref = '/'.join(location_list)
client = netapp_client.NetAppClient(release_track=self._RELEASE_TRACK)
return list(client.ListOperations(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Files operations."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Storage Pools."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class StoragePools(base.Group):
"""Create and manage Cloud NetApp Storage Pools."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class StoragePoolsBeta(StoragePools):
"""Create and manage Cloud NetApp Storage Pools."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class StoragePoolsAlpha(StoragePoolsBeta):
"""Create and manage Cloud NetApp Storage Pools."""

View File

@@ -0,0 +1,154 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Creates a Cloud NetApp Storage Pool."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.storage_pools import client as storagepools_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.storage_pools import flags as storagepools_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
def _CommonArgs(parser, release_track):
storagepools_flags.AddStoragePoolCreateArgs(
parser, release_track=release_track
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Creates a Storage Pool to contain Volumes with a specified Service Level and capacity.
""",
'EXAMPLES': """\
The following command creates a Storage Pool named NAME using all possible arguments with a VPC network in the same project
$ {command} NAME --location=us-central1 --service-level=standard --capacity=2048 --network=name=default --active-directory=ad1 --kms-config=kms-config1 --enable-ldap=true --description="example description"
The following command creates a Storage pool named NAME using all possible arguments with a shared VPC network in a separate project called VPC_PROJECT
$ {command} NAME --location=us-central1 --service-level=standard --capacity=2048 --network=name=projects/VPC_PROJECT/locations/us-central1/networks/default --active-directory=ad1 --kms-config=kms-config1 --enable-ldap=true --description="example description"
""",
}
@staticmethod
def Args(parser):
_CommonArgs(parser, Create._RELEASE_TRACK)
def Run(self, args):
"""Create a Cloud NetApp Storage Pool in the current project."""
storagepool_ref = args.CONCEPTS.storage_pool.Parse()
client = storagepools_client.StoragePoolsClient(self._RELEASE_TRACK)
service_level = storagepools_flags.GetStoragePoolServiceLevelArg(
client.messages, self._RELEASE_TRACK
).GetEnumForChoice(args.service_level)
labels = labels_util.ParseCreateArgs(
args, client.messages.StoragePool.LabelsValue)
capacity_in_gib = args.capacity >> 30
zone = args.zone
replica_zone = args.replica_zone
if args.total_throughput is not None:
total_throughput_mibps = args.total_throughput >> 20
else:
total_throughput_mibps = None
hot_tier_size_gib = None
qos_type = None
if args.qos_type is not None:
qos_type = storagepools_flags.GetStoragePoolQosTypeArg(
client.messages
).GetEnumForChoice(args.qos_type)
enable_hot_tier_auto_resize = None
unified_pool = None
storage_pool_type = None
if args.type is not None:
storage_pool_type = storagepools_flags.GetStoragePoolTypeEnumFromArg(
args.type, client.messages
)
if (self._RELEASE_TRACK == base.ReleaseTrack.ALPHA or
self._RELEASE_TRACK == base.ReleaseTrack.BETA):
if args.hot_tier_size is not None:
hot_tier_size_gib = args.hot_tier_size >> 30
enable_hot_tier_auto_resize = args.enable_hot_tier_auto_resize
if args.unified_pool is not None:
unified_pool = args.unified_pool
storage_pool = client.ParseStoragePoolConfig(
name=storagepool_ref.RelativeName(),
service_level=service_level,
network=args.network,
active_directory=args.active_directory,
kms_config=args.kms_config,
enable_ldap=args.enable_ldap,
capacity=capacity_in_gib,
description=args.description,
allow_auto_tiering=args.allow_auto_tiering,
zone=zone,
replica_zone=replica_zone,
custom_performance_enabled=args.custom_performance_enabled,
total_throughput=total_throughput_mibps,
total_iops=args.total_iops,
hot_tier_size=hot_tier_size_gib,
enable_hot_tier_auto_resize=enable_hot_tier_auto_resize,
labels=labels,
unified_pool=unified_pool,
qos_type=qos_type,
storage_pool_type=storage_pool_type,
)
result = client.CreateStoragePool(
storagepool_ref, args.async_, storage_pool
)
if args.async_:
command = 'gcloud {} netapp storage-pools list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new storage pool by listing all storage'
' pools:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@staticmethod
def Args(parser):
_CommonArgs(parser, CreateBeta._RELEASE_TRACK)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Create a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
@staticmethod
def Args(parser):
_CommonArgs(parser, CreateAlpha._RELEASE_TRACK)

View File

@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Storage Pool."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.storage_pools import client as storagepools_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.storage_pools import flags as storagepools_flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Delete a Storage Pool
""",
'EXAMPLES': """\
The following command deletes a Storage Pool named NAME in the given location
$ {command} NAME --location=us-central1
To delete a Storage Pool asynchronously, run the following command:
$ {command} NAME --location=us-central1 --async
""",
}
@staticmethod
def Args(parser):
storagepools_flags.AddStoragePoolDeleteArgs(parser)
def Run(self, args):
"""Delete a Cloud NetApp Storage Pool."""
storagepool_ref = args.CONCEPTS.storage_pool.Parse()
if not args.quiet:
delete_warning = ('You are about to delete a Storage Pool {}.\n'
'Are you sure?'.format(storagepool_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = storagepools_client.StoragePoolsClient(
release_track=self._RELEASE_TRACK)
result = client.DeleteStoragePool(storagepool_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp storage-pools list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the deletion by listing all storage pools:\n '
'$ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(DeleteBeta):
"""Delete a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command to show metadata for a Cloud NetApp Storage Pool."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.storage_pools import client as storagepools_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Show metadata for a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describe a Storage Pool
""",
'EXAMPLES': """\
The following command describes a Storage Pool named NAME in the given location
$ {command} NAME --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetStoragePoolPresentationSpec(
'The Storage Pool to describe.')]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
storagepool_ref = args.CONCEPTS.storage_pool.Parse()
client = storagepools_client.StoragePoolsClient(
release_track=self._RELEASE_TRACK)
return client.GetStoragePool(storagepool_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Show metadata for a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Show metadata for a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,83 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Lists Cloud NetApp Storage Pools."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.storage_pools import client as storagepools_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.storage_pools import flags as storagepools_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Storage Pools."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Storage Pools
""",
'EXAMPLES': """\
The following command lists Storage Pools in the given location
$ {command} --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Storage Pools.')
]).AddToParser(parser)
parser.display_info.AddFormat(
storagepools_flags.STORAGE_POOLS_LIST_FORMAT
)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
# Default to listing all Cloud NetApp Storage Pools in all locations.
location = args.location if args.location else '-'
location_list = location_ref.split('/')
location_list[-1] = location
location_ref = '/'.join(location_list)
client = storagepools_client.StoragePoolsClient(
release_track=self._RELEASE_TRACK)
return list(client.ListStoragePools(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Storage Pools."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Storage Pools."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Switch a Regional Cloud NetApp Flex Storage Pool zone."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.storage_pools import client as storagepools_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.storage_pools import flags as storagepools_flags
from googlecloudsdk.core import log
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA
)
class Switch(base.Command):
"""Switch a Regional Cloud NetApp Flex Storage Pool zone."""
detailed_help = {
'DESCRIPTION': """\
Switch a Regional Cloud NetApp Flex Storage Pool zone.
""",
'EXAMPLES': """\
The following command switches zone of a Storage Pool named NAME using the required arguments:
$ {command} NAME --location=us-central1
To switch zone of a Storage Pool named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --async
""",
}
@staticmethod
def Args(parser):
storagepools_flags.AddStoragePoolSwitchArg(parser)
def Run(self, args):
"""Switch a Regional Cloud NetApp Flex Storage Pool zone in the current project."""
storagepool_ref = args.CONCEPTS.storage_pool.Parse()
client = storagepools_client.StoragePoolsClient(self.ReleaseTrack())
result = client.SwitchStoragePool(storagepool_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp storage-pools list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the zone switch of storage pool by listing all'
' storage pools:\n $ {} '.format(command)
)
return result

View File

@@ -0,0 +1,172 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Storage Pool."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.storage_pools import client as storagepools_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.storage_pools import flags as storagepools_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
def _CommonArgs(parser, release_track):
storagepools_flags.AddStoragePoolUpdateArgs(parser, release_track)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Updates a Storage Pool with given arguments
""",
'EXAMPLES': """\
The following command updates a Storage Pool named NAME in the given location
$ {command} NAME --location=us-central1 --capacity=4096 --active-directory=ad-2 --description="new description" --update-labels=key1=val1
""",
}
@staticmethod
def Args(parser):
_CommonArgs(parser, Update._RELEASE_TRACK)
def Run(self, args):
"""Update a Cloud NetApp Storage Pool in the current project."""
storagepool_ref = args.CONCEPTS.storage_pool.Parse()
client = storagepools_client.StoragePoolsClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
orig_storagepool = client.GetStoragePool(storagepool_ref)
capacity_in_gib = args.capacity >> 30 if args.capacity else None
## Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.StoragePool.LabelsValue, orig_storagepool.labels
).GetOrNone()
else:
labels = None
zone = args.zone
replica_zone = args.replica_zone
if args.total_throughput is not None:
total_throughput_mibps = args.total_throughput >> 20
else:
total_throughput_mibps = None
hot_tier_size_gib = None
enable_hot_tier_auto_resize = None
qos_type = None
if args.qos_type is not None:
qos_type = storagepools_flags.GetStoragePoolQosTypeArg(
client.messages
).GetEnumForChoice(args.qos_type)
if (self._RELEASE_TRACK == base.ReleaseTrack.ALPHA or
self._RELEASE_TRACK == base.ReleaseTrack.BETA):
if args.hot_tier_size is not None:
hot_tier_size_gib = args.hot_tier_size >> 30
enable_hot_tier_auto_resize = args.enable_hot_tier_auto_resize
storage_pool = client.ParseUpdatedStoragePoolConfig(
orig_storagepool,
capacity=capacity_in_gib,
active_directory=args.active_directory,
description=args.description,
labels=labels,
allow_auto_tiering=args.allow_auto_tiering,
zone=zone,
replica_zone=replica_zone,
total_throughput=total_throughput_mibps,
total_iops=args.total_iops,
hot_tier_size=hot_tier_size_gib,
enable_hot_tier_auto_resize=enable_hot_tier_auto_resize,
qos_type=qos_type,
)
updated_fields = []
if args.IsSpecified('capacity'):
updated_fields.append('capacityGib')
if args.IsSpecified('active_directory'):
updated_fields.append('activeDirectory')
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
if args.IsSpecified('allow_auto_tiering'):
updated_fields.append('allowAutoTiering')
if args.IsSpecified('zone'):
updated_fields.append('zone')
if args.IsSpecified('replica_zone'):
updated_fields.append('replicaZone')
if args.IsSpecified('total_throughput'):
updated_fields.append('totalThroughputMibps')
if args.IsSpecified('total_iops'):
updated_fields.append('totalIops')
if args.IsSpecified('qos_type'):
updated_fields.append('qosType')
if (self._RELEASE_TRACK == base.ReleaseTrack.ALPHA or
self._RELEASE_TRACK == base.ReleaseTrack.BETA):
if args.IsSpecified('hot_tier_size'):
updated_fields.append('hotTierSizeGib')
if args.IsSpecified('enable_hot_tier_auto_resize'):
updated_fields.append('enableHotTierAutoResize')
update_mask = ','.join(updated_fields)
result = client.UpdateStoragePool(
storagepool_ref, storage_pool, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp storage-pools list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated storage pool by listing all storage'
' pools:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@staticmethod
def Args(parser):
_CommonArgs(parser, UpdateBeta._RELEASE_TRACK)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(UpdateBeta):
"""Update a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
@staticmethod
def Args(parser):
_CommonArgs(parser, UpdateAlpha._RELEASE_TRACK)

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Validate directory service for a Cloud Netapp storage pool."""
from googlecloudsdk.api_lib.netapp.storage_pools import client as storagepools_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.storage_pools import flags as storagepools_flags
def _CommonArgs(parser):
storagepools_flags.AddStoragePoolValidateDirectoryServiceArg(parser)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ValidateDirectoryService(base.Command):
"""Validate directory service for a Cloud Netapp storage pool."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Validate the directory service for a Cloud Netapp storage pool.
""",
'EXAMPLES': """\
The following command validates the directory service of type ACTIVE_DIRECTORY for a storage pool named NAME:
$ {command} NAME --location=us-central1 --directory-service-type=ACTIVE_DIRECTORY
""",
}
@staticmethod
def Args(parser):
_CommonArgs(parser)
def Run(self, args):
"""Validate directory service for a Cloud Netapp storage pool."""
storagepool_ref = args.CONCEPTS.storage_pool.Parse()
client = storagepools_client.StoragePoolsClient(self._RELEASE_TRACK)
directory_service_type_enum = (
storagepools_flags.GetDirectoryServiceTypeEnumFromArg(
args.directory_service_type, client.messages
)
)
result = client.ValidateDirectoryService(
storagepool_ref,
directory_service_type_enum,
args.async_,
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ValidateDirectoryServiceBeta(ValidateDirectoryService):
"""Validate directory service for a Cloud Netapp storage pool."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Volumes."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Volumes(base.Group):
"""Create and manage Cloud NetApp Volumes."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class VolumesBeta(Volumes):
"""Create and manage Cloud NetApp Volumes."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class VolumesAlpha(VolumesBeta):
"""Create and manage Cloud NetApp Volumes."""

View File

@@ -0,0 +1,177 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a Cloud NetApp Volume."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.volumes import flags as volumes_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
def _CommonArgs(parser, release_track):
volumes_flags.AddVolumeCreateArgs(parser, release_track=release_track)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Volume
""",
'EXAMPLES': """\
The following command creates a NFS Volume named NAME asynchronously using the specified arguments
$ {command} NAME --capacity=1024 --protocols=nfsv3,nfsv4 --share-name=share1 --storage-pool=sp1 --description="test description" --enable-kerberos=true --unix-permissions=0755 --async
The following command creates a SMB Volume named NAME asynchronously using the specified arguments
$ {command} NAME --capacity=1024 --protocols=smb --share-name=share2 --storage-pool=sp2 --description="test smb" --security-style=ntfs --smb-settings=SHOW_SNAPSHOT,SHOW_PREVIOUS_VERSIONS,ACCESS_BASED_ENUMERATION --snap-reserve=0.1 --async
""",
}
@staticmethod
def Args(parser):
_CommonArgs(parser, Create._RELEASE_TRACK)
def Run(self, args):
"""Create a Cloud NetApp Volume in the current project."""
volume_ref = args.CONCEPTS.volume.Parse()
client = volumes_client.VolumesClient(self._RELEASE_TRACK)
## Fill in protocol types into list
protocols = []
for protocol in args.protocols:
protocol_enum = volumes_flags.GetVolumeProtocolEnumFromArg(
protocol, client.messages)
protocols.append(protocol_enum)
capacity_in_gib = args.capacity >> 30
smb_settings = []
if args.smb_settings:
for smb_setting in args.smb_settings:
smb_setting_enum = (
volumes_flags.GetVolumeSmbSettingsEnumFromArg(
smb_setting, client.messages))
smb_settings.append(smb_setting_enum)
snapshot_policy = {}
for name, snapshot_schedule in {
'hourly_snapshot': args.snapshot_hourly,
'daily_snapshot': args.snapshot_daily,
'weekly_snapshot': args.snapshot_weekly,
'monthly_snapshot': args.snapshot_monthly
}.items():
if snapshot_schedule: # snapshot schedule is set
snapshot_policy[name] = snapshot_schedule
if not snapshot_policy:
# if no snapshot_schedule was set in args, change to None type for
# ParseVolumeConfig to easily parse
snapshot_policy = None
security_style = volumes_flags.GetVolumeSecurityStyleEnumFromArg(
args.security_style, client.messages
)
restricted_actions = []
if args.restricted_actions:
for restricted_action in args.restricted_actions:
restricted_action_enum = (
volumes_flags.GetVolumeRestrictedActionsEnumFromArg(
restricted_action, client.messages
)
)
restricted_actions.append(restricted_action_enum)
labels = labels_util.ParseCreateArgs(
args, client.messages.Volume.LabelsValue
)
large_capacity = args.large_capacity
throughput_mibps = args.throughput_mibps
multiple_endpoints = args.multiple_endpoints
cache_parameters = args.cache_parameters
cache_pre_populate = args.cache_pre_populate
block_devices = args.block_devices
if (self._RELEASE_TRACK == base.ReleaseTrack.BETA or
self._RELEASE_TRACK == base.ReleaseTrack.GA):
backup_config = args.backup_config
source_backup = args.source_backup
else:
backup_config = None
source_backup = None
volume = client.ParseVolumeConfig(
name=volume_ref.RelativeName(),
capacity=capacity_in_gib,
description=args.description,
labels=labels,
storage_pool=args.storage_pool,
protocols=protocols,
share_name=args.share_name,
export_policy=args.export_policy,
unix_permissions=args.unix_permissions,
smb_settings=smb_settings,
snapshot_policy=snapshot_policy,
snap_reserve=args.snap_reserve,
snapshot_directory=args.snapshot_directory,
security_style=security_style,
enable_kerberos=args.enable_kerberos,
snapshot=args.source_snapshot,
backup=source_backup,
restricted_actions=restricted_actions,
backup_config=backup_config,
large_capacity=large_capacity,
multiple_endpoints=multiple_endpoints,
tiering_policy=args.tiering_policy,
hybrid_replication_parameters=args.hybrid_replication_parameters,
throughput_mibps=throughput_mibps,
cache_parameters=cache_parameters,
cache_pre_populate=cache_pre_populate,
block_devices=block_devices,
)
result = client.CreateVolume(volume_ref, args.async_, volume)
if args.async_:
command = 'gcloud {} netapp volumes list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the new volume by listing all volumes:\n '
'$ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@staticmethod
def Args(parser):
_CommonArgs(parser, CreateBeta._RELEASE_TRACK)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Create a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
@staticmethod
def Args(parser):
_CommonArgs(parser, CreateAlpha._RELEASE_TRACK)

View File

@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Volume."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.volumes import flags as volumes_flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Delete a Cloud NetApp Volume
""",
'EXAMPLES': """\
The following command deletes a Volume named NAME in the given location
$ {command} NAME --location=us-central1
To delete a Volume named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --async
""",
}
@staticmethod
def Args(parser):
volumes_flags.AddVolumeDeleteArgs(parser)
def Run(self, args):
"""Deletes a Cloud NetApp Volume."""
volume_ref = args.CONCEPTS.volume.Parse()
if not args.quiet:
delete_warning = ('You are about to delete a Volume [{}].\n'
'Are you sure?'.format(volume_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = volumes_client.VolumesClient(release_track=self._RELEASE_TRACK)
result = client.DeleteVolume(volume_ref, args.async_, args.force)
if args.async_:
command = 'gcloud {} netapp volumes list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the deletion by listing all volumes:\n '
'$ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(DeleteBeta):
"""Delete a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describes a Cloud NetApp Volume."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Show metadata for a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Volume
""",
'EXAMPLES': """\
The following command describe a Volume named NAME in the given location
$ {command} NAME --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetVolumePresentationSpec(
'The Volume to describe.')]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
volume_ref = args.CONCEPTS.volume.Parse()
client = volumes_client.VolumesClient(release_track=self._RELEASE_TRACK)
return client.GetVolume(volume_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Show metadata for a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Show metadata for a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Establish peering for Cache Volumes."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.Hidden # TODO(b/423515496): Remove hidden flag once the feature is ready.
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class EstablishPeering(base.Command):
"""Establish peering for Cache Volumes."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
detailed_help = {
'DESCRIPTION': """\
Establish peering for Cache Volumes.
""",
'EXAMPLES': """\
The following command establishes peering for Cache Volume named NAME using the arguments specified:
$ {command} NAME --location=us-central1 --peer-cluster-name=peer-cluster-name1 --peer-svm-name=peer-svm-name1 --peer-volume-name=peer-volume-name1 --peer-ip-addresses=1.1.1.1,2.2.2.2
""",
}
@staticmethod
def Args(parser):
"""Add args for establishing peering for Cache Volume."""
concept_parsers.ConceptParser([
flags.GetVolumePresentationSpec(
'The Cache Volume to establish peering for.'
)
]).AddToParser(parser)
flags.AddResourcePeerClusterNameArg(parser)
flags.AddResourcePeerSvmNameArg(parser)
flags.AddResourcePeerVolumeNameArg(parser)
flags.AddResourcePeerIpAddressesArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Run the establish peering command."""
volume_ref = args.CONCEPTS.volume.Parse()
client = volumes_client.VolumesClient(
release_track=self._RELEASE_TRACK
)
establish_volume_peering_request_config = (
client.ParseEstablishVolumePeeringRequestConfig(
args.peer_cluster_name,
args.peer_svm_name,
args.peer_volume_name,
args.peer_ip_addresses,
)
)
volume = client.EstablishPeering(
volume_ref,
establish_volume_peering_request_config,
args.async_,
)
return volume
@base.Hidden # TODO(b/423515496): Remove hidden flag once the feature is ready.
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class EstablishPeeringBeta(EstablishPeering):
"""Establish peering for Cache Volumes."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
# @base.Hidden # TODO(b/423515496): Uncomment this and make EstablishPeering
# point to GA release track for GA launch.
# @base.ReleaseTracks(base.ReleaseTrack.ALPHA)
# class EstablishPeeringAlpha(EstablishPeeringBeta):
# """Establish peering for Cache Volumes."""
# _RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Lists Cloud NetApp Volumes."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes import flags as volumes_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volumes."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Volumes
""",
'EXAMPLES': """\
The following command lists all Volumes in the given location
$ {command} --location=us-central1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Volumes.')
]).AddToParser(parser)
parser.display_info.AddFormat(volumes_flags.VOLUMES_LIST_FORMAT)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.location.Parse().RelativeName()
# Default to listing all Cloud NetApp Volumes in all locations.
location = args.location if args.location else '-'
location_list = location_ref.split('/')
location_list[-1] = location
location_ref = '/'.join(location_list)
client = volumes_client.VolumesClient(release_track=self._RELEASE_TRACK)
# TODO(b/294604013): Re-assess whether to keep or remove args.limit to be
# passed into List
return list(client.ListVolumes(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volumes."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Volumes
""",
'EXAMPLES': """\
The following command lists all Volumes in the given location
$ {command} --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Volumes."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Volume QuotaRules."""
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class QuotaRules(base.Group):
"""Create and manage Cloud NetApp Volume QuotaRules."""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class QuotaRulesBeta(QuotaRules):
"""Create and manage Cloud NetApp Volume QuotaRules."""

View File

@@ -0,0 +1,106 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a Cloud NetApp Volume Quota Rule."""
from googlecloudsdk.api_lib.netapp.volumes.quota_rules import client as quota_rules_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.volumes.quota_rules import flags as quota_rules_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Volume Quota Rule."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Volume Quota Rule.
""",
'EXAMPLES': """\
The following command creates a default `user` Quota Rule named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1 --type=DEFAULT_USER_QUOTA --disk-limit-mib=200
The following command creates a default `group` Quota Rule named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1 --type=DEFAULT_GROUP_QUOTA --disk-limit-mib=200
The following command creates an individual user Quota Rule named NAME for user with UID '100' using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1 --type=INDIVIDUAL_USER_QUOTA --target=100 --disk-limit-mib=200
The following command creates an individual group Quota Rule named NAME for group with GID '1001' using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1 --type=INDIVIDUAL_GROUP_QUOTA --target=1001 --disk-limit-mib=200
""",
}
@staticmethod
def Args(parser):
quota_rules_flags.AddQuotaRuleCreateArgs(parser)
def Run(self, args):
"""Create a Cloud NetApp Volume Quota Rule in the current project."""
quota_rule_ref = args.CONCEPTS.quota_rule.Parse()
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = quota_rules_client.QuotaRulesClient(self._RELEASE_TRACK)
quota_rule_type = quota_rules_flags.GetQuotaRuleTypeEnumFromArg(
args.type, client.messages
)
labels = labels_util.ParseCreateArgs(
args, client.messages.QuotaRule.LabelsValue
)
quota_rule = client.ParseQuotaRuleConfig(
name=quota_rule_ref.RelativeName(),
quota_rule_type=quota_rule_type,
target=args.target,
disk_limit_mib=args.disk_limit_mib,
description=args.description,
labels=labels,
)
result = client.CreateQuotaRule(
quota_rule_ref, volume_ref, args.async_, quota_rule
)
if args.async_:
command = 'gcloud {} netapp volumes quota-rules list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new quota rule by listing all quota rules:\n'
'$ {} '.format(command)
)
return result
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Volume Quota Rule."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Volume Quota Rule."""
from googlecloudsdk.api_lib.netapp.volumes.quota_rules import client as quota_rules_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.quota_rules import flags as quota_rules_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volume QuotaRule."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Delete a Cloud NetApp Volume QuotaRule.
""",
'EXAMPLES': """\
The following command deletes a QuotaRule named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To delete a QuotaRule named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
"""Add args for deleting a Quota Rule."""
concept_parsers.ConceptParser([
flags.GetQuotaRulePresentationSpec('The Quota Rule to delete.')
]).AddToParser(parser)
quota_rules_flags.AddQuotaRuleVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Delete a Cloud NetApp Volume QuotaRule in the current project."""
quota_rule_ref = args.CONCEPTS.quota_rule.Parse()
if not args.quiet:
delete_warning = (
'You are about to delete a QuotaRule {}.\nAre you sure?'.format(
quota_rule_ref.RelativeName()
)
)
if not console_io.PromptContinue(message=delete_warning):
return None
client = quota_rules_client.QuotaRulesClient(self._RELEASE_TRACK)
result = client.DeleteQuotaRule(quota_rule_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes quota-rules list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the deletion by listing all quota rules:\n '
'$ {} '.format(command)
)
return result
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volume Quota Rule."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describe a Cloud NetApp Volume Quota Rule."""
from googlecloudsdk.api_lib.netapp.volumes.quota_rules import client as quota_rules_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.quota_rules import flags as quota_rules_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Volume Quota Rule."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Volume Quota Rule.
""",
'EXAMPLES': """\
The following command describes a Quota Rule named NAME in the given location and volume:
$ {command} NAME --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetQuotaRulePresentationSpec('The Quota Rule to describe.')]
).AddToParser(parser)
quota_rules_flags.AddQuotaRuleVolumeArg(parser, required=True)
def Run(self, args):
"""Get a Cloud NetApp Volume Quota Rule in the current project."""
quota_rule_ref = args.CONCEPTS.quota_rule.Parse()
client = quota_rules_client.QuotaRulesClient(
release_track=self._RELEASE_TRACK
)
return client.GetQuotaRule(quota_rule_ref)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Volume Quota Rule."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""List Cloud NetApp Volume Quota Rules."""
from googlecloudsdk.api_lib.netapp.volumes.quota_rules import client as quota_rules_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.quota_rules import flags as quota_rules_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volume QuotaRules."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Volume QuotaRules.
""",
'EXAMPLES': """\
The following command lists all QuotaRules in the given location and volume:
$ {command} --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Volume QuotaRules.')
]).AddToParser(parser)
quota_rules_flags.AddQuotaRuleVolumeArg(parser, required=True)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = quota_rules_client.QuotaRulesClient(
release_track=self._RELEASE_TRACK
)
return list(client.ListQuotaRules(volume_ref, limit=args.limit))
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volume QuotaRules."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,107 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Volume QuotaRule."""
from googlecloudsdk.api_lib.netapp.volumes.quota_rules import client as quota_rules_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.volumes.quota_rules import flags as quota_rules_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volume QuotaRule."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Update a Cloud NetApp Volume QuotaRule and its specified parameters.
""",
'EXAMPLES': """\
The following command updates a QuotaRule named NAME and its specified parameters:
$ {command} NAME --location=us-central1 --description="new" --disk-limit-mib=100 --update-labels=key2=val2 --volume=vol1
""",
}
@staticmethod
def Args(parser):
quota_rules_flags.AddQuotaRuleUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Volume QuotaRule in the current project."""
quota_rule_ref = args.CONCEPTS.quota_rule.Parse()
client = quota_rules_client.QuotaRulesClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
original_quota_rule = client.GetQuotaRule(quota_rule_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.QuotaRule.LabelsValue, original_quota_rule.labels
).GetOrNone()
else:
labels = None
quota_rule = client.ParseUpdatedQuotaRuleConfig(
original_quota_rule,
disk_limit_mib=args.disk_limit_mib,
description=args.description,
labels=labels,
)
updated_fields = []
# add possible updated quota rule fields
# TODO(b/243601146) add config mapping and separate config file for update
if args.IsSpecified('description'):
updated_fields.append('description')
# Need a check for labels is not None. GetOrNone returns None if there are
# no updates to labels. If that's the case, make sure not to include the
# labels field in the field mask of the update command. Otherwise, it's
# possible to inadvertently clear the labels on the resource.
if (labels is not None) and (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
if args.IsSpecified('disk_limit_mib'):
updated_fields.append('diskLimitMib')
update_mask = ','.join(updated_fields)
result = client.UpdateQuotaRule(
quota_rule_ref, quota_rule, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp volumes quota-rules list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated quota rule by listing all quota'
' rules:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volume Quota Rule."""
_RELEASE_TRACK = base.ReleaseTrack.BETA

View File

@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Volume Replications."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Replications(base.Group):
"""Create and manage Cloud NetApp Volume Replications."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ReplicationsBeta(Replications):
"""Create and manage Cloud NetApp Volume Replications."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ReplicationsAlpha(ReplicationsBeta):
"""Create and manage Cloud NetApp Volume Replications."""

View File

@@ -0,0 +1,128 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp import util as netapp_api_util
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command creates a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1 --replication-schedule=EVERY_10_MINUTES --destination-volume-parameters=storage_pool=sp1,volume_id=vol2,share_name=share2
""",
}
@staticmethod
def Args(parser):
return Create._ReplicationArgs(parser, Create._RELEASE_TRACK)
@staticmethod
def _ReplicationArgs(parser, release_track):
"""Add args for creating a Replication."""
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to create.')]
).AddToParser(parser)
messages = netapp_api_util.GetMessagesModule(
release_track=release_track
)
replications_flags.AddReplicationVolumeArg(parser)
replications_flags.AddReplicationReplicationScheduleArg(parser)
replications_flags.AddReplicationDestinationVolumeParametersArg(
parser, messages
)
replications_flags.AddReplicationClusterLocationArg(parser)
flags.AddResourceAsyncFlag(parser)
flags.AddResourceDescriptionArg(parser, 'Replication')
labels_util.AddCreateLabelsFlags(parser)
def Run(self, args):
"""Create a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.Replication.LabelsValue
)
replication_schedule_enum = (
replications_flags.GetReplicationReplicationScheduleEnumFromArg(
args.replication_schedule, client.messages
)
)
replication = client.ParseReplicationConfig(
name=replication_ref.RelativeName(),
description=args.description,
labels=labels,
replication_schedule=replication_schedule_enum,
destination_volume_parameters=args.destination_volume_parameters,
cluster_location=args.cluster_location,
)
result = client.CreateReplication(
replication_ref, volume_ref, args.async_, replication
)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@staticmethod
def Args(parser):
return CreateBeta._ReplicationArgs(parser, CreateBeta._RELEASE_TRACK)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Create a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
@staticmethod
def Args(parser):
return CreateAlpha._ReplicationArgs(parser, CreateAlpha._RELEASE_TRACK)

View File

@@ -0,0 +1,99 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Delete a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command deletes a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To delete a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
"""Add args for deleting a Replication."""
concept_parsers.ConceptParser([
flags.GetReplicationPresentationSpec('The Replication to delete.')
]).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Delete a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
if not args.quiet:
delete_warning = (
'You are about to delete a Replication {}.\nAre you sure?'.format(
replication_ref.RelativeName()
)
)
if not console_io.PromptContinue(message=delete_warning):
return None
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.DeleteReplication(replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the deletion by listing all replications:\n '
'$ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(DeleteBeta):
"""Delete a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describe a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command describes a Replication named NAME in the given location and volume:
$ {command} NAME --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to describe.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
def Run(self, args):
"""Get a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
return client.GetReplication(replication_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Volume Replication
""",
'EXAMPLES': """\
The following command describes a Replication named NAME in the given location and volume
$ {command} NAME --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to describe.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
def Run(self, args):
"""Get a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
return client.GetReplication(replication_ref)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Describe a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,97 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Establish peering for Hybrid replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class EstablishPeering(base.Command):
"""Establish peering for Hybrid replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Establish peering for Hybrid replication.
""",
'EXAMPLES': """\
The following command establishes peering for Hybrid replication named NAME using the arguments specified:
$ {command} NAME --volume=volume1 --peer-cluster-name=peer-cluster-name1 --peer-svm-name=peer-svm-name1 --peer-volume-name=peer-volume-name1 --peer-ip-addresses=1.1.1.1,2.2.2.2
""",
}
@staticmethod
def Args(parser):
"""Add args for establishing peering for Hybrid replication."""
concept_parsers.ConceptParser([
flags.GetReplicationPresentationSpec(
'The Hybrid replication to establish peering for.'
)
]).AddToParser(parser)
flags.AddResourcePeerClusterNameArg(parser)
flags.AddResourcePeerSvmNameArg(parser)
flags.AddResourcePeerVolumeNameArg(parser)
flags.AddResourcePeerIpAddressesArg(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Run the establish peering command."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
establish_peering_request_config = (
client.ParseEstablishPeeringRequestConfig(
args.peer_cluster_name,
args.peer_svm_name,
args.peer_volume_name,
args.peer_ip_addresses,
)
)
replication = client.EstablishPeering(
replication_ref,
establish_peering_request_config,
args.async_,
)
return replication
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class EstablishPeeringBeta(EstablishPeering):
"""Establish peering for Hybrid replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class EstablishPeeringAlpha(EstablishPeeringBeta):
"""Establish peering for Hybrid replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""List Cloud NetApp Volume Replications."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volume Replications."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Volume Replications.
""",
'EXAMPLES': """\
The following command lists all Replications in the given location and volume:
$ {command} --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Volume Replications.'
)
]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
if args.CONCEPTS.volume.Parse() is None:
raise exceptions.RequiredArgumentException(
'--volume', 'Requires a volume to list replications of'
)
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
return list(client.ListReplications(volume_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volume Replications."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Volume Replications."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Resume a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Resume(base.Command):
"""Resume a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Resume a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command resumes a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To resume a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to create.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Resume a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.ResumeReplication(
replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the resumed replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ResumeBeta(Resume):
"""Resume a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ResumeAlpha(ResumeBeta):
"""Resume a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Reverse a Cloud NetApp Volume Replication's direction."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Reverse(base.Command):
"""Reverse a Cloud NetApp Volume Replication's direction."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Reverse a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command reverses a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To reverse a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetReplicationPresentationSpec(
'The Replication to reverse direction.'
)
]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser, reverse_op=True)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Reverse a Cloud NetApp Volume Replication's direction in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.ReverseReplication(
replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the reversed replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ReverseBeta(Reverse):
"""Reverse a Cloud NetApp Volume Replication's direction."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ReverseAlpha(ReverseBeta):
"""Reverse a Cloud NetApp Volume Replication's direction."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Stop a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Stop(base.Command):
"""Stop a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Stop a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command stops a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To stop a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to create.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
replications_flags.AddReplicationForceArg(parser)
def Run(self, args):
"""Stop a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.StopReplication(
replication_ref, args.async_, args.force)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the stopped replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class StopBeta(Stop):
"""Stop a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class StopAlpha(StopBeta):
"""Stop a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Sync a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Sync(base.Command):
"""Sync a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Sync a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command syncs a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To sync a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
"""Add args for syncing a Replication."""
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to sync.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Sync a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.SyncReplication(replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the sync replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class SyncBeta(Sync):
"""Sync a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class SyncAlpha(SyncBeta):
"""Sync a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,135 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Update a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Update a Cloud NetApp Volume Replication and its specified parameters.
""",
'EXAMPLES': """\
The following command updates a Replication named NAME and its specified parameters:
$ {command} NAME --location=us-central1 --volume=vol1 --replication-schedule=EVERY_5_MINUTES --description="new description" --cluster-location= us-central1
""",
}
@staticmethod
def Args(parser):
"""Add args for updating a Replication."""
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to update.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
replications_flags.AddReplicationReplicationScheduleArg(
parser, required=False
)
replications_flags.AddReplicationClusterLocationArg(parser)
flags.AddResourceAsyncFlag(parser)
flags.AddResourceDescriptionArg(parser, 'Replication')
labels_util.AddUpdateLabelsFlags(parser)
def Run(self, args):
"""Update a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
original_replication = client.GetReplication(replication_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.Replication.LabelsValue, original_replication.labels
).GetOrNone()
else:
labels = None
replication_schedule_enum = (
replications_flags.GetReplicationReplicationScheduleEnumFromArg(
args.replication_schedule, client.messages
)
)
replication = client.ParseUpdatedReplicationConfig(
original_replication, description=args.description, labels=labels,
replication_schedule=replication_schedule_enum,
cluster_location=args.cluster_location,
)
updated_fields = []
# Add possible updated replication fields.
# TODO(b/243601146) add config mapping and separate config file for update
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
if args.IsSpecified('replication_schedule'):
updated_fields.append('replication_schedule')
if args.IsSpecified('cluster_location'):
updated_fields.append('cluster_location')
update_mask = ','.join(updated_fields)
result = client.UpdateReplication(
replication_ref, replication, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(UpdateBeta):
"""Update a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,97 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Restores selected files from a backup to a specified Volume."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes import flags as volumes_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class RestoreBackupFiles(base.Command):
"""Restore specific files from a backup to a Volume."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
detailed_help = {
'DESCRIPTION': """\
Restore specific files from a backup to a Volume
""",
'EXAMPLES': """\
The following command restores file1.txt and file2.txt from the given backup to a Volume named NAME to the directory /path/to/destination/directory.
$ {command} NAME --location=us-central1 --backup=backup-1 --file-list=file1.txt,file2.txt --restore-destination-path=/path/to/destination/directory
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetVolumePresentationSpec('The Volume to restore into.')]
).AddToParser(parser)
volumes_flags.AddVolumeRestoreFromBackupArg(parser)
volumes_flags.AddVolumeRestoreDestinationPathArg(parser)
volumes_flags.AddVolumeRestoreFileListArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Run the restore command."""
volume_ref = args.CONCEPTS.volume.Parse()
client = volumes_client.VolumesClient(release_track=self._RELEASE_TRACK)
revert_warning = (
'You are about to restore files from a backup to Volume {}.\n'
'Are you sure?'.format(volume_ref.RelativeName())
)
if not console_io.PromptContinue(message=revert_warning):
return None
result = client.RestoreVolume(
volume_ref,
args.backup,
args.file_list,
args.restore_destination_path,
args.async_,
)
if args.async_:
command = 'gcloud {} netapp volumes list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the volume being restored by listing all'
' volumes:\n$ {}'.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class RestoreBackupFilesBeta(RestoreBackupFiles):
"""Restore specific files from a backup to a Volume."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.GA)
class RestoreBackupFilesGA(RestoreBackupFiles):
"""Restore specific files from a backup to a Volume."""
_RELEASE_TRACK = base.ReleaseTrack.GA

View File

@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Reverts a Cloud NetApp Volume back to a specified Snapshot."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes import flags as volumes_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Revert(base.Command):
"""Revert a Cloud NetApp Volume back to a specified Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Revert a Cloud NetApp Volume back to a specified source Snapshot
""",
'EXAMPLES': """\
The following command reverts a Volume named NAME in the given location and snapshot
$ {command} NAME --location=us-central1 --snapshot="snapshot1"
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetVolumePresentationSpec(
'The Volume to revert.')]).AddToParser(parser)
volumes_flags.AddVolumeRevertSnapshotArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Run the revert command."""
volume_ref = args.CONCEPTS.volume.Parse()
client = volumes_client.VolumesClient(release_track=self._RELEASE_TRACK)
revert_warning = (
'You are about to revert Volume {} back to Snapshot {}.\n'
'Are you sure?'.format(volume_ref.RelativeName(), args.snapshot)
)
if not console_io.PromptContinue(message=revert_warning):
return None
result = client.RevertVolume(volume_ref, args.snapshot, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the volume being reverted by listing all'
' volumes:\n$ {}'.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class RevertBeta(Revert):
"""Revert a Cloud NetApp Volume back to a specified Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class RevertAlpha(RevertBeta):
"""Revert a Cloud NetApp Volume back to a specified Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command group for Cloud NetApp Volume Snapshots."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Snapshots(base.Group):
"""Create and manage Cloud NetApp Volume Snapshots."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class SnapshotsBeta(Snapshots):
"""Create and manage Cloud NetApp Volume Snapshots."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class SnapshotsAlpha(SnapshotsBeta):
"""Create and manage Cloud NetApp Volume Snapshots."""

View File

@@ -0,0 +1,97 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a Cloud NetApp Volume Snapshot."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.snapshots import client as snapshots_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp.volumes.snapshots import flags as snapshots_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Volume Snapshot.
""",
'EXAMPLES': """\
The following command creates a Snapshot named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
snapshots_flags.AddSnapshotCreateArgs(parser)
def Run(self, args):
"""Create a Cloud NetApp Volume Snapshot in the current project."""
snapshot_ref = args.CONCEPTS.snapshot.Parse()
if args.CONCEPTS.volume.Parse() is None:
raise exceptions.RequiredArgumentException(
'--volume', 'Requires a volume to create snapshot of'
)
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = snapshots_client.SnapshotsClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.Snapshot.LabelsValue
)
snapshot = client.ParseSnapshotConfig(
name=snapshot_ref.RelativeName(),
description=args.description,
labels=labels,
)
result = client.CreateSnapshot(
snapshot_ref, volume_ref, args.async_, snapshot
)
if args.async_:
command = 'gcloud {} netapp volumes snapshots list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new snapshot by listing all snapshots:\n '
'$ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Creates a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Delete a Cloud NetApp Volume Snapshot."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.snapshots import client as snapshots_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp.volumes.snapshots import flags as snapshots_flags
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Delete a Cloud NetApp Volume Snapshot.
""",
'EXAMPLES': """\
The following command deletes a Snapshot named NAME in the given location and volume:
$ {command} NAME --location=us-central1 --volume=vol1
To delete a Snapshot named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
snapshots_flags.AddSnapshotDeleteArgs(parser)
def Run(self, args):
"""Delete a Cloud NetApp Volume Snapshot in the current project."""
snapshot_ref = args.CONCEPTS.snapshot.Parse()
if args.CONCEPTS.volume.Parse() is None:
raise exceptions.RequiredArgumentException(
'--volume', 'Requires a volume to delete snapshot of')
if not args.quiet:
delete_warning = ('You are about to delete a Snapshot {}.\n'
'Are you sure?'.format(snapshot_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = snapshots_client.SnapshotsClient(self._RELEASE_TRACK)
result = client.DeleteSnapshot(snapshot_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes snapshots list'.format(
self.ReleaseTrack().prefix)
log.status.Print(
'Check the status of the deletion by listing all snapshots:\n '
'$ {} '.format(command))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(DeleteBeta):
"""Delete a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Describe a Cloud NetApp Volume Snapshot."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.snapshots import client as snapshots_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.snapshots import flags as snapshots_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Volume Snapshot.
""",
'EXAMPLES': """\
The following command describes a Snapshot named NAME in the given location and volume:
$ {command} NAME --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetSnapshotPresentationSpec(
'The Snapshot to describe.')]).AddToParser(parser)
snapshots_flags.AddSnapshotVolumeArg(parser)
def Run(self, args):
"""Get a Cloud NetApp Volume Snapshot in the current project."""
snapshot_ref = args.CONCEPTS.snapshot.Parse()
if args.CONCEPTS.volume.Parse() is None:
raise exceptions.RequiredArgumentException(
'--volume', 'Requires a volume to describe snapshot of')
client = snapshots_client.SnapshotsClient(release_track=self._RELEASE_TRACK)
return client.GetSnapshot(snapshot_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Describe a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""List Cloud NetApp Volume Snapshots."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.snapshots import client as snapshots_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.snapshots import flags as snapshots_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volume Snapshots."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Volume Snapshots.
""",
'EXAMPLES': """\
The following command lists all Snapshots in the given location and volume:
$ {command} --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Volume Snapshots.')
]).AddToParser(parser)
snapshots_flags.AddSnapshotVolumeArg(parser)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
if args.CONCEPTS.volume.Parse() is None:
raise exceptions.RequiredArgumentException(
'--volume', 'Requires a volume to list snapshots of')
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = snapshots_client.SnapshotsClient(release_track=self._RELEASE_TRACK)
return list(client.ListSnapshots(volume_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volume Snapshots."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Volume Snapshots."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,113 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Update a Cloud NetApp Volume Snapshot."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.snapshots import client as snapshots_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp.volumes.snapshots import flags as snapshots_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Update a Cloud NetApp Volume Snapshot and its specified parameters.
""",
'EXAMPLES': """\
The following command updates a Snapshot named NAME and its specified parameters:
$ {command} NAME --location=us-central1 --description="new" --update-labels=key2=val2 --volume=vol1
""",
}
@staticmethod
def Args(parser):
snapshots_flags.AddSnapshotUpdateArgs(parser)
def Run(self, args):
"""Update a Cloud NetApp Volume Snapshot in the current project."""
snapshot_ref = args.CONCEPTS.snapshot.Parse()
if args.CONCEPTS.volume.Parse() is None:
raise exceptions.RequiredArgumentException(
'--volume', 'Requires a volume to update snapshot of')
client = snapshots_client.SnapshotsClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
original_snapshot = client.GetSnapshot(snapshot_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.Snapshot.LabelsValue, original_snapshot.labels
).GetOrNone()
else:
labels = None
snapshot = client.ParseUpdatedSnapshotConfig(
original_snapshot, description=args.description, labels=labels
)
updated_fields = []
# add possible updated snapshot fields
# TODO(b/243601146) add config mapping and separate config file for update
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
update_mask = ','.join(updated_fields)
result = client.UpdateSnapshot(
snapshot_ref, snapshot, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp volumes snapshots list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated snapshot by listing all snapshots:\n'
' $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(UpdateBeta):
"""Update a Cloud NetApp Volume Snapshot."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,264 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Updates a Cloud NetApp Volume."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes import client as volumes_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp.volumes import flags as volumes_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
def _CommonArgs(parser, release_track):
volumes_flags.AddVolumeUpdateArgs(parser, release_track=release_track)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Update a Cloud NetApp Volume and its specified parameters
""",
'EXAMPLES': """\
The following command updates a Volume named NAME and its specified parameters
$ {command} NAME --location=us-central1 --capacity=4096 --description="new description" --enable-kerberos=false --storage-pool=sp3 --unix-permissions=0777
""",
}
@staticmethod
def Args(parser):
_CommonArgs(parser, Update._RELEASE_TRACK)
def Run(self, args):
"""Update a Cloud NetApp Volume in the current project."""
volume_ref = args.CONCEPTS.volume.Parse()
client = volumes_client.VolumesClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
original_volume = client.GetVolume(volume_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(client.messages.Volume.LabelsValue,
original_volume.labels).GetOrNone()
else:
labels = None
protocols = []
if args.protocols:
for protocol in args.protocols:
protocol_enum = volumes_flags.GetVolumeProtocolEnumFromArg(
protocol, client.messages
)
protocols.append(protocol_enum)
capacity_in_gib = args.capacity >> 30 if args.capacity else None
smb_settings = []
if args.smb_settings:
for smb_setting in args.smb_settings:
smb_setting_enum = volumes_flags.GetVolumeSmbSettingsEnumFromArg(
smb_setting, client.messages
)
smb_settings.append(smb_setting_enum)
restricted_actions = []
if args.restricted_actions:
for restricted_action in args.restricted_actions:
restricted_action_enum = (
volumes_flags.GetVolumeRestrictedActionsEnumFromArg(
restricted_action, client.messages
)
)
restricted_actions.append(restricted_action_enum)
snapshot_policy = {}
for name, snapshot_schedule in (
('hourly_snapshot', args.snapshot_hourly),
('daily_snapshot', args.snapshot_daily),
('weekly_snapshot', args.snapshot_weekly),
('monthly_snapshot', args.snapshot_monthly),
):
if snapshot_schedule: # snapshot schedule is set
snapshot_policy[name] = snapshot_schedule
if not snapshot_policy:
# if no snapshot_schedule was set in args, change to None type for
# ParseVolumeConfig to easily parse
snapshot_policy = None
if args.security_style:
security_style = volumes_flags.GetVolumeSecurityStyleEnumFromArg(
args.security_style, client.messages
)
else:
security_style = None
if self._RELEASE_TRACK in [base.ReleaseTrack.BETA, base.ReleaseTrack.GA]:
backup_config = args.backup_config
source_backup = args.source_backup
else:
backup_config = None
source_backup = None
cache_parameters = args.cache_parameters
cache_pre_populate = args.cache_pre_populate
block_devices = args.block_devices
throughput_mibps = args.throughput_mibps
volume = client.ParseUpdatedVolumeConfig(
original_volume,
description=args.description,
labels=labels,
storage_pool=args.storage_pool,
protocols=protocols,
share_name=args.share_name,
export_policy=args.export_policy,
capacity=capacity_in_gib,
unix_permissions=args.unix_permissions,
smb_settings=smb_settings,
snapshot_policy=snapshot_policy,
snap_reserve=args.snap_reserve,
snapshot_directory=args.snapshot_directory,
security_style=security_style,
enable_kerberos=args.enable_kerberos,
snapshot=args.source_snapshot,
backup=source_backup,
restricted_actions=restricted_actions,
backup_config=backup_config,
tiering_policy=args.tiering_policy,
cache_parameters=cache_parameters,
cache_pre_populate=cache_pre_populate,
throughput_mibps=throughput_mibps,
block_devices=block_devices,
)
updated_fields = []
# add possible updated volume fields
# TODO(b/243601146) add config mapping and separate config file for update
if args.IsSpecified('capacity'):
updated_fields.append('capacityGib')
if args.IsSpecified('storage_pool'):
updated_fields.append('storagePool')
if args.IsSpecified('share_name'):
updated_fields.append('shareName')
if args.IsSpecified('export_policy'):
updated_fields.append('exportPolicy')
if args.IsSpecified('protocols'):
updated_fields.append('protocols')
if args.IsSpecified('unix_permissions'):
updated_fields.append('unixPermissions')
if args.IsSpecified('smb_settings'):
updated_fields.append('smbSettings')
if (args.IsSpecified('snapshot_hourly') or
args.IsSpecified('snapshot_daily') or
args.IsSpecified('snapshot_weekly') or
args.IsSpecified('snapshot_monthly')):
updated_fields.append('snapshotPolicy')
if args.IsSpecified('snap_reserve'):
updated_fields.append('snapReserve')
if args.IsSpecified('snapshot_directory'):
updated_fields.append('snapshotDirectory')
if args.IsSpecified('security_style'):
updated_fields.append('securityStyle')
if args.IsSpecified('enable_kerberos'):
updated_fields.append('kerberosEnabled')
if args.IsSpecified('source_snapshot'):
updated_fields.append('restoreParameters')
if args.IsSpecified('restricted_actions'):
updated_fields.append('restrictedActions')
if args.IsSpecified('throughput_mibps'):
updated_fields.append('throughputMibps')
if (self._RELEASE_TRACK == base.ReleaseTrack.BETA or
self._RELEASE_TRACK == base.ReleaseTrack.GA):
if args.IsSpecified('source_backup'):
updated_fields.append('restoreParameters')
if backup_config is not None:
if backup_config.get('backup-policies') is not None:
updated_fields.append('backupConfig.backupPolicies')
if backup_config.get('backup-vault') is not None:
updated_fields.append('backupConfig.backupVault')
if backup_config.get('enable-scheduled-backups') is not None:
updated_fields.append('backupConfig.scheduledBackupEnabled')
if args.IsSpecified('tiering_policy'):
if args.tiering_policy.get('tier-action') is not None:
updated_fields.append('tieringPolicy.tierAction')
if args.tiering_policy.get('cooling-threshold-days') is not None:
updated_fields.append('tieringPolicy.coolingThresholdDays')
if (
self._RELEASE_TRACK == base.ReleaseTrack.BETA
or self._RELEASE_TRACK == base.ReleaseTrack.ALPHA
) and args.tiering_policy.get('enable-hot-tier-bypass-mode') is not None:
updated_fields.append('tieringPolicy.hotTierBypassModeEnabled')
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
if (
args.IsSpecified('cache_parameters')
and args.cache_parameters.get('cache-config') is not None
):
for config in args.cache_parameters.get('cache-config'):
if 'cifs-change-notify-enabled' in config:
updated_fields.append(
'cacheParameters.cacheConfig.cifsChangeNotifyEnabled'
)
if 'write-back-enabled' in config:
updated_fields.append(
'cacheParameters.cacheConfig.writebackEnabled'
)
if args.IsSpecified('cache_pre_populate'):
updated_fields.append('cacheParameters.cacheConfig.cachePrePopulate')
if args.IsSpecified('block_devices'):
updated_fields.append('blockDevices')
update_mask = ','.join(updated_fields)
result = client.UpdateVolume(volume_ref, volume, update_mask, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated volume by listing all volumes:\n '
'$ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@staticmethod
def Args(parser):
_CommonArgs(parser, UpdateBeta._RELEASE_TRACK)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(UpdateBeta):
"""Update a Cloud NetApp Volume."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
@staticmethod
def Args(parser):
_CommonArgs(parser, UpdateAlpha._RELEASE_TRACK)