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,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 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 environments 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.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Environments(base.Group):
"""Notebooks Environments Command Group."""
pass

View File

@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 environments create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import environments as env_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 creating environments.
""",
'EXAMPLES':
"""
To create an environment with id 'example-environment' in location
'us-central1-a' using a container repository, run:
$ {command} example-environment --location=us-central1-a --container-repository=gcr.io/deeplearning-platform-release/base-cpu --container-tag=test-tag --description=test-description --post-startup-script=gs://path-to-file/file-name --display-name=test-display-name --async
To create an environment with id 'example-environment' in location
'us-central1-a' using a VM Image Family, run:
$ {command} example-environment --vm-image-project=deeplearning-platform-release --vm-image-family=caffe1-latest-cpu-experimental
To create an environment with id 'example-environment' in location
'us-central1-a' using a VM Image, run:
$ {command} example-environment --location=us-central1-a --vm-image-project=deeplearning-platform-release --vm-image-name=tf2-2-1-cu101-notebooks-20200110
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Request for creating environments."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddCreateEnvironmentFlags(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)
environment_service = client.projects_locations_environments
operation = environment_service.Create(
env_util.CreateEnvironmentCreateRequest(args, messages))
return env_util.HandleLRO(operation, args, environment_service,
release_track)
Create.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 environments delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import environments as env_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 environments.
""",
'EXAMPLES':
"""
To delete environment with id 'example-environment' in location
'us-central1-a', run:
$ {command} example-environment --location=us-central1-a
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Request for deleting environments."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddDeleteEnvironmentFlags(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)
environment_service = client.projects_locations_environments
operation = environment_service.Delete(
env_util.CreateEnvironmentDeleteRequest(args, messages))
return env_util.HandleLRO(
operation,
args,
environment_service,
release_track,
is_delete=True)
Delete.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 environments describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.notebooks import environments as env_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 environments.
""",
'EXAMPLES':
"""
To describe an environment with id 'example-environment' in location
'us-central1-a', run:
$ {command} example-environment --location=us-central1-a
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Request for describing environments."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
api_version = util.ApiVersionSelector(cls.ReleaseTrack())
flags.AddDescribeEnvironmentFlags(api_version, parser)
def Run(self, args):
release_track = self.ReleaseTrack()
client = util.GetClient(release_track)
messages = util.GetMessages(release_track)
environment_service = client.projects_locations_environments
result = environment_service.Get(
env_util.CreateEnvironmentDescribeRequest(args, messages))
return result
Describe.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 environments 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 environments as env_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 environments.
""",
'EXAMPLES':
"""
To list environments in location 'us-central1-a', run:
$ {command} --location=us-central1-a
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class List(base.ListCommand):
"""Request for listing environments."""
@classmethod
def Args(cls, parser):
"""Register flags for this command."""
parser.display_info.AddFormat("""
table(name.segment(-1),
name.segment(-3):label=LOCATION,
name.segment(-5):label=PROJECT,
vmImage.imageFamily,
vmImage.imageName,
containerImage.repository)
""")
parser.display_info.AddUriFunc(env_util.GetEnvironmentURI)
flags.AddListEnvironmentFlags(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')
environment_service = client.projects_locations_environments
return list_pager.YieldFromList(
environment_service,
env_util.CreateEnvironmentListRequest(args, messages),
field='environments',
limit=args.limit,
batch_size_attribute='pageSize')
List.detailed_help = DETAILED_HELP