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,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