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,61 @@
# -*- coding: utf-8 -*- #
# Copyright 2013 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 super-group for the update manager."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import argparse
import os
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.core import config
from googlecloudsdk.core import log
from googlecloudsdk.core import properties
from googlecloudsdk.core.updater import update_manager
from googlecloudsdk.core.util import platforms
class Repositories(base.Group):
"""Manage additional component repositories for Trusted Tester programs."""
detailed_help = {
'DESCRIPTION': """\
List, add, and remove component repositories for Trusted Tester
programs. If you are not participating in a Trusted Tester program,
these commands are not necessary for updating your Google Cloud CLI
installation.
If you are participating in a Trusted Tester program, you will be
instructed on the location of repositories that you should add.
These commands allow you to manage the set of repositories you have
registered.
Once you have a repository registered, the component manager will use
that location to locate new Google Cloud CLI components that are
available, or possibly different versions of existing components that
can be installed.
If you want to revert to a standard version of the Google Cloud CLI at
any time, you may remove all repositories and then run:
$ gcloud components update
to revert to a standard installation.
""",
}

View File

@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*- #
# Copyright 2013 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 command to list installed/available gcloud components."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.core import log
from googlecloudsdk.core import properties
from googlecloudsdk.core.updater import snapshots
from googlecloudsdk.core.updater import update_manager
class Add(base.SilentCommand):
"""Add a new Trusted Tester component repository.
"""
detailed_help = {
'DESCRIPTION': """\
Add a new Trusted Tester component repository to the list of
repositories used by the component manager. This will allow you to
install and update components found in this repository.
If you are participating in a Trusted Tester program, you will be
instructed on the location of repositories with additional versions of
one or more Google Cloud CLI components.
""",
'EXAMPLES': """\
To add the Trusted Tester component repository
http://repo.location.com run:
$ gcloud components repositories add http://repo.location.com
""",
}
@staticmethod
def Args(parser):
parser.add_argument(
'url',
nargs='+',
metavar='URL',
help='One or more URLs for the component repositories you want to add.')
def Run(self, args):
"""Runs the add command."""
# Ensure all the repos are valid.
for repo in args.url:
try:
snapshots.ComponentSnapshot.FromURLs(
repo, command_path='components.repositories.add')
except snapshots.Error:
raise exceptions.InvalidArgumentException(
'url',
'The given repository [{repo}] could not be fetched. Check your '
'network settings and ensure that you have entered a valid '
'repository URL.'.format(repo=repo))
repos = update_manager.UpdateManager.GetAdditionalRepositories()
added = []
existing = []
for url in args.url:
if url in repos:
existing.append(url)
else:
added.append(url)
repos.extend(added)
properties.PersistProperty(
properties.VALUES.component_manager.additional_repositories,
','.join(repos),
scope=properties.Scope.INSTALLATION)
for url in added:
log.status.Print('Added repository: [{repo}]'.format(repo=url))
for url in existing:
log.status.Print(
'Repository already added, skipping: [{repo}]'.format(repo=url))
return added

View File

@@ -0,0 +1,83 @@
# -*- coding: utf-8 -*- #
# Copyright 2013 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 command to list installed/available gcloud components."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.core import log
from googlecloudsdk.core.updater import snapshots
from googlecloudsdk.core.updater import update_manager
def TransformLastUpdate(r):
try:
snapshot = snapshots.ComponentSnapshot.FromURLs(
r, command_path='components.repositories.list')
return snapshot.sdk_definition.LastUpdatedString()
except (AttributeError, TypeError, snapshots.URLFetchError):
return 'Unknown'
_COMPONENTS_REPOSITORIES_TRANSFORMS = {
'last_update': TransformLastUpdate,
}
class List(base.ListCommand):
"""List any Trusted Tester component repositories you have registered.
"""
detailed_help = {
'DESCRIPTION': """
List all Trusted Tester component repositories that are registered
with the component manager. If you have additional repositories, the
component manager will look at them to discover additional components
to install, or different versions of existing components that are
available.
""",
'EXAMPLES': """
To list all Trusted Tester component repositories that are registered
with the component manager, run:
$ {command}
"""
}
@staticmethod
def Args(parser):
"""Adds/removes args for this command."""
base.PAGE_SIZE_FLAG.RemoveFromParser(parser)
base.URI_FLAG.RemoveFromParser(parser)
parser.display_info.AddFormat("""
table(
.:label=REPOSITORY,
last_update():label=LAST_UPDATE
)
""")
parser.display_info.AddTransforms(_COMPONENTS_REPOSITORIES_TRANSFORMS)
def Run(self, args):
"""Runs the list command."""
repos = update_manager.UpdateManager.GetAdditionalRepositories()
return repos if repos else []
def Epilog(self, resources_were_displayed):
if not resources_were_displayed:
log.status.write(
'You have no registered component repositories. To add one, run:\n'
' $ gcloud components repositories add URL\n\n')

View File

@@ -0,0 +1,109 @@
# -*- coding: utf-8 -*- #
# Copyright 2013 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 command to list installed/available gcloud components."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.components import completers
from googlecloudsdk.core import log
from googlecloudsdk.core import properties
from googlecloudsdk.core.console import console_io
from googlecloudsdk.core.updater import update_manager
class Remove(base.SilentCommand):
"""Remove a registered Trusted Test component repository.
"""
detailed_help = {
'DESCRIPTION': """\
Remove a registered Trusted Tester component repository from the list
of repositories used by the component manager. After removing a
repository, you can run:
$ gcloud components update
to revert back to the standard version of any components that were
installed from that repository.
""",
'EXAMPLES': """\
To be prompted for registered Trusted Tester component repositories to
remove run:
$ gcloud components repositories remove
""",
}
@staticmethod
def Args(parser):
parser.add_argument(
'url',
nargs='*',
metavar='URL',
completer=completers.RepoCompleter,
help='Zero or more URLs for the component repositories you want to '
'remove. If none are given, you will be prompted to choose which '
'existing repository you want to remove.')
parser.add_argument('--all', action='store_true',
help='Remove all registered repositories.')
def Run(self, args):
"""Runs the remove command."""
repos = update_manager.UpdateManager.GetAdditionalRepositories()
removed_repos = []
# Removing all URLs.
if args.all:
removed_repos.extend(repos)
repos = []
# Specifying URLs to remove explicitly.
elif args.url:
if not repos:
raise update_manager.NoRegisteredRepositoriesError(
'You have no registered repositories.')
for url in args.url:
if url not in repos:
raise exceptions.InvalidArgumentException(
'url',
'URL [{0}] was not a known registered repository.'.format(url))
for url in args.url:
repos.remove(url)
removed_repos.extend(args.url)
# No URL specified, prompt to choose one.
else:
if not repos:
raise update_manager.NoRegisteredRepositoriesError(
'You have no registered repositories.')
result = console_io.PromptChoice(
repos, default=None,
message='Which repository would you like to remove?')
if result is None:
log.status.Print('No repository was removed.')
else:
removed_repos.append(repos.pop(result))
if removed_repos:
properties.PersistProperty(
properties.VALUES.component_manager.additional_repositories,
','.join(repos) if repos else None,
scope=properties.Scope.INSTALLATION)
for removed_repo in removed_repos:
log.status.Print('Removed repository: [{repo}]'.format(repo=removed_repo))
return removed_repos