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,34 @@
# -*- 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.
"""Manage Cloud Workstations resources."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
@base.DefaultUniverseOnly
class Workstations(base.Group):
"""Manage Cloud Workstations resources."""
category = base.TOOLS_CATEGORY
def Filter(self, context, args):
del context, args

View File

@@ -0,0 +1,30 @@
# -*- 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.
"""Manage Cloud Workstations cluster resources."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Clusters(base.Group):
"""Manage Cloud Workstations cluster resources."""
category = base.TOOLS_CATEGORY
def Filter(self, context, args):
del context, args

View File

@@ -0,0 +1,74 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Create a workstation cluster.
description: |
Create a workstation cluster.
examples: |
To create a public cluster `my-cluster` in region `us-central1`, run:
$ {command} my-cluster --region=us-central1
To create a private cluster 'my-private-cluster' associated with network 'my-network' and
subnetwork 'my-subnetwork'. run:
$ {command} my-private-cluster --region=us-central1 --enable-private-endpoint
--network='my-network' --subnetwork='my-subnetwork'
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:cluster
help_text: |
Arguments and flags that specify the cluster to create.
params:
- arg_name: network
api_field: workstationCluster.network
help_text: |
Fully specified network path for instances created in this cluster.
- arg_name: subnetwork
api_field: workstationCluster.subnetwork
help_text: |
Fully specified subnetwork path for instances created in this cluster.
- arg_name: labels
metavar: KEY=VALUE
api_field: workstationCluster.labels
type: "googlecloudsdk.calliope.arg_parsers:ArgDict:"
help_text: |
Labels that are applied to the cluster and propagated to the underlying Compute Engine
resources.
- arg_name: enable-private-endpoint
api_field: workstationCluster.privateClusterConfig.enablePrivateEndpoint
type: bool
default: false
help_text: |
Default is false.
If specified, the cluster will be assigned an internal IP address to the Cluster Gateway.
This isolates the cluster's workstations from public networks, but requires additional
configuration. Learn more: https://cloud.google.com/workstations/docs.
- arg_name: domain
api_field: workstationCluster.domainConfig.domain
type: str
help_text: |
Domain used by Workstations for HTTP ingress.
- arg_name: tags
api_field: workstationCluster.tags
metavar: KEY=VALUE
type: "googlecloudsdk.calliope.arg_parsers:ArgDict:"
help_text: |
Resource manager tags to be bound to this cluster.
For example:
"123/environment=production"
"123/costCenter=marketing"
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters
async:
collection: workstations.projects.locations.operations

View File

@@ -0,0 +1,29 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Delete a workstation cluster.
description: |
Delete a workstation cluster.
examples: |
To delete a cluster, run:
$ {command} WORKSTATION
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:cluster
help_text: |
The name of the cluster to delete.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters
async:
collection: workstations.projects.locations.operations

View File

@@ -0,0 +1,29 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Describe a cluster.
description: |
Describe a cluster.
examples: |
To describe a cluster, run:
$ {command} CLUSTER
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:cluster
help_text: |
The name of the cluster to display.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters
output:
format: json

View File

@@ -0,0 +1,34 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
List workstation clusters.
description: |
List all workstation clusters under the specified project and region.
examples: |
To list workstation clusters, run:
$ {command}
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:region_with_global_fallthrough
help_text: |
The region of the clusters to display.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters
output:
format: |
table(
name.basename():sort=1,
name.scope(locations).segment(0):label='REGION',
createTime.date()
)

View File

@@ -0,0 +1,30 @@
# -*- 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.
"""Manage Cloud Workstations configuration resources."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Configs(base.Group):
"""Manage Cloud Workstations configuration resources."""
category = base.TOOLS_CATEGORY
def Filter(self, context, args):
del context, args

View File

@@ -0,0 +1,114 @@
# -*- 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 for creating Workstation configs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workstations import configs
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workstations import flags as workstations_flags
@base.DefaultUniverseOnly
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class Create(base.CreateCommand):
"""Create a workstation configuration.
Create a workstation configuration.
## EXAMPLES
To create a configuration with the 'e2-standard-8' machine type and a
IntelliJ image, run:
$ {command} CONFIG --machine-type=e2-standard-8
--container-predefined-image=intellij
To create a configuration with a Shielded VM instance that enables Secure
Boot, virtual trusted platform module (vTPM) and integrity monitoring, run:
$ {command} CONFIG --machine-type=e2-standard-4 --shielded-secure-boot
--shielded-vtpm --shielded-integrity-monitoring
To create a configuration with a non-default persistent disk containing 10GB
of PD SSD storage, run:
$ {command} CONFIG --machine-type=e2-standard-4 --pd-disk-type=pd-ssd
--pd-disk-size=10
"""
@classmethod
def Args(cls, parser):
workstations_flags.AddAcceleratorFields(parser)
workstations_flags.AddAllowedPortsFlag(parser)
workstations_flags.AddAsyncFlag(parser)
workstations_flags.AddBootDiskSize(parser)
workstations_flags.AddConfigResourceArg(parser)
workstations_flags.AddContainerArgsField(parser)
workstations_flags.AddContainerCommandField(parser)
workstations_flags.AddContainerEnvField(parser)
workstations_flags.AddContainerImageField(parser)
workstations_flags.AddContainerRunAsUserField(parser)
workstations_flags.AddContainerWorkingDirField(parser)
workstations_flags.AddDeprecatedDisableSSHToVM(parser)
workstations_flags.AddDisablePublicIpAddresses(parser)
workstations_flags.AddDisableTcpConnections(parser)
workstations_flags.AddEnableAuditAgent(parser)
workstations_flags.AddEnableConfidentialCompute(parser)
workstations_flags.AddEnableNestedVirtualization(parser)
workstations_flags.AddEnableSSHToVM(parser, True)
workstations_flags.AddEncryptionKeyFields(parser)
workstations_flags.AddEphemeralDirectory(parser)
workstations_flags.AddGrantWorkstationAdminRoleOnCreate(parser)
workstations_flags.AddIdleTimeoutFlag(parser)
workstations_flags.AddLabelsField(parser)
workstations_flags.AddMachineTypeFlag(parser)
workstations_flags.AddMaxUsableWorkstationsCount(parser)
workstations_flags.AddNetworkTags(parser)
workstations_flags.AddPoolSize(parser)
workstations_flags.AddReplicaZones(parser)
workstations_flags.AddRunningTimeoutFlag(parser)
workstations_flags.AddServiceAccountFlag(parser)
workstations_flags.AddServiceAccountScopes(parser)
workstations_flags.AddShieldedIntegrityMonitoring(parser)
workstations_flags.AddShieldedSecureBoot(parser)
workstations_flags.AddShieldedVtpm(parser)
workstations_flags.AddStartupScriptUri(parser)
workstations_flags.AddVmTags(parser)
if cls.ReleaseTrack() == base.ReleaseTrack.GA:
workstations_flags.AddNoPersistentStorageOrPd(parser)
else:
workstations_flags.AddNoPersistentStorageOrPdOrDisk(parser)
if cls.ReleaseTrack() != base.ReleaseTrack.GA:
workstations_flags.AddAllowUnauthenticatedCorsPreflightRequestsFlag(
parser
)
workstations_flags.AddBoostConfigs(parser)
workstations_flags.AddDisableLocalhostReplacementFlag(parser)
workstations_flags.AddReservationAffinity(parser)
workstations_flags.AddInstanceMetadata(parser)
def Collection(self):
return (
'workstations.projects.locations.workstationClusters.workstationConfigs'
)
def Run(self, args):
client = configs.Configs(self.ReleaseTrack())
response = client.Create(args)
return response

View File

@@ -0,0 +1,29 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Delete a workstation configuration.
description: |
Delete a workstation configuration.
examples: |
To delete a configuration, run:
$ {command} WORKSTATION
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:config
help_text: |
The name of the configuration to delete.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs
async:
collection: workstations.projects.locations.operations

View File

@@ -0,0 +1,29 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Describe a config.
description: |
Describe a config.
examples: |
To describe a config, run:
$ {command} CONFIG
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:config
help_text: |
The name of the config to display.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs
output:
format: json

View File

@@ -0,0 +1,30 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Get the IAM policy for a configuration..
description: |
*{command}* displays the IAM policy associated with a given configuration. 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 get the IAM policy for a given configuration, run:
$ {command} CONFIG
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:config
help_text: |
The configuration for which to display the IAM policy.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs

View File

@@ -0,0 +1,37 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
List workstation configurations.
description: |
List all workstation configurations under the specified cluster.
examples: |
To list workstation configurations, run:
$ {command}
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:cluster_with_global_fallthrough
help_text: |
The cluster of the configurations to display.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs
output:
format: |
table(
name.basename():sort=1,
name.scope(workstationClusters).segment(0):label='CLUSTER',
name.scope(locations).segment(0):label='REGION',
createTime.date(),
host.gceInstance.machine_type:label='MACHINE TYPE',
container.image:label='IMAGE'
)

View File

@@ -0,0 +1,30 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Set the IAM policy for a configuration.
description: |
Sets the IAM policy for the given configuration as defined in a JSON or YAML file.
examples: |
The following command will read an IAM policy defined in a JSON file 'policy.json' and set it
for the given configuration:
$ {command} CONFIG policy.json
See https://cloud.google.com/iam/docs/managing-policies for details of the
policy file format and contents.
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:config
help_text: |
The configuration for which to display the IAM policy.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs

View File

@@ -0,0 +1,109 @@
# -*- 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 for updating Workstation configs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workstations import configs
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workstations import flags as workstations_flags
@base.DefaultUniverseOnly
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class Update(base.UpdateCommand):
"""Updates a workstation configuration.
Updates a workstation configuration.
## EXAMPLES
To update a configuration with the 'e2-standard-8' machine type and a
IntelliJ image, run:
$ {command} CONFIG --machine-type=e2-standard-8
--container-predefined-image=intellij
To update a configuration to disable Secure Boot, virtual trusted platform
module (vTPM) and integrity monitoring, run:
$ {command} CONFIG --no-shielded-secure-boot --no-shielded-vtpm
--no-shielded-integrity-monitoring
"""
@classmethod
def Args(cls, parser):
workstations_flags.AddAcceleratorFields(parser)
workstations_flags.AddAllowedPortsFlag(parser)
workstations_flags.AddAsyncFlag(parser)
workstations_flags.AddBootDiskSize(parser, use_default=False)
workstations_flags.AddConfigResourceArg(parser)
workstations_flags.AddContainerArgsField(parser)
workstations_flags.AddContainerCommandField(parser)
workstations_flags.AddContainerEnvField(parser)
workstations_flags.AddContainerImageField(parser, use_default=False)
workstations_flags.AddContainerRunAsUserField(parser)
workstations_flags.AddContainerWorkingDirField(parser)
workstations_flags.AddDisablePublicIpAddresses(parser, use_default=False)
workstations_flags.AddDisableSSHToVM(parser)
workstations_flags.AddEnableAuditAgent(parser, use_default=False)
workstations_flags.AddEnableConfidentialCompute(parser, use_default=False)
workstations_flags.AddEnableNestedVirtualization(parser, use_default=False)
workstations_flags.AddEnableTcpConnections(parser)
workstations_flags.AddGrantWorkstationAdminRoleOnCreate(
parser, use_default=False
)
workstations_flags.AddIdleTimeoutFlag(parser, use_default=False)
workstations_flags.AddLabelsField(parser)
workstations_flags.AddMachineTypeFlag(parser, use_default=False)
workstations_flags.AddMaxUsableWorkstationsCount(parser)
workstations_flags.AddNetworkTags(parser)
workstations_flags.AddPoolSize(parser, use_default=False)
workstations_flags.AddRunningTimeoutFlag(parser, use_default=False)
workstations_flags.AddServiceAccountFlag(parser)
workstations_flags.AddServiceAccountScopes(parser)
workstations_flags.AddShieldedSecureBoot(parser, use_default=False)
workstations_flags.AddShieldedIntegrityMonitoring(parser, use_default=False)
workstations_flags.AddShieldedVtpm(parser, use_default=False)
workstations_flags.AddStartupScriptUri(parser)
workstations_flags.AddVmTags(parser)
if cls.ReleaseTrack() != base.ReleaseTrack.GA:
workstations_flags.AddPersistentDirectoriesOrHyperdisks(
parser, use_default=False
)
else:
workstations_flags.AddPersistentDirectories(parser, use_default=False)
if cls.ReleaseTrack() != base.ReleaseTrack.GA:
workstations_flags.AddDisallowUnauthenticatedCorsPreflightRequestsToggleFlag(
parser
)
workstations_flags.AddBoostConfigs(parser)
workstations_flags.AddDisableLocalhostReplacementToggleFlag(parser)
workstations_flags.AddReservationAffinity(parser)
workstations_flags.AddInstanceMetadata(parser)
def Collection(self):
return (
'workstations.projects.locations.workstationClusters.workstationConfigs'
)
def Run(self, args):
client = configs.Configs(self.ReleaseTrack())
response = client.Update(args)
return response

View File

@@ -0,0 +1,51 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Create a workstation.
description: |
Create a workstation.
examples: |
To create a workstation, run:
$ {command} WORKSTATION
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:workstation
help_text: |
Arguments and flags that specify the workstation to create.
params:
- arg_name: labels
metavar: KEY=VALUE
api_field: workstation.labels
type: "googlecloudsdk.calliope.arg_parsers:ArgDict:"
help_text: |
Labels that are applied to the workstation and propagated to the underlying Compute Engine
resources.
- arg_name: env
metavar: KEY=VALUE
api_field: workstation.env
type: "googlecloudsdk.calliope.arg_parsers:ArgDict:"
help_text: |
Environment variables passed to the Workstation.
- arg_name: source-workstation
api_field: workstation.sourceWorkstation
type: str
help_text: |
Source workstation from which this workstations persistent directories are cloned on
creation. When specified, the workstations service agent must have
`compute.disks.createSnapshot` and `compute.snapshots.useReadOnly` permissions on the source
workstation's host project.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs.workstations
async:
collection: workstations.projects.locations.operations

View File

@@ -0,0 +1,29 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Delete a workstation.
description: |
Delete a workstation.
examples: |
To delete a workstation, run:
$ {command} WORKSTATION
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:workstation
help_text: |
The name of the workstation to delete.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs.workstations
async:
collection: workstations.projects.locations.operations

View File

@@ -0,0 +1,29 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Describe a workstation.
description: |
Describe a workstation.
examples: |
To describe a workstation, run:
$ {command} WORKSTATION
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:workstation
help_text: |
The name of the workstation to display.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs.workstations
output:
format: json

View File

@@ -0,0 +1,30 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Get the IAM policy for a workstation.
description: |
*{command}* displays the IAM policy associated with a given workstation. 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 get the IAM policy for a given workstation, run:
$ {command} WORKSTATION
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:workstation
help_text: |
The workstation for which to display the IAM policy.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs.workstations

View File

@@ -0,0 +1,37 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
List workstations.
description: |
List all workstations under the specified configuration.
examples: |
To list workstations, run:
$ {command}
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:config_with_global_fallthrough
help_text: |
The configuration of the workstations to display.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs.workstations
output:
format: |
table(
name.basename():sort=1,
name.scope(workstationConfigs).segment(0):label='CONFIG',
name.scope(workstationClusters).segment(0):label='CLUSTER',
name.scope(locations).segment(0):label='REGION',
state.sub("STATE_", ""):optional,
createTime.date()
)

View File

@@ -0,0 +1,64 @@
# -*- 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 for listing usable workstations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workstations import workstations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workstations import flags
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class ListUsable(base.ListCommand):
"""List usable workstations.
List all usable workstations under the specified configuration.
## EXAMPLES
To list usable workstations, run
$ {command}
"""
@staticmethod
def Args(parser):
base.URI_FLAG.RemoveFromParser(parser)
flags.AddConfigResourceArg(
parser, flag_anchor=True, global_fallthrough=True
)
parser.display_info.AddFormat("""
table(
name.basename():sort=1,
name.scope(workstationConfigs).segment(0):label='CONFIG',
name.scope(workstationsClusters).segment(0):label='CLUSTER',
name.scope(locations).segment(0):label='REGION',
state.sub("STATE_", ""),
createTime.date()
)
""")
def Collection(self):
return 'workstations.projects.locations.workstationClusters.workstationConfigs.usableWorkstations'
def Run(self, args):
client = workstations.Workstations(self.ReleaseTrack())
response = client.ListUsableWorkstations(args)
return response

View File

@@ -0,0 +1,30 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Set the IAM policy for a workstation.
description: |
Sets the IAM policy for the given workstation as defined in a JSON or YAML file.
examples: |
The following command will read an IAM policy defined in a JSON file 'policy.json' and set it
for the given workstation:
$ {command} WORKSTATION policy.json
See https://cloud.google.com/iam/docs/managing-policies for details of the
policy file format and contents.
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.workstations.resources:workstation
help_text: |
The workstation for which to display the IAM policy.
request:
GA:
api_version: v1
BETA:
api_version: v1beta
ALPHA:
api_version: v1beta
collection: workstations.projects.locations.workstationClusters.workstationConfigs.workstations

View File

@@ -0,0 +1,89 @@
# -*- 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 for SSHing into a started workstation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import threading
from googlecloudsdk.api_lib.workstations import workstations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workstations import flags as workstations_flags
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
@base.DefaultUniverseOnly
class Start(base.Command):
"""SSH into a running workstation.
SSH into a running workstation.
Note that arguments for the `NO_PROXY` environment variable must be FQDNs.
## EXAMPLES
To ssh into a running workstation, run:
$ {command} WORKSTATION
To specify the workstation port, run:
$ {command} WORKSTATION --port=22
To ssh into a running workstation with a username, run:
$ {command} WORKSTATION --user=my-user
To run a command on the workstation, such as getting a snapshot of the
guest's process tree, run:
$ {command} WORKSTATION --command="ps -ejH"
"""
@staticmethod
def Args(parser):
workstations_flags.AddWorkstationResourceArg(parser)
workstations_flags.AddPortField(parser)
workstations_flags.AddLocalHostPortField(parser)
workstations_flags.AddCommandField(parser)
workstations_flags.AddSshArgsAndUserField(parser)
def Collection(self):
return 'workstations.projects.locations.workstationClusters.workstationConfigs.workstations'
def Run(self, args):
# Format arguments for StartTcpTunnel
args.workstation_port = args.port
client = workstations.Workstations(self.ReleaseTrack())
# Validate args in the main thread to reduce the chances of raising an
# exception within the tunnel thread. Otherwise, the exception won't bubble
# up correctly and can hang the process or generate unexpected output.
args.CONCEPTS.workstation.Parse()
client.threading_event.clear()
client.tcp_tunnel_open = False
t = threading.Thread(target=client.StartTcpTunnel, args=(args, True))
t.daemon = True
t.start()
client.threading_event.wait()
if client.tcp_tunnel_open:
client.Ssh(args)

View File

@@ -0,0 +1,54 @@
# -*- 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 for starting Workstations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workstations import workstations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workstations import flags as workstations_flags
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class Start(base.Command):
"""Start a workstation.
Start a workstation.
## EXAMPLES
To start a workstation, run
$ {command} WORKSTATION
"""
@classmethod
def Args(cls, parser):
workstations_flags.AddAsyncFlag(parser)
workstations_flags.AddWorkstationResourceArg(parser)
if (cls.ReleaseTrack() != base.ReleaseTrack.GA):
workstations_flags.AddBoost(parser)
def Collection(self):
return 'workstations.projects.locations.workstationClusters.workstationConfigs.workstations'
def Run(self, args):
client = workstations.Workstations(self.ReleaseTrack())
response = client.Start(args)
return response

View File

@@ -0,0 +1,54 @@
# -*- 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.
"""Implements a command to forward TCP traffic to a workstation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workstations import workstations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workstations import flags as workstations_flags
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
@base.DefaultUniverseOnly
class StartTcpTunnel(base.Command):
"""Start a tunnel through which a local process can forward TCP traffic to the workstation.
Start a tunnel through which a local process can forward TCP traffic to the
workstation.
Note that arguments for the `NO_PROXY` environment variable must be FQDNs.
## EXAMPLES
To start a tunnel to port 22 on a workstation, run:
$ {command} --project=my-project --region=us-central1 --cluster=my-cluster
--config=my-config my-workstation 22
"""
@staticmethod
def Args(parser):
workstations_flags.AddWorkstationResourceArg(parser)
workstations_flags.AddWorkstationPortField(parser)
workstations_flags.AddLocalHostPortField(parser)
def Run(self, args):
client = workstations.Workstations(self.ReleaseTrack())
client.StartTcpTunnel(args)

View File

@@ -0,0 +1,52 @@
# -*- 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 for stopping Workstations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.workstations import workstations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.workstations import flags as workstations_flags
@base.ReleaseTracks(
base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA
)
class Stop(base.Command):
"""Stop a workstation.
Stop a workstation.
## EXAMPLES
To stop a workstation, run
$ {command} WORKSTATION
"""
@staticmethod
def Args(parser):
workstations_flags.AddAsyncFlag(parser)
workstations_flags.AddWorkstationResourceArg(parser)
def Collection(self):
return 'workstations.projects.locations.workstationClusters.workstationConfigs.workstations'
def Run(self, args):
client = workstations.Workstations(self.ReleaseTrack())
response = client.Stop(args)
return response