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,29 @@
# -*- 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 bare-metal node-pools`."""
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
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class NodePools(base.Group):
"""Create and manage node pools in an Anthos cluster on bare metal."""

View File

@@ -0,0 +1,209 @@
# -*- 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 create a node pool in an Anthos cluster on bare metal."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from typing import Optional
from googlecloudsdk.api_lib.container.gkeonprem import bare_metal_node_pools as apis
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.calliope import parser_extensions
from googlecloudsdk.command_lib.container.bare_metal import cluster_flags
from googlecloudsdk.command_lib.container.bare_metal import constants as bare_metal_constants
from googlecloudsdk.command_lib.container.bare_metal import node_pool_flags
from googlecloudsdk.command_lib.container.gkeonprem import constants
from googlecloudsdk.core import log
from googlecloudsdk.generated_clients.apis.gkeonprem.v1 import gkeonprem_v1_messages as messages
_EXAMPLES = """
To create a node pool named ``my-node-pool'' in a cluster named
``my-cluster'' managed in location ``us-west1'', run:
$ {command} my-node-pool --cluster=my-cluster --location=us-west1
"""
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers command line arguments for the create command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT
)
node_pool_flags.AddNodePoolResourceArg(parser, 'to create')
cluster_flags.AddValidationOnly(parser)
base.ASYNC_FLAG.AddToParser(parser)
node_pool_flags.AddNodePoolAnnotations(parser)
node_pool_flags.AddNodePoolDisplayName(parser)
node_pool_flags.AddNodePoolConfig(parser)
def Run(self, args):
"""Runs the create 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 created
resource. If `--validate-only` is specified, it returns None or any
possible error.
"""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Create(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
return operation
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
if not args.validate_only:
log.CreatedResource(
node_pool_ref,
'node pool in Anthos cluster on bare metal',
args.async_,
)
return operation_response
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(base.CreateCommand):
"""Create a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers command line arguments for the create command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT)
node_pool_flags.AddNodePoolResourceArg(parser, 'to create')
cluster_flags.AddValidationOnly(parser)
base.ASYNC_FLAG.AddToParser(parser)
node_pool_flags.AddNodePoolAnnotations(parser)
node_pool_flags.AddNodePoolDisplayName(parser)
node_pool_flags.AddNodePoolConfig(parser)
def Run(self, args):
"""Runs the create 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 created
resource. If `--validate-only` is specified, it returns None or any
possible error.
"""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Create(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
return operation
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
if not args.validate_only:
log.CreatedResource(node_pool_ref,
'node pool in Anthos cluster on bare metal',
args.async_)
return operation_response
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(base.CreateCommand):
"""Create a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers command line arguments for the create command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT)
node_pool_flags.AddNodePoolResourceArg(parser, 'to create')
cluster_flags.AddValidationOnly(parser)
base.ASYNC_FLAG.AddToParser(parser)
node_pool_flags.AddNodePoolAnnotations(parser)
node_pool_flags.AddNodePoolDisplayName(parser)
node_pool_flags.AddNodePoolConfig(parser)
node_pool_flags.AddNodePoolVersion(parser)
def Run(
self, args: parser_extensions.Namespace
) -> Optional[messages.Operation]:
"""Runs the create 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 created
resource. If `--validate-only` is specified, it returns None or any
possible error.
"""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Create(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
return operation
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
if not args.validate_only:
log.CreatedResource(node_pool_ref,
'node pool in Anthos cluster on bare metal',
args.async_)
return operation_response

View File

@@ -0,0 +1,77 @@
# -*- 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 delete a node pool in an Anthos cluster on bare metal."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import bare_metal_node_pools as apis
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.bare_metal import cluster_flags
from googlecloudsdk.command_lib.container.bare_metal import node_pool_flags
from googlecloudsdk.core import log
_EXAMPLES = """
To delete a node pool named ``my-node-pool'' in a cluster named
``my-cluster'' managed in location ``us-west1'', run:
$ {command} my-node-pool --cluster=my-cluster --location=us-west1
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Delete(base.DeleteCommand):
"""Delete a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
node_pool_flags.AddNodePoolResourceArg(parser, 'to delete')
node_pool_flags.AddAllowMissingNodePool(parser)
cluster_flags.AddValidationOnly(parser)
base.ASYNC_FLAG.AddToParser(parser)
node_pool_flags.AddIgnoreErrors(parser)
def Run(self, args):
"""Runs the delete command."""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Delete(args)
if args.validate_only:
return
if operation.name is None:
return operation
if args.async_:
log.DeletedResource(node_pool_ref,
'Node Pool in Anthos Cluster on bare metal',
args.async_)
return operation
else:
operation_client = operations.OperationsClient()
response = operation_client.Wait(operation)
log.DeletedResource(node_pool_ref,
'Node Pool in Anthos Cluster on bare metal',
args.async_)
return response

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 a node pool in an Anthos cluster on bare metal."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import bare_metal_node_pools as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.bare_metal import node_pool_flags as flags
_EXAMPLES = """
To describe a node pool named ``my-node-pool'' in a cluster named
``my-cluster'' managed in location ``us-west1'', run:
$ {command} my-node-pool --cluster=my-cluster --location=us-west1
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Describe(base.DescribeCommand):
"""Describe a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
flags.AddNodePoolResourceArg(parser, 'to describe')
def Run(self, args):
"""Runs the describe command."""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
return client.Describe(node_pool_ref)

View File

@@ -0,0 +1,74 @@
# -*- 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 to enroll a node pool from a user cluster in Anthos on bare metal."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import bare_metal_node_pools as apis
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.bare_metal import cluster_flags
from googlecloudsdk.command_lib.container.bare_metal import constants as bare_metal_constants
from googlecloudsdk.command_lib.container.bare_metal import node_pool_flags
from googlecloudsdk.command_lib.container.gkeonprem import constants
_EXAMPLES = """
To enroll a node pool named `my-node-pool` in a cluster named
`my-cluster` managed in location `us-west1`, run:
$ {command} my-node-pool --cluster=my-cluster --location=us-west1
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Enroll(base.Command):
"""Enroll a node pool of a user cluster in Anthos on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT
)
node_pool_flags.AddNodePoolResourceArg(parser, 'to enroll')
base.ASYNC_FLAG.AddToParser(parser)
cluster_flags.AddValidationOnly(parser)
def Run(self, args):
"""Runs the enroll command."""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Enroll(args)
if args.validate_only:
return
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
operations.log_enroll(node_pool_ref, args.async_)
return operation
else:
operation_client = operations.OperationsClient()
response = operation_client.Wait(operation)
operations.log_enroll(node_pool_ref, args.async_)
return response

View File

@@ -0,0 +1,53 @@
# -*- 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 node pools in an Anthos cluster on bare metal."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import bare_metal_node_pools as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.bare_metal import cluster_flags as flags
from googlecloudsdk.command_lib.container.bare_metal import constants
_EXAMPLES = """
To list all node pools in a cluster named ``my-cluster''
managed in location ``us-west1'', run:
$ {command} --cluster=my-cluster --location=us-west1
"""
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class List(base.ListCommand):
"""List node pools in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
flags.AddClusterResourceArg(parser, 'to list', positional=False)
parser.display_info.AddFormat(constants.BARE_METAL_NODE_POOLS_FORMAT)
def Run(self, args):
"""Runs the list command."""
cluster_ref = args.CONCEPTS.cluster.Parse()
client = apis.NodePoolsClient()
return client.List(cluster_ref, args.page_size)

View File

@@ -0,0 +1,77 @@
# -*- 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 to unenroll a node pool from a user cluster in Anthos on bare metal."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.gkeonprem import bare_metal_node_pools as apis
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.bare_metal import constants as bare_metal_constants
from googlecloudsdk.command_lib.container.bare_metal import node_pool_flags
from googlecloudsdk.command_lib.container.gkeonprem import constants
_EXAMPLES = """
To unenroll a node pool named ``my-node-pool'' in a cluster named
``my-cluster'' managed in location ``us-west1'', run:
$ {command} my-node-pool --cluster=my-cluster --location=us-west1
"""
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Unenroll(base.Command):
"""Unenroll a node pool from a user cluster in Anthos on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT
)
node_pool_flags.AddNodePoolResourceArg(parser, 'to unenroll')
base.ASYNC_FLAG.AddToParser(parser)
node_pool_flags.AddAllowMissingNodePool(parser)
node_pool_flags.AddValidationOnly(parser)
def Run(self, args):
"""Runs the unenroll command."""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Unenroll(args)
if args.validate_only:
return
# using allow-missing returns an empty operation.
if operation.name is None:
return
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
operations.log_unenroll(node_pool_ref, args.async_)
return operation
else:
operation_client = operations.OperationsClient()
response = operation_client.Wait(operation)
operations.log_unenroll(node_pool_ref, args.async_)
return response

View File

@@ -0,0 +1,205 @@
# -*- 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 a node pool in an Anthos cluster on bare metal."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from typing import Optional
from googlecloudsdk.api_lib.container.gkeonprem import bare_metal_node_pools as apis
from googlecloudsdk.api_lib.container.gkeonprem import operations
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.command_lib.container.bare_metal import cluster_flags
from googlecloudsdk.command_lib.container.bare_metal import constants as bare_metal_constants
from googlecloudsdk.command_lib.container.bare_metal import node_pool_flags as flags
from googlecloudsdk.command_lib.container.gkeonprem import constants
from googlecloudsdk.core import log
from googlecloudsdk.generated_clients.apis.gkeonprem.v1 import gkeonprem_v1_messages as messages
_EXAMPLES = """
To update a node pool named ``my-node-pool'' in a cluster named
``my-cluster'' managed in location ``us-west1'', run:
$ {command} my-node-pool --cluster=my-cluster --location=us-west1
"""
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers commandline arguments for the update command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT
)
flags.AddNodePoolResourceArg(parser, 'to update')
cluster_flags.AddValidationOnly(parser)
flags.AddAllowMissingUpdateNodePool(parser)
base.ASYNC_FLAG.AddToParser(parser)
flags.AddNodePoolConfig(parser, is_update=True)
flags.AddNodePoolDisplayName(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. If `--validate-only` is specified, it returns None or any
possible error.
"""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Update(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
return operation
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
if not args.validate_only:
log.UpdatedResource(
node_pool_ref,
'Node pool in Anthos cluster on bare metal',
args.async_,
)
return operation_response
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(base.UpdateCommand):
"""Update a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers commandline arguments for the update command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT)
flags.AddNodePoolResourceArg(parser, 'to update')
cluster_flags.AddValidationOnly(parser)
flags.AddAllowMissingUpdateNodePool(parser)
base.ASYNC_FLAG.AddToParser(parser)
flags.AddNodePoolConfig(parser, is_update=True)
flags.AddNodePoolDisplayName(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. If `--validate-only` is specified, it returns None or any
possible error.
"""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Update(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
return operation
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
if not args.validate_only:
log.UpdatedResource(node_pool_ref,
'Node pool in Anthos cluster on bare metal',
args.async_)
return operation_response
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(base.UpdateCommand):
"""Update a node pool in an Anthos cluster on bare metal."""
detailed_help = {'EXAMPLES': _EXAMPLES}
@staticmethod
def Args(parser: parser_arguments.ArgumentInterceptor):
"""Gathers commandline arguments for the update command.
Args:
parser: The argparse parser to add the flag to.
"""
parser.display_info.AddFormat(
bare_metal_constants.BARE_METAL_NODE_POOLS_FORMAT)
flags.AddNodePoolResourceArg(parser, 'to update')
cluster_flags.AddValidationOnly(parser)
flags.AddAllowMissingUpdateNodePool(parser)
base.ASYNC_FLAG.AddToParser(parser)
flags.AddNodePoolConfig(parser, is_update=True)
flags.AddNodePoolDisplayName(parser)
flags.AddNodePoolVersion(parser)
def Run(self, args) -> Optional[messages.Operation]:
"""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. If `--validate-only` is specified, it returns None or any
possible error.
"""
node_pool_ref = args.CONCEPTS.node_pool.Parse()
client = apis.NodePoolsClient()
operation = client.Update(args)
if args.async_ and not args.IsSpecified('format'):
args.format = constants.OPERATIONS_FORMAT
if args.async_:
return operation
operation_client = operations.OperationsClient()
operation_response = operation_client.Wait(operation)
if not args.validate_only:
log.UpdatedResource(node_pool_ref,
'Node pool in Anthos cluster on bare metal',
args.async_)
return operation_response