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,26 @@
# -*- 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.
"""The gcloud notebooks runtimes command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Runtimes(base.Group):
"""Notebooks Runtimes command group."""

View File

@@ -0,0 +1,72 @@
# -*- 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.
"""'notebooks runtimes create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_errors
from googlecloudsdk.command_lib.notebooks import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for creating notebook runtimes.
""",
'EXAMPLES':
"""
To create a runtime, run:
$ {command} example-runtime --runtime-access-type=SINGLE_USER --runtime-owner=example@google.com --machine-type=n1-standard-4 --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Request for creating an runtime."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddCreateRuntimeFlags(api_version, 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')
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Create(
runtime_util.CreateRuntimeCreateRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.CREATE)
Create.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,66 @@
# -*- 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.
"""'notebooks runtimes delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for deleting notebook runtimes.
""",
'EXAMPLES':
"""
To delete a runtime, run:
$ {command} example-runtime --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Request for deleting runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddDeleteRuntimeFlags(api_version, 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)
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Delete(
runtime_util.CreateRuntimeDeleteRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.DELETE)
Delete.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,60 @@
# -*- 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.
"""'notebooks runtimes describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for describing notebook runtimes.
""",
'EXAMPLES':
"""
To describe a runtime, run:
$ {command} example-runtime --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Request for describing runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddDescribeRuntimeFlags(api_version, parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
runtime_service = client.projects_locations_runtimes
result = runtime_service.Get(
runtime_util.CreateRuntimeDescribeRequest(args, messages))
return result
Describe.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,75 @@
# -*- 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.
"""'notebooks runtimes diagnose' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for diagnose notebook runtimes.
""",
'EXAMPLES':
"""
To diagnose an runtime, run:
$ {command} example-runtime --location=us-central1 --gcs-bucket=gs://example-bucket
To diagnose an runtime with a relative path:
$ {command} example-runtime --location=us-central1 --gcs-bucket=gs://example-bucket --relative-path=logs
To diagnose an runtime, with packet capture:
$ {command} example-runtime --location=us-central1 --gcs-bucket=gs://example-bucket --enable-packet-capture
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Diagnose(base.Command):
"""Request for diagnose runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddDiagnoseRuntimeFlags(api_version, 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)
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Diagnose(
runtime_util.CreateRuntimeDiagnoseRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.UPDATE)
Diagnose.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'notebooks runtimes 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.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import parser_errors
from googlecloudsdk.command_lib.notebooks import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for listing runtimes.
""",
'EXAMPLES':
"""
To list runtimes in a particular location, run:
$ {command} --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""Request for listing runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
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(runtime_util.GetRuntimeURI)
flags.AddListRuntimeFlags(api_version, 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')
runtime_service = client.projects_locations_runtimes
return list_pager.YieldFromList(
runtime_service,
runtime_util.CreateRuntimeListRequest(args, messages),
field='runtimes',
limit=args.limit,
batch_size_attribute='pageSize')
List.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,75 @@
# -*- 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.
"""'notebooks runtimes migrate' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for migrating notebook runtimes.
""",
'EXAMPLES':
"""
To migrate a runtime, run:
$ {command} example-runtime --location=us-central1
To migrate a runtime with a new custom network, run:
$ {command} example-runtime --location=us-central1 --network=projects/example-project/global/networks/example-network --subnet=projects/example-project/regions/us-central1/subnetworks/example-subnetwork
To migrate a runtime and reuse the post-startup script, run:
$ {command} example-runtime --location=us-central1 --post-startup-script-option=POST_STARTUP_SCRIPT_OPTION_RERUN
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Migrate(base.Command):
"""Request for migrating runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddMigrateRuntimeFlags(api_version, 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)
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Migrate(
runtime_util.CreateRuntimeMigrateRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.MIGRATE)
Migrate.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,65 @@
# -*- 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.
"""'notebooks runtimes reset' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for resetting notebook runtimes.
""",
'EXAMPLES':
"""
To reset a runtime, run:
$ {command} example-runtime --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Reset(base.Command):
"""Request for resetting runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddResetRuntimeFlags(api_version, parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Reset(
runtime_util.CreateRuntimeResetRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.RESET)
Reset.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,65 @@
# -*- 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.
"""'notebooks runtimes start' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for starting notebook runtimes.
""",
'EXAMPLES':
"""
To start a runtime, run:
$ {command} example-runtime --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Start(base.Command):
"""Request for starting runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddStartRuntimeFlags(api_version, parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Start(
runtime_util.CreateRuntimeStartRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.UPDATE)
Start.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,65 @@
# -*- 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.
"""'notebooks runtimes stop' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for stopping notebook runtimes.
""",
'EXAMPLES':
"""
To stop a runtime, run:
$ {command} example-runtime --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Stop(base.Command):
"""Request for stopping runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddStopRuntimeFlags(api_version, parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Stop(
runtime_util.CreateRuntimeStopRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.UPDATE)
Stop.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,65 @@
# -*- 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.
"""'notebooks runtimes start' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import runtimes as runtime_util
from googlecloudsdk.api_lib.notebooks import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.notebooks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Request for switching notebook runtimes.
""",
'EXAMPLES':
"""
To switch a runtime, run:
$ {command} example-runtime --machine-type=n1-standard-4
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Switch(base.Command):
"""Request for switching runtimes."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddSwitchRuntimeFlags(api_version, parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
runtime_service = client.projects_locations_runtimes
operation = runtime_service.Switch(
runtime_util.CreateRuntimeSwitchRequest(args, messages))
return runtime_util.HandleLRO(
operation,
args,
runtime_service,
release_track,
operation_type=runtime_util.OperationType.UPDATE)
Switch.detailed_help = DETAILED_HELP