GCLOUD_TOPIC_PROJECTIONS(1)

NAME

gcloud topic projections - resource projections supplementary help

DESCRIPTION
Most gcloud commands return a list of resources on success. By default they are pretty-printed on the standard output. The --format=NAME[ATTRIBUTES](PROJECTION) flag changes the default output: NAME
    The format name.
ATTRIBUTES
    Format specific attributes. For details run $ gcloud topic formats.
PROJECTION
    A list of resource keys that selects the data listed. Resource projections are described in detail below.
resource keys
    Keys are names for resource resource items. For details run $ gcloud topic resource-keys. Most gcloud list commands have a --filter=EXPRESSION flag that selects resources to be listed. For details run $ gcloud topic filters.

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())
The builtin transform functions are: always()
    Marks a transform sequence to always be applied. In some cases transforms are disabled. Prepending always() to a transform sequence causes the sequence to always be evaluated. For example:
        some_field.always().foo().bar() will always apply foo() and then bar().
basename(undefined="")
    Returns the last path component. The arguments are: undefined
        Returns this value if the resource or basename is empty.
collection(undefined="")
    Returns the current resource collection. The arguments are: undefined
        This value is returned if r or the collection is empty.
color(red, yellow, green, blue)
    Colorizes the resource string value. The resource string is searched for an RE pattern match in Roy.G.Biv order. The first pattern that matches colorizes the resource string with that color. The arguments are: red
        Color red resource value pattern.
    yellow
        Color yellow resource value pattern.
    green
        Color green resource value pattern.
    blue
        Color blue resource value pattern.
date(format="%Y-%m-%dT%H:%M:%S", unit=1, undefined="", tz, tz_default)
    Formats the resource as a strftime() format. The arguments are: format
        The strftime(3) format.
    unit
        If the resource is a Timestamp then divide by unit to yield seconds.
    undefined
        Returns this value if the resource is not a valid time.
    tz
        Return the time relative to the tz timezone if specified, the explicit timezone in the resource if it has one, otherwise the local timezone. For example,
    tz_default
        The default timezone if the resource does not have a timezone suffix.
decode(encoding, undefined="")
    Returns the decoded value of the resource that was encoded by encoding. The arguments are: encoding
        The encoding name. base64 and utf-8 are supported.
    undefined
        Returns this value if the decoding fails.
duration(start="", end="", parts=3, precision=3, calendar=true, unit=1, undefined="")
    Formats the resource as an ISO 8601 duration string. The ISO 8601 Duration (https://en.wikipedia.org/wiki/ISO_8601#Durations) format is: "[-]P[nY][nM][nD][T[nH][nM][n[.m]S]]". The 0 duration is "P0". Otherwise at least one part will always be displayed. Negative durations are prefixed by "-". "T" disambiguates months "P2M" to the left of "T" and minutes "PT5M" to the right. If the resource is a datetime then the duration of resource - current_time is returned. The arguments are: start
        The name of a start time attribute in the resource. The duration of the end - start time attributes in resource is returned. If end is not specified then the current time is used.
    end
        The name of an end time attribute in the resource. Defaults to the current time if omitted. Ignored if start is not specified.
    parts
        Format at most this many duration parts starting with largest non-zero part.
    precision
        Format the last duration part with precision digits after the decimal point. Trailing "0" and "." are always stripped.
    calendar
        Allow time units larger than hours in formated durations if true. Durations specifying hours or smaller units are exact across daylight savings time boundaries. On by default. Use calendar=false to disable. For example, if calendar=true then at the daylight savings boundary 2016-03-13T01:00:00 + P1D => 2016-03-14T01:00:00 but 2016-03-13T01:00:00 + PT24H => 2016-03-14T03:00:00. Similarly, a +P1Y duration will be inexact but "calendar correct", yielding the same month and day number next year, even in leap years.
    unit
        Divide the resource numeric value by unit to yield seconds.
    undefined
        Returns this value if the resource is not a valid timestamp.
encode(encoding, undefined="")
    Returns the encoded value of the resource using encoding. The arguments are: encoding
        The encoding name. base64 and utf-8 are supported.
    undefined
        Returns this value if the encoding fails.
enum(enums, inverse=false, undefined="")
    Returns the enums dictionary description for the resource. The arguments are: enums
        The name of a message enum dictionary.
    inverse
        Do inverse lookup if true.
    undefined
        Returns this value if there is no matching enum description.
error(message)
    Raises an Error exception that does not generate a stack trace. The arguments are: message
        An error message. If not specified then the resource is formatted as the error message.
extract(keys)
    Extract an ordered list of values from the resource for the specified keys. The arguments are: keys
        The list of keys in the resource whose associated values will be included in the result.
fatal(message)
    Raises an InternalError exception that generates a stack trace. The arguments are: message
        An error message. If not specified then the resource is formatted as the error message.
firstof(args)
    Returns the first non-empty .name attribute value for name in args. The arguments are: args
        Names to check for resource attribute values,
    For example:
        x.firstof(bar_foo, barFoo, BarFoo, BAR_FOO) will check x.bar_foo, x.barFoo, x.BarFoo, and x.BAR_FOO in order for the first non-empty value.
float(precision=6, spec, undefined="")
    Returns the string representation of a floating point number. One of these formats is used (1) ". precision spec" if spec is specified (2) ". precision" unless 1e-04 <= abs(number) < 1e+09 (3) ".1f" otherwise. The arguments are: precision
        The maximum number of digits before and after the decimal point.
    spec
        The printf(3) floating point format "e", "f" or "g" spec character.
    undefined
        Returns this value if the resource is not a float.
format(fmt, args)
    Formats resource key values. The arguments are: fmt
        The format string with {0} ... {nargs-1} references to the resource attribute name arg values.
    args
        The resource attribute key expression to format. The printer projection symbols and aliases may be used in key expressions. If no args are specified then the resource is used as the arg list if it is a list, otherwise the resource is used as the only arg.
    For example:
        --format='value(format("{0:f.1}/{0:f.1}", q.CPU.default, q.CPU.limit))'
group(args)
    Formats a [...] grouped list. Each group is enclosed in [...]. The first item separator is ':', subsequent separators are ','. [item1] [item1] ... [item1: item2] ... [item1: item2] [item1: item2, item3] ... [item1: item2, item3] The arguments are: args
        Optional attribute names to select from the list. Otherwise the string value of each list item is selected.
if(expr)
    Disables the projection key if the flag name filter expr is false. The arguments are: expr
        A command flag filter name expression. See gcloud topic filters for details on filter expressions. The expression variables are flag names without the leading -- prefix and dashes replaced by underscores.
    For example:
        The "table(name, value.if(NOT short_format))" format will list a value column if the --short-format command line flag is not specified.
iso(undefined="T")
    Formats the resource to numeric ISO time format. The arguments are: undefined
        Returns this value if the resource does not have an isoformat() attribute.
join(sep="/", undefined="")
    Joins the elements of the resource list by the value of sep. A string resource is treated as a list of characters. The arguments are: sep
        The separator value to use when joining.
    undefined
        Returns this value if the result after joining is empty.
    For example:
        "a/b/c/d".split("/").join("!") returns "a!b!c!d"
len()
    Returns the length of the resource if it is non-empty, 0 otherwise.
list(show="", undefined="", separator=",")
    Formats a dict or list into a compact comma separated list. The arguments are: show
        If show=keys then list dict keys; if show=values then list dict values; otherwise list dict key=value pairs.
    undefined
        Return this if the resource is empty.
    separator
        The list item separator string.
map()
    Applies the next transform in the sequence to each resource list item. For example:
        list_field.map().foo().bar() applies foo() to each item in list_field and then bar() to the resulting value. list_field.map().foo().map().bar() applies foo() to each item in list_field and then bar() to each item in the resulting list.
resolution(undefined="", transpose=false)
    Formats a human readable XY resolution. The arguments are: undefined
        Returns this value if a recognizable resolution was not found.
    transpose
        Returns the y/x resolution if true.
scope(args)
    Gets the /args/ suffix from a URI. The arguments are: args
        Optional URI segment names. If not specified then 'regions', 'zones' is assumed.
    For example:
        "https://abc/foo/projects/bar/xyz".scope("projects") returns "bar/xyz". "https://xyz/foo/regions/abc".scope() returns "abc".
segment(index=-1, undefined="")
    Returns the index-th URI path segment. The arguments are: index
        The path segment index to return counting from 0.
    undefined
        Returns this value if the resource or segment index is empty.
size(zero="0", precision=1, units_in, units_out, min=0)
    Formats a human readable size in bytes. The arguments are: zero
        Returns this if size==0. Ignored if None.
    precision
        The number of digits displayed after the decimal point.
    units_in
        A unit suffix (only the first character is checked) or unit size. The size is multiplied by this. The default is 1.0.
    units_out
        A unit suffix (only the first character is checked) or unit size. The size is divided by this. The default is 1.0.
    min
        Sizes < min will be listed as "< min".
slice(op=":", undefined="")
    Returns a list slice specified by op. The op parameter consists of up to three colon-delimeted integers: start, end, and step. The parameter supports half-open ranges: start and end values can be omitted, representing the first and last positions of the resource respectively. The step value represents the increment between items in the resource included in the slice. A step of 2 results in a slice that contains every other item in the resource. Negative values for start and end indicate that the positons should start from the last position of the resource. A negative value for step indicates that the slice should contain items in reverse order. If op contains no colons, the slice consists of the single item at the specified position in the resource. The arguments are: op
        The slice operation.
    undefined
        Returns this value if the slice cannot be created, or the resulting slice is empty.
    For example:
[1,2,3].slice(1:) returns [2,3]. [1,2,3].slice(:2) returns [1,2]. [1,2,3].slice(-1:) returns [3]. [1,2,3].slice(
    -1) returns [3,2,1]. [1,2,3].slice(1) returns [2].
split(sep="/", undefined="")
    Splits a string by the value of sep. The arguments are: sep
        The separator value to use when splitting.
    undefined
        Returns this value if the result after splitting is empty.
    For example:
        "a/b/c/d".split() returns ["a", "b", "c", "d"]
uri(undefined=".")
    Gets the resource URI. The arguments are: undefined
        Returns this if a the URI for r cannot be determined.
yesno(yes, no="No")
    Returns no if the resource is empty, yes or the resource itself otherwise. The arguments are: yes
        If the resource is not empty then returns yes or the resource itself if yes is not defined.
    no
        Returns this value if the resource is empty.
The compute transform functions are: firewall_rule(undefined="")
    Returns a compact string describing a firewall rule. The compact string is a comma-separated list of PROTOCOL:PORT_RANGE items. If a particular protocol has no port ranges then only the protocol is listed. The arguments are: undefined
        Returns this value if the resource cannot be formatted.
image_alias(undefined="")
    Returns a comma-separated list of alias names for an image. The arguments are: undefined
        Returns this value if the resource cannot be formatted.
location(undefined="")
    Return the region or zone name. The arguments are: undefined
        Returns this value if the resource cannot be formatted.
location_scope(undefined="")
    Return the location scope name, either region or zone. The arguments are: undefined
        Returns this value if the resource cannot be formatted.
machine_type()
    Return the formatted name for a machine type.
next_maintenance(undefined="")
    Returns the timestamps of the next scheduled maintenance. All timestamps are assumed to be ISO strings in the same timezone. The arguments are: undefined
        Returns this value if the resource cannot be formatted.
operation_http_status(undefined="")
    Returns the HTTP response code of an operation. The arguments are: undefined
        Returns this value if there is no response code.
quota(undefined="")
    Formats a quota as usage/limit. The arguments are: undefined
        Returns this value if the resource cannot be formatted.
status(undefined="")
    Returns the machine status with deprecation information if applicable. The arguments are: undefined
        Returns this value if the resource cannot be formatted.
The debug transform functions are: full_status(undefined="UNKNOWN_ERROR")
    Returns a full description of the status of a logpoint or snapshot. Status will be one of ACTIVE, COMPLETED, or a verbose error description. If the status is an error, there will be additional information available in the status field of the object. The arguments are: undefined
        Returns this value if the resource is not a valid status.
    For example:
        --format="table(id, location, full_status())"
short_status(undefined="UNKNOWN_ERROR")
    Returns a short description of the status of a logpoint or snapshot. Status will be one of ACTIVE, COMPLETED, or a short error description. If the status is an error, there will be additional information available in the status field of the object. The arguments are: undefined
        Returns this value if the resource is not a valid status.
    For example:
        --format="table(id, location, short_status())"
The runtimeconfig transform functions are: waiter_status(undefined="")
    Returns a short description of the status of a waiter or waiter operation. Status will be one of WAITING, SUCCESS, FAILURE, or TIMEOUT. The arguments are: undefined
        Returns this value if the resource status cannot be determined.
    For example:
        --format="table(name, status())"
The service_registry transform functions are: endpoint_address(undefined="")
    Returns a compact representation of an endpoint address. The compact representation for a plain address (no port information) is just the address. The compact representation for an address with a port is of the form [HOST/IP]:PORT and addresses with more details or more ports will look like address=ADDRESS[;port_number=PORT[,protocol=PROTOCOL][,port_name=name]]+ The arguments are: undefined
        Returns this value if the resource cannot be formatted.
    For example:
        --format="table(name, addresses[].map().endpoint_address())"

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 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.

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)'