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,27 @@
# -*- 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.
"""The gcloud workbench instances command group."""
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, base.ReleaseTrack.BETA)
class Instances(base.Group):
"""Workbench Instances command group."""

View File

@@ -0,0 +1,21 @@
release_tracks: [GA, BETA]
help_text:
brief: Adds IAM policy binding for a workbench instance.
description: |
Adds a policy binding to the IAM policy of an instance, given an instance ID and the binding.
examples: |
To add an IAM policy binding for the role of ``roles/notebooks.admin'' for the user 'test-user@gmail.com'
on the instance 'instance-id', run:
$ {command} --member='user:test-user@gmail.com' --role='roles/notebooks.admin' example-instance --location=us-central1-a
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
request:
collection: notebooks.projects.locations.instances
api_version: v2
arguments:
resource:
help_text: The ID of the instance to add the IAM binding.
spec: !REF googlecloudsdk.command_lib.workbench.resources:instance

View File

@@ -0,0 +1,60 @@
# -*- 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.
"""'workbench instances checkinstanceupgradability' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Checks if a workbench instance is upgradeable.
""",
'EXAMPLES':
"""
To check if an instance can be upgraded, run:
$ {command} example-instance --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class IsUpgradeable(base.DescribeCommand):
"""Checks if a workbench instance is upgradeable."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddIsUpgradeableInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
result = instance_service.CheckUpgradability(
instance_util.CreateInstanceCheckUpgradabilityRequest(args, messages))
return result
IsUpgradeable.detailed_help = DETAILED_HELP

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.
"""'workbench instances create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Creates a workbench instance.
""",
'EXAMPLES':
"""
To create an instance from a VmImage family, run:
$ {command} example-instance --vm-image-project=cloud-notebooks-managed --vm-image-family=workbench-instances --machine-type=n1-standard-4 --location=us-central1-b
To create an instance from a VmImage name, run:
$ {command} example-instance --vm-image-project=cloud-notebooks-managed --vm-image-name=workbench-instances-v20230925-debian-11-py310 --machine-type=n1-standard-4 --location=us-central1-b
To create an instance from a Container Repository, run:
$ {command} example-instance --container-repository=gcr.io/deeplearning-platform-release/base-cpu --container-tag=latest --machine-type=n1-standard-4 --location=us-central1-b
To create an instance with shielded-secure-boot, shielded-vtpm and shielded-integrity-monitoring disabled, run:
$ {command} example-instance --shielded-integrity-monitoring=false --shielded-secure-boot=false --shielded-vtpm=false --location=us-central1-b
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Create(base.CreateCommand):
"""Creates a workbench instance."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
flags.AddCreateInstanceFlags(parser)
def Run(self, args):
"""This is what gets called when the user runs this command."""
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Create(
instance_util.CreateInstanceCreateRequest(args, messages)
)
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.CREATE,
)
Create.detailed_help = DETAILED_HELP

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.
"""'workbench instances delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Deletes a workbench instance.
""",
'EXAMPLES':
"""
To delete an instance, run:
$ {command} example-instance --location=us-central1-b
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Delete(base.DeleteCommand):
"""Deletes a workbench instance."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDeleteInstanceFlags(parser)
def Run(self, args):
"""This is what gets called when the user runs this command."""
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Delete(
instance_util.CreateInstanceDeleteRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.DELETE)
Delete.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,60 @@
# -*- 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.
"""'workbench instances describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describes a workbench instance.
""",
'EXAMPLES':
"""
To describe an instance, run:
$ {command} example-instance --location=us-central1-b
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Describe(base.DescribeCommand):
"""Describes a workbench instance."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDescribeInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
result = instance_service.Get(
instance_util.CreateInstanceDescribeRequest(args, messages))
return result
Describe.detailed_help = DETAILED_HELP

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.
"""'workbench instances diagnose' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Diagnoses a workbench instance.
""",
'EXAMPLES':
"""
To diagnose an instance, run:
$ {command} example-instance --location=us-west1-b --gcs-bucket=gs://example-bucket
To diagnose an instance with a relative path:
$ {command} example-instance --location=us-west1-b --gcs-bucket=gs://example-bucket --relative-path=logs
To diagnose an instance, with packet capture:
$ {command} example-instance --location=us-west1-b --gcs-bucket=gs://example-bucket --enable-packet-capture
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Diagnose(base.Command):
"""Diagnoses a workbench instance."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDiagnoseInstanceFlags(parser)
def Run(self, args):
"""This is what gets called when the user runs this command."""
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Diagnose(
instance_util.CreateInstanceDiagnoseRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.UPDATE)
Diagnose.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,64 @@
# -*- 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.
"""'workbench instances get-config' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_errors
from googlecloudsdk.command_lib.workbench import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION':
"""
Describes the valid configurations for workbench instances.
""",
'EXAMPLES':
"""
For valid configurations, run:
$ {command} --location=us-west1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Describe(base.DescribeCommand):
"""Describes the valid configurations for workbench instances."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddListInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
if (not args.IsSpecified('location')) and (
not properties.VALUES.notebooks.location.IsExplicitlySet()):
raise parser_errors.RequiredError(argument='--location')
instance_service = client.projects_locations_instances
result = instance_service.GetConfig(
instance_util.CreateGetConfigRequest(args, messages))
return result
Describe.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,22 @@
release_tracks: [GA, BETA]
help_text:
brief: Gets IAM policy for a workbench instance.
description: |
*{command}* displays the IAM policy associated with an instance.
If formatted as JSON, the output can be edited and used as
a policy file for *set-iam-policy*. The output includes an "etag"
field identifying the version emitted and allowing detection of
concurrent policy updates; see
$ {parent} set-iam-policy for additional details.
examples: |
To print the IAM policy for a given instance, run:
$ {command} my-instance --location=us-central1-a
request:
collection: notebooks.projects.locations.instances
api_version: v2
arguments:
resource:
help_text: The ID of the instance for which to display the IAM policy.
spec: !REF googlecloudsdk.command_lib.workbench.resources:instance

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.
"""'workbench instances list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_errors
from googlecloudsdk.command_lib.workbench import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION':
"""
Lists workbench instances.
""",
'EXAMPLES':
"""
To list instances in a particular location, run:
$ {command} --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class List(base.ListCommand):
"""Lists workbench instances."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
parser.display_info.AddFormat("""
table(name.segment(-1),
name.segment(-3):label=LOCATION,
name.segment(-5):label=PROJECT,
state,
machineType.segment(-1),
network.segment(-1),
subnet.segment(-1))
""")
parser.display_info.AddUriFunc(instance_util.GetInstanceURI)
flags.AddListInstanceFlags(parser)
def Run(self, args):
"""This is what gets called when the user runs this command."""
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
if (not args.IsSpecified('location')) and (
not properties.VALUES.notebooks.location.IsExplicitlySet()):
raise parser_errors.RequiredError(argument='--location')
instance_service = client.projects_locations_instances
return list_pager.YieldFromList(
instance_service,
instance_util.CreateInstanceListRequest(args, messages),
field='instances',
limit=args.limit,
batch_size_attribute='pageSize')
List.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,21 @@
release_tracks: [GA, BETA]
help_text:
brief: Removes IAM policy binding for a workbench instance.
description: |
Removes a policy binding to the IAM policy of an instance, given an instance ID and the binding.
examples: |
To remove an IAM policy binding for the role of ``roles/editor'' for the user 'test-user@gmail.com'
on the instance 'instance-id', run:
$ {command} example-instance --member='user:test-user@gmail.com' --role='roles/editor' --location=us-central1-a
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
request:
collection: notebooks.projects.locations.instances
api_version: v2
arguments:
resource:
help_text: The ID of the instance to remove the IAM binding.
spec: !REF googlecloudsdk.command_lib.workbench.resources:instance

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.
"""'workbench instances reset' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Resets a workbench instance.
""",
'EXAMPLES':
"""
To reset an instance, run:
$ {command} example-instance --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Reset(base.Command):
"""Resets a workbench instance."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddResetInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Reset(
instance_util.CreateInstanceResetRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.RESET)
Reset.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,68 @@
# -*- 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.
"""'workbench instances update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Resizes the workbench instance's disk.
""",
'EXAMPLES':
"""
To increase the boot disk size for an instance, run:
$ {command} example-instance --boot-disk-size=200 --location=us-central1-a
To increase the data disk size for an instance, run:
$ {command} example-instance --data-disk-size=200 --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Update(base.Command):
"""Resizes the workbench instance's disk."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddResizeDiskFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.ResizeDisk(
instance_util.CreateInstanceResizeDisk(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.UPDATE)
Update.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,65 @@
# -*- 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.
"""'workbench instances get-config' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Restores the workbench instance to a snapshot state.
""",
'EXAMPLES':
"""
For valid configurations, run:
$ {command} example-instance --snapshot-project=example-project --snapshot=example-snapshot --location=us-west1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Restore(base.RestoreCommand):
"""Restores the workbench instance to a snapshot state."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddRestoreInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Restore(
instance_util.CreateInstanceRestoreRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.RESTORE)
Restore.detailed_help = DETAILED_HELP

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.
"""'workbench instances rollback' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Rolls back a workbench instance.
""",
'EXAMPLES':
"""
To rollback an instance, run:
$ {command} example-instance target-snapshot=projects/example-project/global/snapshots/aorlbjvpavvf --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Rollback(base.Command):
"""Rolls back a workbench instance."""
@staticmethod
def Args(parser):
"""Upgrade flags for this command."""
flags.AddRollbackInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Rollback(
instance_util.CreateInstanceRollbackRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.ROLLBACK)
Rollback.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,30 @@
- release_tracks: [GA, BETA]
help_text:
brief: Sets the IAM policy for a workbench instance.
description: |
*{command}* sets the IAM policy for a Notebook instance given an
instance ID and a JSON or YAML file that describes the IAM policy.
Note: Setting the IAM policy for an Instance replaces existing IAM bindings for
that account.
examples: |
The following command reads an IAM policy defined in the JSON file
`policy.json` and sets it for Instance ID *my_instance* at the
specified location:
$ {command} my_instance --location=us-central1-a policy.json
See https://cloud.google.com/iam/docs/managing-policies for policy file
format and content details.
request:
collection: notebooks.projects.locations.instances
api_version: v2
arguments:
resource:
help_text: The ID of the instance for which to set the IAM policy.
spec: !REF googlecloudsdk.command_lib.workbench.resources:instance

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.
"""'workbench instances start' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Starts a workbench instance.
""",
'EXAMPLES':
"""
To start an instance, run:
$ {command} example-instance --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Start(base.Command):
"""Starts a workbench instance."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddStartInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Start(
instance_util.CreateInstanceStartRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.UPDATE)
Start.detailed_help = DETAILED_HELP

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.
"""'workbench instances stop' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Stops a workbench instance.
""",
'EXAMPLES':
"""
To stop an instance, run:
$ {command} example-instance --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Stop(base.Command):
"""Stops a workbench instance."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddStopInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Stop(
instance_util.CreateInstanceStopRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.UPDATE)
Stop.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,68 @@
# -*- 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.
"""'workbench instances update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Updates a workbench instance.
""",
'EXAMPLES':
"""
To update machine type for an instance, run:
$ {command} example-instance --machine-type=n1-standard-8 --location=us-central1-a
To update labels for an instance, run:
$ {command} example-instance --labels=k1=v1,k2=v2 --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Update(base.Command):
"""Updates a workbench instance."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddUpdateInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Patch(
instance_util.CreateInstanceUpdateRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.UPDATE)
Update.detailed_help = DETAILED_HELP

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.
"""'workbench instances upgrade' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workbench import instances as instance_util
from googlecloudsdk.api_lib.workbench import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workbench import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Upgrades a workbench instance.
""",
'EXAMPLES':
"""
To upgrade an instance, run:
$ {command} example-instance --location=us-central1-a
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA)
class Upgrade(base.Command):
"""Upgrades a workbench instance."""
@staticmethod
def Args(parser):
"""Upgrade flags for this command."""
flags.AddUpgradeInstanceFlags(parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
instance_service = client.projects_locations_instances
operation = instance_service.Upgrade(
instance_util.CreateInstanceUpgradeRequest(args, messages))
return instance_util.HandleLRO(
operation,
args,
instance_service,
release_track,
operation_type=instance_util.OperationType.UPGRADE)
Upgrade.detailed_help = DETAILED_HELP