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,42 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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.
"""gcloud supplementary help topic command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA,
base.ReleaseTrack.ALPHA)
class Topic(base.Group):
"""gcloud supplementary help.
The {command} command group provides supplementary help for topics not
directly associated with individual commands.
More information on {command} can be found by running:
$ gcloud topic [TOPIC_NAME]
For a list of available topics run:
$ gcloud topic --help
"""
category = base.SDK_TOOLS_CATEGORY

View File

@@ -0,0 +1,45 @@
# -*- 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.
"""Extra help for .gcloudignore."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class AccessibilityHelp(base.TopicCommand):
r"""Reference for `Accessibility` features.
The `accessibility/screen_reader` property when set to true will change some
behavior to make gcloud more screen reader friendly. Currently the following
changes are implemented:
* For progress trackers, instead of unicode spinners, the phrase 'working'
is displayed on stderr, every second while gcloud is working.
* For progress bars, progress is displayed as a percentage, outputted to
stderr.
* For boxed tables, instead of the queried resources being displayed in tables
drawn in Unicode, results are rendered as a flattened list of items.
Also consider using the --format flag to define your own format.
To turn this on, run:
$ gcloud config set accessibility/screen_reader true
Accessibility support is still in early stages. Please report any issues that
you would like fixed using `gcloud feedback`.
"""

View File

@@ -0,0 +1,198 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Gcloud firebase test argument files supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class TestingArgFiles(base.TopicCommand):
"""Supplementary help for arg-files to be used with *gcloud firebase test*."""
# pylint: disable=line-too-long
detailed_help = {
'DESCRIPTION':
"""\
{description}
All *gcloud firebase test android run* arguments may be specified by
flags on the command line and/or via a YAML-formatted _ARG_FILE_. The
optional, positional ARG_SPEC argument on the command line is used to
specify a single _ARG_FILE_:_ARG_GROUP_NAME_ pair, where _ARG_FILE_ is
the path to the YAML argument file, and _ARG_GROUP_NAME_ is the name
of the argument group to load and parse. The _ARG_FILE_ must contain
valid YAML syntax or gcloud will respond with an error.
The basic format of a YAML argument file is:
arg-group1:
arg1: value1 # a comment
arg2: value2
...
# Another comment
arg-group2:
arg3: value3
...
List arguments may be specified within square brackets:
directories-to-pull: [/sdcard/dir1, /data/dir2]
or by using the alternate YAML list notation with one dash per list
item:
```
directories-to-pull:
- /sdcard/dir1
- /data/dir2
```
If a list argument only contains a single value, you may omit the
square brackets:
directories-to-pull: /sdcard/dir1
Composition
A special *include: [_ARG_GROUP1_, ...]* syntax allows merging or
composition of argument groups (see *EXAMPLES* below). Included
argument groups can *include:* other argument groups within the
same YAML file, with unlimited nesting.
Precedence
An argument which appears on the command line has the highest
precedence and will override the same argument if it is specified
within an argument file.
Any argument defined directly within a group will have higher
precedence than an identical argument which is merged into that
group using the *include:* keyword.
""",
'EXAMPLES':
"""\
Here are the contents of a very simple YAML argument file which
is assumed to be stored in a file named excelsior_args.yaml:
# Run a quick 'robo' test on the 'Excelsior' app for
# 90 seconds using only the default Test Lab device.
quick-robo-test:
app: path/to/excelsior.apk
type: robo
max-steps: 100
timeout: 90s
async: true
To invoke this test, run:
$ gcloud firebase test android run excelsior_args.yaml:quick-robo-test
To select which device(s) you wish to test against in an argument
file, use *device:* to specify one or more devices, with each device
having one or more dimensions. For example, to specify the LG G3
device in the Chinese locale and with landscape orientation, use:
single-device-group:
device: [{model: g3, orientation: landscape, locale: zh}]
To specify multiple devices, use any of the following equivalent YAML
formats:
multi-device-group1:
device: [{model: flo}, {model: g3, version: 19, locale: zh}, {model: mako, version: 21}]
multi-device-group2:
device:
- {model: flo}
- {model: g3, version: 19, locale: zh}
- {model: mako, version: 21}
multi-device-group3:
device:
- model: flo
- model: g3
version: 19
locale: zh
- model: mako
version: 21
If your app has a login screen, or has additional UI elements which
require input text, you may specify the resource names of the Android
target UI elements, along with their corresponding input values, in
the 'robo-directives' map argument. You may also specify the elements
which the Robo test should prioritize clicking. In the example below,
"username_resource" is the resource name of the username field and
"username" is the input for that field (similarly for password), and
"signin_button_resource" is the resource name of the sign in button.
# Run a 'robo' test on the 'Excelsior' app with login credentials.
robo-test-with-login:
app: path/to/excelsior.apk
type: robo
robo-directives:
"text:username_resource": username
"text:password_resource": password
"click:sigin_button_resource": ""
Assuming the above YAML text is appended to the arg-file named
excelsior_args.yaml, you may invoke the test by running:
$ gcloud firebase test android run excelsior_args.yaml:robo-test-with-login
Here is a slightly more complicated example which demonstrates
composition of argument groups using the legacy device dimension
arguments (*device:* is now the preferred way to specify test
devices). Assume the following YAML text is appended to the arg-file
shown above named excelsior_args.yaml:
# Specify some unit tests to be run against a test matrix
# with one device type, two Android versions, and four
# locales, for a total of eight test variations (1*2*4).
unit-tests:
type: instrumentation
app: path/to/excelsior.apk
test: path/to/excelsior-test.apk # the unit tests
timeout: 10m
device-ids: NexusLowRes
include: [supported-versions, supported-locales]
supported-versions:
os-version-ids: [21, 22]
supported-locales:
locales: [en, es, fr, it]
To invoke this test matrix, run:
$ gcloud firebase test android run excelsior_args.yaml:unit-tests
To run these unit tests with the same locales and os-version-ids,
but substituting a sampling of three physical Android devices
instead of the single virtual NexusLowRes device, run:
$ gcloud firebase test android run excelsior_args.yaml:unit-tests --device-ids shamu,htc_m8,g3
In the last example, the --device-ids argument on the
command line overrides the device-ids: specification inside the
arg-file because command-line arguments have higher precedence.
""",
}

View File

@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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.
"""CLI trees supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
# NOTE: If the name of this topic is modified, please make sure to update all
# references to it in error messages and other help messages as there are no
# tests to catch such changes.
class CliTrees(base.TopicCommand):
"""CLI trees supplementary help.
CLI trees are static nested dictionaries that describe all of the groups,
commands, flags, positionals, help text, and completer module paths for a
CLI. A CLI tree is often much faster to load and access than one generated
at runtime from an active CLI. It is also a more compact representation.
A properly formed CLI tree can be used to reproduce the help documentation
for an entire CLI.
### CLI Tree Data Files
A CLI tree is a dictionary in a JSON file. By convention, the file base name
is the corresponding CLI name. For example, the CLI tree file name for
*gcloud* is *gcloud.json*.
CLI trees associated with Google Cloud CLI modules are installed in the
*data/cli* subdirectory of the Google Cloud CLI installation root:
$(gcloud info --format="value(installation.sdk_root)")/data/cli
This includes tree data for *gcloud* (core component), *bq*, *gsutil*,
and *kubectl*. Note that the tree data is installed with the component.
If the component is not installed then neither is its CLI tree. An installed
component does not require its CLI tree to run. Only the *gcloud* CLI
tree is required by `$ gcloud alpha interactive`.
By default, CLI trees for other commands are JSON files generated on demand
from their *man*(1) or *man7.org* man pages. They are cached in the *cli*
subdirectory of the global config directory:
$(gcloud info --format="value(config.paths.global_config_dir)")/cli
### The gcloud CLI Tree
The *gcloud* CLI tree is used for static TAB completion, the corpus for
`$ gcloud alpha help-search`, and the data source for
`$ gcloud alpha interactive` completions and help text generation.
### Other CLI Trees
`$ gcloud alpha interactive` uses CLI tree data files for typeahead,
command line completion and active help. A few CLI trees are installed
with their respective Google Cloud CLI components: *gcloud* (core component),
*bq*, *gsutil*, and *kubectl*.
The generated trees are a close approximation. You can construct your own,
especially for hierarchical CLIs like *git*(1) that are hard to extract
from man pages.
### CLI Tree Schema
TBD (`gcloud interactive` is still in ALPHA).
"""

View File

@@ -0,0 +1,85 @@
# -*- 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.
"""Client certificate authorization supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
IAP_TUNNEL_SERVICE = 'iap_tunnel'
START_IAP_TUNNEL_COMMAND = 'gcloud compute start-iap-tunnel'
class ClientCert(base.TopicCommand):
"""Client certificate authorization supplementary help."""
detailed_help = {
'DESCRIPTION':
"""\
Client certificate authorization supplementary help.
Device Certificate Authorization (DCA) enables Context-aware access to
identify devices by their X.509 certificates. DCA for Google Cloud
APIs is the second in a series of releases that provides
administrators the capability to protect access to their Google
Cloud resources with device certificates. This feature builds
on top of the existing Context-aware access suite (Endpoint
Verification, Access Context Manager, and VPC Service Controls) and
ensures that only users on trusted devices with a Google-generated
certificate are able to access Google Cloud APIs. This
provides a stronger signal of device identity (device certificate
verification), and protects users from credential theft to accidental
loss by only granting access when credentials and the original device
certificate are presented.
To use this feature, organizations can follow the instructions below to
install an endpoint verification agent to devices:
* Automatically deploy endpoint verification (https://support.google.com/a/answer/9007320#)
* Via Chrome Policy for the extension
* 3rd party image/software distribution tools for the Native Helper on macOS
and Windows
* Let users install endpoint verification themselves from the Chrome Webstore
(https://support.google.com/a/users/answer/9018161#install)
* Users would also be prompted to install the Native Helper as well
For a greater level of security, operating system key stores can be used to store client
certificate objects. This feature is enabled by using [enterprise-certificate-proxy](https://github.com/googleapis/enterprise-certificate-proxy).
enterprise-certificate-proxy can be installed by running `$ gcloud components install enterprise-certificate-proxy`.
In order to use enterprise-certificate-proxy it must first be configured. By default the configuration should be written to `~/.config/gcloud/certificate_config.json`.
The enterprise-certificate-proxy schema is documented on the [GitHub project page](https://github.com/googleapis/enterprise-certificate-proxy#certificate-configuration). Each operating system that gcloud supports uses a different key store. The certificate_config may contain multiple OS configurations.
Provisioning the key stores is not in scope for this document.
Run ``$ gcloud config set context_aware/use_client_certificate True''
so that the gcloud CLI will load the certificate and send it to services.
See https://cloud.google.com/sdk/gcloud/reference/topic/client-certificate
for the support list for the latest version of the gcloud CLI. Please upgrade
the gcloud command-line tool if necessary.
Note: {iap_tunnel_service} is a special service gcloud CLI uses to create the
IAP tunnel. For example, ``{start_iap_tunnel_command}'' can start a tunnel to
Cloud Identity-Aware Proxy through which another process can create a connection
(e.g. SSH, RDP) to a Google Compute Engine instance. Client certificate
authorization is supported in tunnel creation.""".format(
iap_tunnel_service=IAP_TUNNEL_SERVICE,
start_iap_tunnel_command=START_IAP_TUNNEL_COMMAND)
}

View File

@@ -0,0 +1,193 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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.
"""gcloud command conventions supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
# NOTE: If the name of this topic is modified, please make sure to update all
# references to it in error messages and other help messages as there are no
# tests to catch such changes.
class CommandConventions(base.TopicCommand):
r"""gcloud command conventions supplementary help.
*gcloud* command design follows a common set of principles and conventions.
This document describes them in detail.
Conventions are goals more than rules. Refer to individual command *--help*
for any exceptions.
### Command Hierarchy
*gcloud* commands are organized as a tree with *gcloud* at the root, command
_groups_ in the inner nodes, and _commands_ at the leaf nodes. Each command
group typically contains a set of CRUD commands (*create*, *describe*, *list*,
*update*, *delete*) that operate on a resource for a single API. Group
commands are executable, but only for displaying help.
All groups and commands have a *--help* flag that displays a *man*(1) style
document on the standard output. The display is run through the default pager
if the calling environment specifies one. Help documents are derived from the
running executable, so they are always up to date, even when switching
between multiple release installations.
### Command Line
Every *gcloud* command line follows the same form:
gcloud GROUP GROUP ... COMMAND POSITIONAL ... FLAG ...
Flag and positional arguments can be intermixed but for consistency are
usually displayed positionals first in order, followed by flags in any order.
### Command Usage Notation
Command usage is a shorthand notation that contains the full command name,
the positional arguments, and the flag arguments in group sorted order.
Optional arguments are enclosed in *[ ... ]*. For example:
gcloud foo bar NAME [EXTRA] [--format=FORMAT]
is the usage for the `gcloud foo bar` command with a required
NAME positional argument, an optional EXTRA positional argument, and an
optional *--format* flag argument.
Mutually exclusive arguments are separated by *|*; at most one arg in the
list of mutually exclusive args may be specified:
[ --foo | --bar ]
This means that either *--foo* or *--bar* may be specified, but not both.
Mutually exclusive args may also be _required_, meaning exactly one arg in
the list must be specified. This is denoted by enclosing the args in
*( ... )*:
( --foo | --bar )
Modal argument groups are also supported. If any arg in the group is
specified, then the modal arguments must also be specified. This is denoted
by using *:* to separate the modal args on the left from the other args on
the right:
[ --must-a --must-b : --maybe-c --maybe-d ]
This means that if *--maybe-c* and/or *--maybe-d* are specified then both
*--must-a* and *--must-b* must be specified.
### Positional Arguments
Positional arguments are ordered and must be specified in the order listed
in the command usage and help document argument definition list.
File input arguments usually accept the special name *-* to mean
_read from the standard input_. This can be used only once per command line.
### Flag Arguments
Flag names are lower case with a *--* prefix. Multi-word flags use *-*
(dash) as a word separator. Single character flags are deprecated, rare and
may not be documented at all.
Following UNIX convention, if a flag is repeated on the command line, then
only the rightmost occurrence takes effect, no diagnostic is emitted. This
makes it easy to set up command aliases and wrapper scripts that provide
default flag values; values that can easily be overridden by specifying
them on the alias or wrapper script command line.
### Boolean Flags
Boolean flags have an implied value of *false* or *true*. The presence of
*--foo* sets the flag to *true*. All Boolean flags have a *--no-* prefix
variant. For example, *--no-foo* sets the Boolean *--foo* flag to *false*.
Boolean flags are documented using the positive form. This keeps the style
consistent across all commands, and also makes the meaning of the *--no-*
variant clear. In the case a Boolean flag has a default value of *true*,
the *--no-* variant will appear in the command usage and help text
and like all other *--no-* flags, will set the value of the flag to *false*.
### Valued Flags
Non-Boolean flags have an explicit value. The value can be specified using
*=*:
--flag=value
or by placing the value as the next arg after the flag:
--flag value
The *=* form must be used if _value_ starts with *-*.
The second form requires extra context to determine if *--flag* is
Boolean and *value* is a positional, or if *--flag* is valued and *value*
is its value. Because of the visual ambiguity, usage notation and most
command examples use the first form to make intentions clear. The *=*
form also has a diagnostic bonus: it is an error to specify a value
for a Boolean flag.
### Complex Flag Values
Complex flag values that contain command interpreter special characters may
be difficult to specify on the command line. The *--flags-file*=_YAML-FILE_
flag solves this problem by allowing command line flags to be specified in a
YAML/JSON file. String, numeric, list and dict flag values are specified
using YAML/JSON notation and quoting rules. See $ gcloud topic flags-file
for more information.
### Output
The standard output is for explicit information requested by the command.
Depending on the context, there may be guarantees on the output format
to support deterministic parsing. Certain commands do return resources and
these resources are listed on standard output usually using either a
command-specific table format or the default YAML format.
Moreover, the `--format` flag can be used to change or configure these
default output formats. *yaml*, *json*, and *csv* output *--format* values
guarantee that successful command completion results in standard output data
that can be parsed using the respective format. A detailed explanation of the
capabilities of the `--format` flag can be found with $ gcloud topic formats.
In the case of async commands, or commands run with `--async`, the resource
returned on standard output is an operations resource.
For commands that do not return resources, the output is defined in the
command's `--help`.
The standard error is reserved for diagnostics. In general, the format of
standard error data may change from release to release. Users should not
script against specific content, or even the existence of output to the
standard error at all. The only reliable error indicator is the _exit status_
described below.
Most standard error messaging is also logged to a file that can be accessed
by $ gcloud info `--show-log`.
No *gcloud* command should crash with an uncaught exception. However, if
*gcloud* does crash the stack trace is intercepted and written to the log
file, and a crash diagnostic is written to the standard error.
### Exit Status
Exit status *0* indicates success. For async commands it indicates that the
operation started successfully but may not have completed yet.
Any other exit status indicates an error. Command-specific diagnostics should
explain the nature of the error and how to correct it.
"""

View File

@@ -0,0 +1,122 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Gcloud named configuration files supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.core import properties
class TestingArgFiles(base.TopicCommand):
"""Supplementary help for named configurations.
gcloud properties can be stored in *named configurations*, which
are collections of key-value pairs that influence the behavior of
gcloud.
Named configurations are intended to be an advanced feature,
and you can probably ignore them entirely if you only work with one
project.
Properties that are commonly stored in configurations include
default Google Compute Engine zone, verbosity level, project ID, and
active user or service account. Configurations allow you to define
and enable these and other settings together as a group.
Configuration data is typically stored in $HOME/.config/gcloud,
you can override this location by setting the environment variable
CLOUDSDK_CONFIG. This can be useful if $HOME points to a read only
filesystem or you are running commands inside docker.
Configurations are especially useful if you:
- Work with multiple projects. You can create a separate
configuration for each project.
- Use multiple accounts, for example, a user account and a
service account, etc.
- Perform generally orthogonal tasks (work on an appengine app in
project foo, administer a Google Compute Engine cluster in zone
user-central-1a, manage the network configurations for region
asia-east-1, etc.)
Property information stored in named configurations are readable by
all gcloud commands and may be modified by `gcloud config set`
and `gcloud config unset`.
# Creating configurations
Named configurations may be defined by users or built into gcloud.
User defined configurations have lowercase names, such as
'johndoe', 'default', 'jeff-staging', or 'foo2'. These are defined
by the following regular expression: ```^[a-z][-a-z0-9]*$```
Additionally there is a builtin configuration named NONE that has
no properties set.
The easiest way to create a brand new configuration is by
running
$ gcloud init
This will guide you through setting up your first named configuration,
creating a new named configuration, or reinitializing an existing
named configuration. (Note: reinitializing an existing configuration
will remove all its existing properties!)
You can create a new empty configuration with
$ gcloud config configurations create my-config
# Using configurations
gcloud may have at most one *active* configuration which provides
property values. Inactive configurations have no effect on
gcloud executions.
You can activate a configuration with
$ gcloud config configurations activate my-config
To display the path of the active configuration, run:
$ gcloud info --format="get(config.paths.active_config_path)"
Note that changes to your OS login, Google Cloud Platform account or project
could change the path.
You can view and change the properties of your active configuration
using the following commands:
$ gcloud config list
$ gcloud config set
Additionally, commands under `gcloud config configurations`
allow you to to list, activate, describe, and delete configurations
that may or may not be active.
You can activate a configuration for a single gcloud invocation using
flag, `--configuration my-config`, or environment variable
`CLOUDSDK_ACTIVE_CONFIG_NAME=my-config`.
## AVAILABLE PROPERTIES
{properties}
"""
detailed_help = {'properties': properties.VALUES.GetHelpString()}

View File

@@ -0,0 +1,169 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Date/time input format supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
# NOTE: If the name of this topic is modified, please make sure to update all
# references to it in error messages and other help messages as there are no
# tests to catch such changes.
class DateTimes(base.TopicCommand):
"""Date/time input format supplementary help.
*gcloud* command line flags and filter expressions that expect date/time
string values support common input formats. These formats fall into two main
categories: absolute date/times and relative durations.
### Absolute date/time formats
Absolute date/time input formats minimally support
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) and
[RFC 822](https://www.rfc-editor.org/rfc/rfc0822.txt) date/times. When omitted
the date/time value defaults are:
* year, month, day - current value
* hour, minute, second, fractional second - 0
The supported absolute date/time input formats are listed here.
ISO 8601 / RFC 3339 zulu:
2003-09-25T10:49:41.519Z
2003-09-25T10:49:41Z
ISO 8601 numeric timezone offset:
2003-09-25T10:49:41.5-0000
2003-09-25T10:49:41.5-03:00
2003-09-25T10:49:41.5+0300
ISO with omitted parts:
2003-09-25T10:49:41
2003-09-25T10:49
2003-09-25T10
2003-09-25
RFC 822:
Thu, 25 Sep 2003 10:49:41 -0300
UNIX date command, explicit timezone:
Thu Sep 25 10:36:28 EDT 2003
2003 10:36:28 EDT 25 Sep Thu
local timezone:
Thu Sep 25 10:36:28 2003
omitted parts (date parts default to the current date, time parts default
to 0):
Thu Sep 25 10:36:28
Thu Sep 10:36:28
Thu 10:36:28
Thu 10:36
10:36
omitted parts with different order:
Thu Sep 25 2003
Sep 25 2003
Sep 2003
Sep
2003
ISO no separators:
20030925T104941.5-0300
20030925T104941-0300
20030925T104941
20030925T1049
20030925T10
20030925
no T separator:
20030925104941
200309251049
other date orderings:
2003-09-25
2003-Sep-25
25-Sep-2003
Sep-25-2003
09-25-2003
other date separators:
2003.Sep.25
2003/09/25
2003 Sep 25
2003 09 25
### Relative duration date/time formats
A relative duration specifies a date/time relative to the current time.
Relative durations are based on
[ISO 8601 durations](https://en.wikipedia.org/wiki/ISO_8601#Durations).
They are case-insensitive and must be prefixed with +P or -P.
A fully qualified duration string contains year, month, day, hour, minute,
second, and fractional second parts. Each part is a number followed by a
single character suffix:
* P - period (the duration designator)
* Y - year
* M - minute if after T or H, month otherwise
* D - day
* T - separates date parts from time parts
* H - hour
* M - minute if after T or H, month otherwise
* S - second (for fractional seconds, use decimal value for seconds)
At least one part must be specified. Omitted parts default to 0.
-P1Y2M3DT4H5M6.7S
+p1y2m3dT4h5m6.7s
A relative duration may be used in any context that expects a date/time
string.
For example:
* 1 month ago: -p1m
* 30 minutes from now: +pt30m
* 2 hours and 30 minutes ago: -p2h30m
### Absolute duration formats
An absolute duration specifies a period of time. It has the same syntax as
a relative duration except that there is no leading *+* or *-*, and the
leading *P* is optional.
For example:
* 1 month: 1m
* 1 hour 30 minutes: 1h30m
* 30 minutes: t30m
"""

View File

@@ -0,0 +1,73 @@
# -*- 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.
"""gcloud endpoint override supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
# NOTE: If the name of this topic is modified, please make sure to update all
# references to it in error messages and other help messages as there are no
# tests to catch such changes.
class EndpointOverride(base.TopicCommand):
# pylint: disable=line-too-long
r"""gcloud endpoint override supplementary help.
Use API endpoint overrides to override the API endpoints used by the `gcloud`
CLI. Applications such as Private Google Access and Private Service Connect
use API endpoint overrides.
# Setting API endpoint overrides
`gcloud` API endpoints are defined as `gcloud` CLI properties and can be
overridden through `gcloud` CLI properties or environment variables. For
example, to override the API endpoint for the `gcloud storage` command to use
the private `storage-vialink1.p.googleapis.com` endpoint with either `http://`
or `https://` prefix, you can use one of the following commands:
# Override using a property:
$ gcloud config set api_endpoint_overrides/storage https://storage-vialink1.p.googleapis.com/
# Override using an environment variable
$ CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE=https://storage-vialink1.p.googleapis.com/
gcloud storage objects list gs://my-bucket
# Default API endpoints
To get the default value for an API endpoint override, use `gcloud config get`
to determine the correct format for your API endpoint override:
$ gcloud config get api_endpoint_overrides/storage
# Unsetting API endpoint overrides
To unset an API endpoint override, use `gcloud config unset`:
$ gcloud config unset api_endpoint_overrides/storage
# Configured API endpoint overrides
To see the APIs which have an endpoint override set, use `gcloud config list`:
$ gcloud config list api_endpoint_overrides/
To see all the set and unset API endpoint override properties, use the `--all`
flag:
$ gcloud config list api_endpoint_overrides/ --all
"""

View File

@@ -0,0 +1,106 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Resource escaping supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
# NOTE: If the name of this topic is modified, please make sure to update all
# references to it in error messages and other help messages as there are no
# tests to catch such changes.
class Escaping(base.TopicCommand):
"""List/dictionary-type argument escaping supplementary help."""
detailed_help = {
'DESCRIPTION': """\
{description}
*gcloud* supports list-type and dictionary-type flags that take one
argument which is a list of one or more comma-separated items:
--list-flag=value1,value2,value3
--dict-flag=key1=value1,key2=value2
In the case of a dict-type flag, each item is a key-value pair
separated by '='. If more than one '=' is present, the first is used.
In order to include commas in your arguments, specify an alternate
delimiter using the following syntax:
^DELIM^flag value, with comma
where _DELIM_ is a sequence of one or more characters that may not
appear in any value in the list.
NOTE: In cmd.exe and PowerShell on Windows, `^` is a special character
and you must escape it by repeating it. In the following examples,
every time you see `^`, replace it with `^^^^`.
""",
'EXAMPLES': """\
In these examples, a list-type or dictionary-type flag is given, along
with a shell comment explaining how it is parsed. The parsed flags are
shown here using Python-style list or dict formats (in other
languages, what Python calls "dicts" are often called "associative
arrays," "maps," or "hashes").
Basic example:
--list-flag=^:^a,b:c,d # => ['a,b', 'c,d']
Multi-character delimiters are allowed:
--list-flag=^--^a-,b--c # => ['a-,b', 'c']
Just one '^' has no special meaning:
--list-flag=^a,b,c # => ['^a', 'b', 'c']
This is an alternative way of starting with '^':
--list-flag=^,^^a,b,c # => ['^a', 'b', 'c']
A '^' anywhere but the start has no special meaning:
--list-flag=a^:^,b,c # => ['a^:^', 'b', 'c']
Dictionary-type arguments work exactly the same as list-type
arguments:
--dict-flag=^:^a=b,c:d=f,g # => {'a': 'b,c', 'd': 'f,g'}
To reserve ephemeral IP addresses, passed in as a list, which are
being used by virtual machine instances in the us-central1 region,
run:
$ gcloud compute addresses create \
--addresses ^:^123.456.789.198:22.333.146.189:789.312.645 \
--region us-central1
To create a Google Compute Engine virtual machine instance
with metadata as a list ({'key1': '"value1"', 'key2': 'value2',
'key3': 'value3Index1,value3Index2', 'key4': 'value4'), run:
$ gcloud compute instances create example-instance1 \
--metadata ^:^key1="value1":key2=value2:key3=value3Index1,value3Index2,valueIndex3:key4=value4
""",
}

View File

@@ -0,0 +1,325 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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.
"""Resource filters supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.calliope import base
from googlecloudsdk.core.resource import resource_topics
class Filters(base.TopicCommand):
"""Resource filters supplementary help."""
detailed_help = {
'DESCRIPTION':
textwrap.dedent("""\
{description}
+
Note: Depending on the specific server API, filtering may be done
entirely by the client, entirely by the server, or by a combination
of both.
### Filter Expressions
A filter expression is a Boolean function that selects the resources
to print from a list of resources. Expressions are composed
of terms connected by logic operators.
*LogicOperator*::
Logic operators must be in uppercase: *AND*, *OR*, *NOT*.
Additionally, expressions containing both *AND* and *OR* must be
parenthesized to disambiguate precedence.
*NOT* _term-1_:::
True if _term-1_ is False, otherwise False.
_term-1_ *AND* _term-2_:::
True if both _term-1_ and _term-2_ are true.
_term-1_ *OR* _term-2_:::
True if at least one of _term-1_ or _term-2_ is true.
_term-1_ _term-2_:::
Term conjunction (implicit *AND*) is True if both _term-1_
and _term-2_ are true. Conjunction has lower precedence than *OR*.
*Terms*::
A term is a _key_ _operator_ _value_ tuple, where _key_ is a dotted
name that evaluates to the value of a resource attribute, and _value_
may be:
*number*::: integer or floating point numeric constant
*unquoted literal*::: character sequence terminated by space, ( or )
*quoted literal*::: _"..."_ or _'...'_
Most filter expressions need to be quoted in shell commands. If you
use _'...'_ shell quotes then use _"..."_ filter string literal quotes
and vice versa.
Quoted literals will be interpreted as string values, even when the
value could also be a valid number. For example, 'key:1e9' will be
interpreted as a key named 'key' with the string value '1e9', rather
than with the float value of one billion expressed in scientific
notation.
*Operator Terms*::
_key_ *:* _simple-pattern_:::
*:* operator evaluation is changing for consistency across Google
APIs. The current default is deprecated and will be dropped shortly.
A warning will be displayed when a --filter expression would return
different matches using both the deprecated and new implementations.
+
The current deprecated default is True if _key_ contains
_simple-pattern_. The match is case insensitive. It allows one
```*``` that matches any sequence of 0 or more characters.
If ```*``` is specified then the match is anchored, meaning all
characters from the beginning and end of the value must match.
+
The new implementation is True if _simple-pattern_ matches any
_word_ in _key_. Words are locale specific but typically consist of
alpha-numeric characters. Non-word characters that do not appear in
_simple-pattern_ are ignored. The matching is anchored and case
insensitive. An optional trailing ```*``` does a word prefix match.
+
Use _key_```:*``` to test if _key_ is defined and
```-```_key_```:*``` to test if _key_ is undefined.
_key_ *:(* _simple-pattern_ ... *)*:::
True if _key_ matches any _simple-pattern_ in the
(space, tab, newline, comma) separated list.
_key_ *=* _value_:::
True if _key_ is equal to _value_, or [deprecated] equivalent to *:*
with the exception that the trailing ```*``` prefix match is not
supported.
+
For historical reasons, this operation currently behaves differently
for different Google APIs. For many APIs, this is True if key is
equal to value. For a few APIs, this is currently equivalent to *:*,
with the exception that the trailing ```*``` prefix match is not
supported. However, this behaviour is being phased out, and use of
```=``` for those APIs is deprecated; for those APIs, if you want
matching, you should use ```:``` instead of ```=```, and if you want
to test for equality, you can use
_key_ <= _value_ AND _key_ >= _value_.
_key_ *=(* _value_ ... *)*:::
True if _key_ is equal to any _value_ in the
(space, tab, newline, *,*) separated list.
_key_ *!=* _value_:::
True if _key_ is not _value_. Equivalent to
-_key_=_value_ and NOT _key_=_value_.
_key_ *<* _value_:::
True if _key_ is less than _value_. If both _key_ and
_value_ are numeric then numeric comparison is used, otherwise
lexicographic string comparison is used.
_key_ *<=* _value_:::
True if _key_ is less than or equal to _value_. If both
_key_ and _value_ are numeric then numeric comparison is used,
otherwise lexicographic string comparison is used.
_key_ *>=* _value_:::
True if _key_ is greater than or equal to _value_. If
both _key_ and _value_ are numeric then numeric comparison is used,
otherwise lexicographic string comparison is used.
_key_ *>* _value_:::
True if _key_ is greater than _value_. If both _key_ and
_value_ are numeric then numeric comparison is used, otherwise
lexicographic string comparison is used.
_key_ *~* _value_:::
True if _key_ contains a match for the RE (regular expression) pattern
_value_. Depending on your shell, you might have to escape or quote
_~_ to ensure it isn't consumed as HOME.
_key_ *!~* _value_:::
True if _key_ does not contain a match for the RE (regular expression)
pattern _value_. Depending on your shell, you might have to escape or
quote _~_ to ensure it isn't consumed as HOME.
Regular expressions are evaluated using Python's standard library:
https://docs.python.org/3/library/re.html#re-syntax.
### Determine which fields are available for filtering
In order to build filters, it is often helpful to review some
representative fields returned from commands. One simple way to do
this is to add `--format=yaml --limit=1` to a command. With these
flags, a single record is returned and its full contents are displayed
as a YAML document. For example, a list of project fields could be
generated by running:
$ gcloud projects list --format=yaml --limit=1
This might display the following data:
```yaml
createTime: '2021-02-10T19:19:49.242Z'
lifecycleState: ACTIVE
name: MyProject
parent:
id: '123'
type: folder
projectId: my-project
projectNumber: '456'
```
Using this data, one way of filtering projects is by their parent's ID
by specifying ``parent.id'' as the _key_.
### Filter on a custom or nested list in response
By default the filter expression operates on root level resources.
In order to filter on a nested list(not at the root level of the json)
, one can use the `--flatten` flag to provide a the `resource-key` to
list. For example, To list members under `my-project` that have an
editor role, one can run:
$ gcloud projects get-iam-policy cloudsdktest --flatten=bindings --filter=bindings.role:roles/editor --format='value(bindings.members)'
""").format(
description=resource_topics.ResourceDescription('filter')),
'EXAMPLES':
textwrap.dedent("""\
List all Google Compute Engine instance resources:
$ gcloud compute instances list
List Compute Engine instance resources that have machineType
*f1-micro*:
$ gcloud compute instances list --filter="machineType:f1-micro"
List Compute Engine instance resources using a regular expression for
zone *us* and not MachineType *f1-micro*:
$ gcloud compute instances list --filter="zone ~ us AND -machineType:f1-micro"
List Compute Engine instance resources with tag *my-tag*:
$ gcloud compute instances list --filter="tags.items=my-tag"
List Compute Engine instance resources with tag *my-tag* or
*my-other-tag*:
$ gcloud compute instances list --filter="tags.items=(my-tag,my-other-tag)"
List Compute Engine instance resources with tag *my-tag* and
*my-other-tag*:
$ gcloud compute instances list --filter="tags.items=my-tag AND tags.items=my-other-tag"
List Compute Engine instance resources which either have tag *my-tag*
but not *my-other-tag* or have tag *alternative-tag*:
$ gcloud compute instances list --filter="(tags.items=my-tag AND -tags.items=my-other-tag) OR tags.items=alternative-tag"
List Compute Engine instance resources which contain the key *fingerprint*
in the *metadata* object:
$ gcloud compute instances list --limit=1 --filter="metadata.list(show="keys"):fingerprint"
List Compute Engine instance resources with label *my-label* with any
value:
$ gcloud compute instances list --filter="labels.my-label:*"
List Container Registry images that have a tag with the value
'30e5504145':
$ gcloud container images list-tags --filter="'tags:30e5504145'"
The last example encloses the filter expression in single quotes
because the value '30e5504145' could be interpreted as a number in
scientific notation.
List in JSON format those projects where the labels match specific
values (e.g. label.env is 'test' and label.version is alpha):
$ gcloud projects list --format="json" --filter="labels.env=test AND labels.version=alpha"
List projects that were created on and after a specific date:
$ gcloud projects list --format="table(projectNumber,projectId,createTime)" --filter="createTime>=2018-01-15"
List projects that were created on and after a specific date and time
and sort from oldest to newest (with dates and times listed according
to the local timezone):
$ gcloud projects list --format="table(projectNumber,projectId,createTime.date(tz=LOCAL))" --filter="createTime>=2018-01-15T12:00:00" --sort-by=createTime
List projects that were created within the last two weeks, using
ISO8601 durations:
$ gcloud projects list --format="table(projectNumber,projectId,createTime)" --filter="createTime>-P2W"
For more about ISO8601 durations, see: https://en.wikipedia.org/wiki/ISO_8601
+
The table below shows examples of pattern matching if used with
the `:` operator:
PATTERN | VALUE | MATCHES | DEPRECATED_MATCHES
--- | --- | --- | ---
abc* | abcpdqxyz | True | True
abc | abcpdqxyz | False | True
pdq* | abcpdqxyz | False | False
pdq | abcpdqxyz | False | True
xyz* | abcpdqxyz | False | False
xyz | abcpdqxyz | False | True
* | abcpdqxyz | True | True
* | (None) | False | False
* | ('') | False | False
* | (otherwise) | True | True
abc* | abc.pdq.xyz | True | True
abc | abc.pdq.xyz | True | True
abc.pdq | abc.pdq.xyz | True | True
pdq* | abc.pdq.xyz | True | False
pdq | abc.pdq.xyz | True | True
pdq.xyz | abc.pdq.xyz | True | True
xyz* | abc.pdq.xyz | True | False
xyz | abc.pdq.xyz | True | True
"""),
}

View File

@@ -0,0 +1,117 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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.
"""--flags-file=YAML_FILE supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
# NOTE: If the name of this topic is modified, please make sure to update all
# references to it in error messages and other help messages as there are no
# tests to catch such changes.
@base.UniverseCompatible
class CommandConventions(base.TopicCommand):
r"""--flags-file=YAML_FILE supplementary help.
The *--flags-file*=_YAML-FILE_ flag, available to all *gcloud* commands,
supports complex flag values in any command interpreter.
Complex flag values that contain command interpreter special characters may
be difficult to specify on the command line. The combined list of _special_
characters across commonly used command interpreters (shell, cmd.exe,
PowerShell) is surprisingly large. Among them are ```", ', `, *, ?, [, ],
(, ), $, %, #, ^, &, |, {, }, ;, \, <, >,``` _space_, _tab_, _newline_.
Add to that the separator characters for *list* and *dict* valued flags,
and it becomes all but impossible to construct portable command lines.
The *--flags-file*=_YAML-FILE_ flag solves this problem by allowing
command line flags to be specified in a YAML/JSON file. String, numeric, list
and dict flag values are specified using YAML/JSON notation and quoting rules.
Flag specification uses dictionary notation. Use a list of dictionaries for
flags that must be specified multiple times.
For example, this YAML file defines values for Boolean, integer, floating
point, string, dictionary and list valued flags:
```yaml
--boolean:
--integer: 123
--float: 456.789
--string: A string value.
--dictionary:
a=b: c,d
e,f: g=h
i: none
j=k=l: m=$n,o=%p
"y:": ":z"
meta:
- key: foo
value: bar
- key: abc
value: xyz
--list:
- a,b,c
- x,y,z
```
If the file is named *my-flags.yaml* then the command line flag
*--flags-file=my-flags.yaml* will set the specified flags on any system
using any command interpreter. *--flags-file* may be specified in a YAML
file, and its value can be a YAML list to reference multiple files.
This example specifies the *--metadata* flag multiple times:
```yaml
- --metadata: abc
--integer: 123
- --metadata: xyz
```
Each *--flags-file* arg is replaced by its contents, so normal flag
precedence applies. For example, given *flags-1.yaml*:
```yaml
--zone: us-east2-a
```
*flags-2.yaml*:
```yaml
--verbosity: info
--zone: us-central1-a
```
and command line:
```
gcloud compute instances describe \
--flags-file=flags-1.yaml my-instance --flags-file=flags-2.yaml
```
the effective command line is:
```
gcloud compute instances describe \
--zone=us-east2-a my-instance --verbosity=info --zone=us-central1-a
```
using zone *us-central1-a* (not *us-east2-a*, because `flags-2.yaml`, to the
right of `flags-1.yaml`, has higher precedence).
"""

View File

@@ -0,0 +1,134 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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.
"""Resource formats supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.calliope import base
from googlecloudsdk.core.resource import resource_topics
class Formats(base.TopicCommand):
"""Resource formats supplementary help."""
detailed_help = {
'DESCRIPTION': textwrap.dedent("""\
{description}
### Formats
A format expression is used to change the default output format of a
command.
Many output formats are available; some for pretty printing
human-readable output and others for returning machine-readable
output.
A format expression has 3 parts:
_NAME_:: _name_
_ATTRIBUTES_:: *[* [no-]_attribute-name_[=_value_] [, ... ] *]*
_PROJECTION_:: *(* _resource-key_ [, ...] *)*
_NAME_ is required, _ATTRIBUTES_ are optional, and _PROJECTIONS_
may be required for some formats. Unknown attribute names are
silently ignored.
Each *gcloud* *list* command has a default format expression. The
*--format* flag can alter or replace the default. For example,
--format="[box]"
adds box decorations to a default table, and
--format=json
lists the resource in *json* format.
{format_registry}
""").format(
description=resource_topics.ResourceDescription('format'),
format_registry=resource_topics.FormatRegistryDescriptions()),
'EXAMPLES': """\
List a table of compute instance resources sorted by *name* with
box decorations and title *Instances*:
$ gcloud compute instances list --format="table[box,title=Instances](name:sort=1, zone:label=zone, status)"
List a nested table of the quotas of a region:
$ gcloud compute regions describe us-central1 --format="table(quotas:format='table(metric,limit,usage)')"
Print a flattened list of global quotas in CSV format:
$ gcloud compute project-info describe --flatten="quotas[]" --format="csv(quotas.metric,quotas.limit,quotas.usage)"
List the disk interfaces for all compute instances as a compact
comma separated list:
$ gcloud compute instances list --format="value(disks[].interface.list())"
List the URIs for all compute instances:
$ gcloud compute instances list --format="value(uri())"
List all compute instances with their creation timestamps displayed
according to the local timezone:
$ gcloud compute instances list --format="table(name,creationTimestamp.date(tz=LOCAL))"
List the project authenticated user email address:
$ gcloud info --format="value(config.account)"
List resources filtered on repeated fields by projecting subfields on
a repeated message:
$ gcloud alpha genomics readgroupsets list --format="default(readGroups[].name)"
Return the scope of the current instance:
$ gcloud compute zones list --format="value(selfLink.scope())"
selfLink is a fully qualified name. (e.g. 'https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a')
The previous example returns a list of just the names of each zone
(e.g. 'us-central1-a'). This is because selfLink.scope() grabs the
last part of the URL segment. To extract selfLink starting from
/projects and return the scope of the current instance:
$ gcloud compute zones list --format="value(selfLink.scope(projects))"
List all scopes enabled for a Compute Engine instance and flatten the
multi-valued resource:
$ gcloud compute instances list --format="flattened(name,serviceAccounts[].email,serviceAccounts[].scopes[].basename())"
Display a multi-valued resource's service account keys with the
corresponding service account, extracting just the first '/' delimited
part with segment(0):
$ gcloud iam service-accounts keys list --iam-account=svc-2-123@test-minutia-123.iam.gserviceaccount.com --project=test-minutia-123 --format="table(name.scope(serviceAccounts).segment(0):label='service Account',name.scope(keys):label='keyID',validAfterTime)"
The last example returns a table with service account names without
their full paths, keyID and validity.
""",
}

View File

@@ -0,0 +1,149 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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.
"""Extra help for .gcloudignore."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class GcloudignoreHelp(base.TopicCommand):
r"""Reference for `.gcloudignore` files.
Several commands in `gcloud` involve uploading the contents of a directory to
Google Cloud to host or build. In many cases, you will not want to
upload certain files (i.e., "ignore" them).
If there is a file called `.gcloudignore` _within the top-level directory
being uploaded_, the files that it specifies (see "SYNTAX") will be ignored.
Gcloud commands may generate a .gcloudignore file; see the individual
command help page for details.
The following `gcloud` commands respect the `.gcloudignore` file:
* `gcloud app deploy`
* Note: If you add `app.yaml` to the `.gcloudignore` file, this command will
fail.
* `gcloud functions deploy`
* `gcloud builds submit`
* `gcloud composer environments storage {dags, data, plugins} import`
* `gcloud container builds submit`
* `gcloud run deploy`
* `gcloud run jobs deploy`
* gcloud alpha deploy releases create
* `gcloud infra-manager deployments apply`
* `gcloud infra-manager previews create`
* `gcloud alpha functions local deploy`
* `gcloud alpha run jobs deploy`
* `gcloud beta run jobs deploy`
* `gcloud alpha run worker-pools deploy`
* `gcloud beta run worker-pools deploy`
To globally disable `.gcloudignore` parsing (including default file-ignore
behavior), run:
$ gcloud config set gcloudignore/enabled false
The default content of the generated `.gcloudignore` file, which can be
overridden with `--ignore-file`, is as follows:
.gcloudignore
.git
.gitignore
## SYNTAX
The syntax of `.gcloudignore` borrows heavily from that of `.gitignore`; see
https://git-scm.com/docs/gitignore or `man gitignore` for a full reference.
Each line in a `.gcloudignore` is one of the following:
* *pattern*: a pattern specifies file names to ignore (or explicitly include)
in the upload. If multiple patterns match the file name, the last matching
pattern takes precedence.
* *comment*: comments begin with `#` and are ignored (see "ADVANCED TOPICS"
for an exception). If you want to include a `#` at the beginning of a
pattern, you must escape it: ```\#```.
* *blank line*: A blank line is ignored and useful for readability.
Some example patterns follow; see the full reference
(https://git-scm.com/docs/gitignore or `man gitignore`) for details.
To ignore any file named `foo`, and any file in the root of the upload
directory named `bar`:
foo
/bar
To ignore any file starting with `foo`, ending with `bar`, or starting with
`baz` and ending with `qux`:
foo*
*bar
baz*qux
To explicitly include any file named `foo` (useful if `foo` was excluded
earlier in the file) and ignore a file named `!bar`:
!foo
\!bar
To ignore any directory `foo` and all its contents (though not a file
`foo`), any file `baz`, and the directory `qux` and all its contents:
foo/
**/baz
qux/**
### ADVANCED TOPICS
In order to ignore files specified in the gitignore file, there is a special
comment syntax:
#!include:.gitignore
This will insert the content of a `.gitignore`-style file named `.gitignore`
at the point of the include line. It does not recurse (that is, the included
file *cannot* `#!include` another file) and cannot be anywhere but the
top-level directory to be uploaded.
To display files that will be uploaded run:
gcloud meta list-files-for-upload
## EXAMPLES
This `.gcloudignore` would prevent the upload of the `node_modules/` directory
and any files ending in `~`:
/node_modules/
*~
This `.gcloudignore` (similar to the one generated when Git files are
present) would prevent the upload of the `.gcloudignore` file, the `.git`
directory, and any files in ignored in the `.gitignore` file:
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or
# files from your .gitignore file, remove the corresponding line below:
.git
.gitignore
#!include:.gitignore
"""

View File

@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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.
"""Supplementary help for setting up gcloud offline help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class OfflineHelp(base.TopicCommand):
"""Setting up gcloud command offline help.
There are many ways to access `gcloud` command help. Only the first requires
online access:
* Browse https://cloud.google.com/sdk/gcloud/reference/ for the most
recent Google Cloud CLI release online documents.
* Add the *--help* flag to any command. This will render a man style
document in a terminal pager. The document is always up to date with the
command because it is generated by collating help text from the command
itself.
* Use the `gcloud beta interactive` shell which has as-you-type help. Like
*--help*, the interactive help documents are always up to date with the
`gcloud` installation.
* Generate HTML documents in a local directory and point your browser to
the generated *index.html* for offline browsing. Hover over a navigation
item to focus the menu, hover to the left to expand it again. More
details on this below.
* Generate and install *man*(1) style documents on a local host. More
details on this below.
All of these methods have the same content, all generated from a Google Cloud
CLI `gcloud` installation. The last two are user maintained and can become out
of date. Either use them for one time offline access, or make them part of
your Google Cloud CLI installation/update routine.
### Generating offline HTML documents
To generate HTML documents for offline browsing:
# Select an empty directory where the HTML and supporting *.css* and
# *.js* files will be generated.
HTML_DIR=<some-local-directory>
# Generate the HTML in $HTML_DIR.
# Should take ~1 min, 10 min or more on slower systems.
gcloud meta generate-help-docs --html-dir=$HTML_DIR
Then enter this URL in the browser address/search bar, where $HTML_DIR
must be the actual path name of the directory:
file://$HTML_DIR/index.html
### Generating offline manpage documents
To generate man page documents for the *man*(1) command:
# Select an empty directory where the man page files will be generated.
MANPAGE_DIR=<some-local-directory>
# Generate the man pages in $MANPAGE_DIR.
# Should take ~1 min, 10 min or more on slower systems.
gcloud meta generate-help-docs --manpage-dir=$MANPAGE_DIR
# Append $MANPAGE_DIR to the MANPATH environment variable:
export MANPATH=$MANPATH:$MANPAGE_dir
Then run the man command on gcloud manpages:
man gcloud info
"""

View File

@@ -0,0 +1,139 @@
# -*- 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.
"""Resource projections supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.core.resource import resource_topics
# pylint: disable=line-too-long
class Projections(base.TopicCommand):
"""Resource projections supplementary help.
{projection_description}
### Projections
A projection is a list of keys that selects resource data values.
Projections are used in *--format* flag expressions. For example, the
*table* format requires a projection that describes the table columns:
table(name, network.ip.internal, network.ip.external, uri())
### Transforms
A *transform* formats resource data values. Each projection key may
have zero or more transform calls:
_key_._transform_([arg...])...
This example applies the *foo*() and then the *bar*() transform to the
*status.time* resource value:
(name, status.time.foo().bar())
{transform_registry}
### Key Attributes
Key attributes control formatted output. Each projection key may have
zero or more attributes:
_key_:_attribute_=_value_...
where =_value_ is omitted for Boolean attributes and no-_attribute_
sets the attribute to false. Attribute values may appear in any order,
but must be specified after any transform calls. The attributes are:
*alias*=_ALIAS-NAME_::
Sets _ALIAS-NAME_ as an alias for the projection key.
*align*=_ALIGNMENT_::
Specifies the output column data alignment. Used by the *table*
format. The alignment values are:
*left*:::
Left (default).
*center*:::
Center.
*right*:::
Right.
*label*=_LABEL_::
A string value used to label output. Use :label="" or :label=''
for no label. The *table* format uses _LABEL_ values as column
headings. Also sets _LABEL_ as an alias for the projection key.
The default label is the disambiguated right hand parts of the
column key name in ANGRY_SNAKE_CASE.
[no-]*reverse*::
Sets the key sort order to descending. *no-reverse* resets to the
default ascending order.
*sort*=_SORT-ORDER_::
An integer counting from 1. Keys with lower sort-order are sorted
first. Keys with same sort order are sorted left to right. Columns are
sorted based on displayed value alone, irrespective of the type of
value(date, time, etc.).
*wrap*[=_MIN-WIDTH_]::
Enables the column text to be wrapped if the table would otherwise
be too wide for the display. The column will be wrapped in the available space
with a minimum width of either the default or of _MIN-WIDTH_ if specified. The
default is 10 characters.
*width*=_COLUMN-WIDTH_::
An integer denoting the width for the column. The default fits the table to
the terminal width or 80 if the output is not a terminal.
## EXAMPLES
List a table of instance *zone* (sorted in descending order) and
*name* (sorted by *name* and centered with column heading *INSTANCE*)
and *creationTimestamp* (listed using the *strftime*(3) year-month-day
format with column heading *START*):
$ gcloud compute instances list --format="table(name:sort=2:align=center:label=INSTANCE, zone:sort=1:reverse, creationTimestamp.date("%Y-%m-%d"):label=START)"
List only the *name*, *status* and *zone* instance resource keys in
YAML format:
$ gcloud compute instances list --format="yaml(name, status, zone)"
List only the *config.account* key value(s) in the *info* resource:
$ gcloud info --format="value(config.account)"
List the *name*, *id*, and *description* of an imaginary *foo* resource,
fixing the *name* column width to 16 characters, wrapping the *id* column with
the default minimum width and the *description* column with a minimum width of
20 characters:
$ gcloud example foo list --format="table(name:width=16, id:wrap, description:wrap=20)"
"""
detailed_help = {
'projection_description':
lambda: resource_topics.ResourceDescription('projection'),
'transform_registry':
resource_topics.TransformRegistryDescriptions,
}

View File

@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*- #
# Copyright 2014 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.
"""Resource keys supplementary help."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import textwrap
from googlecloudsdk.calliope import base
class Keys(base.TopicCommand):
"""Resource keys supplementary help."""
detailed_help = {
'DESCRIPTION': textwrap.dedent("""\
A *resource* is a JSON-serializable object organized as a tree.
Each node is a scalar, indexed array, or dictionary. Structs and
classes are represented by dictionaries indexed by member name.
Each node is reachable by a unique path of names from the root. A
node *key* is the path names separated by '.'. [_number_] represents
an array index. For example:
foo
foo.bar
abc.def[3].ghi
The resource keys and data values for any _gcloud_ _list_
command can be printed by running _gcloud_ ... _list_
*--format=flattened*. See the command specific documentation for
details on specific resource keys.
"""),
'EXAMPLES': textwrap.dedent("""\
This command lists the keys and values for the *regions* resource:
$ gcloud compute regions list --format=flattened
and here is sample output for the command:
---
creationTimestamp: 2013-05-23T07:02:09.522-07:00
description: us-central1
id: 22115839677829654
kind: compute#region
name: us-central1
quotas[0].limit: 24.0
quotas[0].metric: CPUS
quotas[0].usage: 15.0
quotas[1].limit: 5120.0
quotas[1].metric: DISKS_TOTAL_GB
quotas[1].usage: 1416.0
quotas[2].limit: 7.0
quotas[2].metric: STATIC_ADDRESSES
quotas[2].usage: 1.0
quotas[3].limit: 23.0
quotas[3].metric: IN_USE_ADDRESSES
quotas[3].usage: 16.0
quotas[4].limit: 1024.0
quotas[4].metric: SSD_TOTAL_GB
quotas[4].usage: 0.0
quotas[5].limit: 1500.0
quotas[5].metric: LOCAL_SSD_TOTAL_GB
quotas[5].usage: 750.0
selfLink: https://www.googleapis.com/.../us-central1
status: UP
zones[0]: us-central1-a
zones[1]: us-central1-b
zones[2]: us-central1-f
The *list* command produces a resource list. The keys are to the
left of ':' and the values are to the right.
"""),
}

View File

@@ -0,0 +1,112 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Supplementary help for gcloud startup options."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class Startup(base.TopicCommand):
"""Supplementary help for gcloud startup options.
# Choosing a Python Interpreter
The `gcloud` CLI runs under Python. Note that `gcloud` supports Python version
3.9-3.14. Certain Windows and Linux installs include a bundled Python
interpreter depending on the package and architecture. Similarly, Intel-based
Macs offer the option to install CPython as part of the main install script.
Otherwise, you must have a Python interpreter available on your system. The
`gcloud` CLI will attempt to locate an interpreter on your system PATH by
looking for the following binaries:
* python3
* python
If you have a bundled Python installed, it will be preferred. To override this
you will need to set the `CLOUDSDK_PYTHON` environment variable, see below.
Other Python tools shipped in the Google Cloud CLI do not support Python 3 and
require Python 2.7.x, including:
* `dev_appserver`
# Bundled Python on Linux
Linux-based installs include a bundled Python installation on x86_64
architectures. This installation will be used by default. If you want to use a
different Python installation, set the `CLOUDSDK_PYTHON` environment variable
to the absolute path to your python interpreter.
If you have multiple Python interpreters available (including a bundled
python) or if you don't have one on your PATH, you can specify which
interpreter to use by setting the `CLOUDSDK_PYTHON` environment variable. For
example:
# Use the python3 interpreter on your path
$ export CLOUDSDK_PYTHON=python3
# Use a python you have installed in a special location
$ export CLOUDSDK_PYTHON=/usr/local/my-custom-python-install/python
`gsutil` versions 5.0 and later support Python 3.9-3.13. To use a different
interpreter for `gsutil` than for the other Python tools, set the
`CLOUDSDK_GSUTIL_PYTHON` environment variable to the interpreter that you
want.
`bq` versions 2.0.99 and later support Python 3.9-3.14. To use a different
interpreter for `bq` than for the other Python tools, set the
`CLOUDSDK_BQ_PYTHON` environment variable to the interpreter that you want.
# Configuring the Python Interpreter
While not typically necessary, you can pass interpreter level
arguments to the Python running `gcloud` using the `CLOUDSDK_PYTHON_ARGS`
environment variable.
A common use case for this (which has been special-cased) is to enable
'site packages'. This allows Python to pick up libraries from the system (
for example, those that may have been installed with `pip`). Site packages may
be necessary if you require certain native libraries (as is the case if you
work with service accounts using a legacy `.p12` key, for example). To enable
site packages, set `CLOUDSDK_PYTHON_SITEPACKAGES=1`. Note that enabling site
packages may cause conflicts with `gcloud` packaged libraries, depending on
what you have installed on your system.
# Setting Configurations and Properties
Your active configuration can also be set via the environment variable
`CLOUDSDK_ACTIVE_CONFIG_NAME`. This allows you to specify a certain
configuration in a given terminal session without changing the global
default configuration.
In addition to being able to set them via `gcloud config set`,
each `gcloud` property has a corresponding environment variable. They take
the form: `CLOUDSDK_SECTION_PROPERTY`. For example, if you wanted to
change your active project for just one terminal you could run:
$ export CLOUDSDK_CORE_PROJECT=my-project
For more information, see `gcloud topic configurations`.
"""

View File

@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Supplementary help for uninstalling Cloud SDK."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Uninstall(base.TopicCommand):
"""Supplementary help for uninstalling Google Cloud CLI.
# Uninstalling Google Cloud CLI
Note: For installations completed using an OS package (such as `apt-get`,
`yum`, etc.), uninstall Google Cloud CLI via the OS package manager.
Note: For Windows installations, execute the uninstaller.exe found under
your Google Cloud CLI directory.
To completely remove Google Cloud CLI, follow these instructions:
* Locate your installation directory by running:
$ gcloud info --format="value(installation.sdk_root)"
* Locate your user config directory (typically `~/.config/gcloud`
on MacOS and Linux) by running:
$ gcloud info --format="value(config.paths.global_config_dir)"
* Delete both these directories.
* Additionally, remove lines sourcing `completion.bash.inc` and
`paths.bash.inc` in your `.bashrc` or equivalent shell init file,
if you added them during installation.
* Review the contents of the `.boto` file in your home directory and
remove the sections '[GoogleCompute]' and '[GSUtil]'. In addition,
review the sections '[OAuth2]' and '[Credentials]' for settings that
are no longer needed.
* Some systems may have `Cache` directories such as `~/Library/Caches/` on
Mac OS X. Find and delete these directories for your system:
$ find ~/Library/Caches/ -type d -name "google-cloud-sdk" | xargs rm -r
"""