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