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 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 `gcloud container vmware admin-clusters`."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.projects import util
from googlecloudsdk.core import log
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class AdminClusters(base.Group):
"""Create and manage admin clusters in Anthos on VMware."""

View File

@@ -0,0 +1,51 @@
# -*- 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 describe an Anthos on VMware admin cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import vmware_admin_clusters as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.vmware import flags
_EXAMPLES = """
To describe an admin cluster named ``my-cluster'' managed in location ``us-west1'',
run:
$ {command} my-cluster --location=us-west1
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Describe(base.DescribeCommand):
"""Describe an Anthos on VMware admin cluster."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Registers flags for this command."""
flags.AddAdminClusterResourceArg(parser, 'to describe')
def Run(self, args):
"""Runs the describe command."""
cluster_ref = args.CONCEPTS.admin_cluster.Parse()
client = apis.AdminClustersClient()
return client.Describe(cluster_ref)

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 to enroll an admin cluster in an Anthos cluster on VMware."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.api_lib.container.gkeonprem import vmware_admin_clusters as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.gkeonprem import constants
from googlecloudsdk.command_lib.container.gkeonprem import flags
from googlecloudsdk.command_lib.container.vmware import constants as vmware_constants
from googlecloudsdk.command_lib.container.vmware import flags as vmware_flags
_EXAMPLES = """
To enroll a cluster named ``my-cluster'' managed in location ``us-west1''
with admin cluster membership of
``projects/my-project/locations/us-west1/memberships/my-admin-cluster-membership'',
run:
$ {command} my-cluster --location=us-west1 --admin-cluster-membership=projects/my-project/locations/us-west1/memberships/my-admin-cluster-membership
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Enroll(base.Command):
"""Enroll an Anthos on VMware admin cluster."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
parser.display_info.AddFormat(vmware_constants.VMWARE_CLUSTERS_FORMAT)
flags.AddAdminClusterMembershipResourceArg(parser, positional=False)
vmware_flags.AddAdminClusterResourceArg(parser, 'to enroll')
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
cluster_client = apis.AdminClustersClient()
admin_cluster_ref = args.CONCEPTS.admin_cluster.Parse()
operation = cluster_client.Enroll(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
operations.log_enroll(admin_cluster_ref, args.async_)
return operation
else:
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
operations.log_enroll(admin_cluster_ref, args.async_)
return operation_response

View File

@@ -0,0 +1,74 @@
# -*- 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 list all admin clusters in the Anthos clusters on VMware API."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import vmware_admin_clusters as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.vmware import constants
from googlecloudsdk.command_lib.container.vmware import flags
from googlecloudsdk.core import log
_EXAMPLES = """
To list all admin clusters managed in location ``us-west1'', run:
$ {command} --location=us-west1
"""
_EPILOG = """
To include admin clusters that are not enrolled with the Anthos On-Prem API, run:
$ gcloud container fleet memberships list --filter='endpoint.onPremCluster.adminCluster=true'
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class List(base.ListCommand):
"""List Anthos on VMware admin clusters."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers command line arguments for the list command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(constants.VMWARE_ADMIN_CLUSTERS_FORMAT)
flags.AddLocationResourceArg(parser,
'to list Anthos on VMware admin clusters')
def Run(self, args):
"""Runs the list command.
Args:
args: Arguments received from command line.
Returns:
protorpc.message.Message, The resources listed by the service.
"""
client = apis.AdminClustersClient()
return client.List(args)
def Epilog(self, resources_were_displayed):
super(List, self).Epilog(resources_were_displayed)
log.status.Print(_EPILOG)

View File

@@ -0,0 +1,81 @@
# -*- 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 unenroll an Anthos on VMware admin cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.api_lib.container.gkeonprem import vmware_admin_clusters as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.gkeonprem import constants
from googlecloudsdk.command_lib.container.vmware import constants as vmware_constants
from googlecloudsdk.command_lib.container.vmware import flags
_EXAMPLES = """
To unenroll an admin cluster named `my-cluster` managed in location `us-west1`,
run:
$ {command} my-cluster --location=us-west1
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
@base.DefaultUniverseOnly
class Unenroll(base.Command):
"""Unenroll an Anthos on VMware admin cluster."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Registers flags for this command."""
parser.display_info.AddFormat(vmware_constants.VMWARE_CLUSTERS_FORMAT)
flags.AddAdminClusterResourceArg(parser, 'to unenroll')
base.ASYNC_FLAG.AddToParser(parser)
flags.AddValidationOnly(parser)
flags.AddAllowMissingUnenrollCluster(parser)
flags.AddIgnoreErrorsAdminCluster(parser)
def Run(self, args):
"""Runs the unenroll command."""
cluster_client = apis.AdminClustersClient()
admin_cluster_ref = args.CONCEPTS.admin_cluster.Parse()
operation = cluster_client.Unenroll(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.validate_only:
return None
# when using --allow-missing without --async on a non-existing resource,
# it would return an operation object with an empty name.
# return early to avoid potential polling error.
if operation.name is None:
return None
if args.async_:
operations.log_unenroll(admin_cluster_ref, args.async_)
return operation
else:
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
operations.log_unenroll(admin_cluster_ref, args.async_)
return operation_response

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.
"""Command to update an Anthos cluster on VMware."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.api_lib.container.gkeonprem import vmware_admin_clusters as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.gkeonprem import constants
from googlecloudsdk.command_lib.container.vmware import constants as vmware_constants
from googlecloudsdk.command_lib.container.vmware import flags
from googlecloudsdk.core import log
_EXAMPLES = """
To update a cluster named ``my-cluster'' managed in location ``us-west1'', run:
$ {command} my-cluster --location=us-west1
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
@base.DefaultUniverseOnly
class Update(base.UpdateCommand):
"""Update an Anthos on VMware admin cluster."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers command line arguments for the update command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(vmware_constants.VMWARE_ADMIN_CLUSTERS_FORMAT)
flags.AddAdminClusterResourceArg(parser, 'to update', True)
flags.AddRequiredPlatformVersion(parser)
flags.AddVersion(parser)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
"""Runs the update command.
Args:
args: The arguments received from command line.
Returns:
The return value depends on the command arguments. If `--async` is
specified, it returns an operation; otherwise, it returns the updated
resource.
"""
cluster_ref = args.CONCEPTS.admin_cluster.Parse()
cluster_client = apis.AdminClustersClient()
operation = cluster_client.Update(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
log.UpdatedResource(cluster_ref,
'Anthos on VMware Admin Cluster',
args.async_)
return operation
else:
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
log.UpdatedResource(cluster_ref,
'Anthos on VMware Admin Cluster',
args.async_)
return operation_response