The compute1 command-line interface (CLI) allows to use most features of the Google compute service from the comfort of your terminal.

By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero.

If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools.

Everything else about the compute API can be found at the official documentation site.

Installation and Source Code

Install the command-line interface with cargo using:

bash cargo install google-compute1-cli

Find the source code on github.

Usage

This documentation was generated from the compute API at revision 20180916. The CLI is at version 1.0.8.

```bash compute1 [options] accelerator-types aggregated-list [-p ]... [-o ] get [-p ]... [-o ] list [-p ]... [-o ] addresses aggregated-list [-p ]... [-o ] delete

[-p ]... [-o ] get
[-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] autoscalers aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] backend-buckets add-signed-url-key (-r )... [-p ]... [-o ] delete [-p ]... [-o ] delete-signed-url-key [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] backend-services add-signed-url-key (-r )... [-p ]... [-o ] aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] delete-signed-url-key [-p ]... [-o ] get [-p ]... [-o ] get-health (-r )... [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] set-security-policy (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] disk-types aggregated-list [-p ]... [-o ] get [-p ]... [-o ] list [-p ]... [-o ] disks aggregated-list [-p ]... [-o ] create-snapshot (-r )... [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] resize (-r )... [-p ]... [-o ] set-labels (-r )... [-p ]... [-o ] firewalls delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] forwarding-rules aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-target (-r )... [-p ]... [-o ] global-addresses delete
[-p ]... [-o ] get
[-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] global-forwarding-rules delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-target (-r )... [-p ]... [-o ] global-operations aggregated-list [-p ]... [-o ] delete [-p ]... get [-p ]... [-o ] list [-p ]... [-o ] health-checks delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] http-health-checks delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] https-health-checks delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] images delete [-p ]... [-o ] deprecate (-r )... [-p ]... [-o ] get [-p ]... [-o ] get-from-family [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-labels (-r )... [-p ]... [-o ] instance-group-managers abandon-instances (-r )... [-p ]... [-o ] aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] delete-instances (-r )... [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] list-managed-instances [-p ]... [-o ] recreate-instances (-r )... [-p ]... [-o ] resize [-p ]... [-o ] set-instance-template (-r )... [-p ]... [-o ] set-target-pools (-r )... [-p ]... [-o ] instance-groups add-instances (-r )... [-p ]... [-o ] aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] list-instances (-r )... [-p ]... [-o ] remove-instances (-r )... [-p ]... [-o ] set-named-ports (-r )... [-p ]... [-o ] instance-templates delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] instances add-access-config (-r )... [-p ]... [-o ] aggregated-list [-p ]... [-o ] attach-disk (-r )... [-p ]... [-o ] delete [-p ]... [-o ] delete-access-config [-p ]... [-o ] detach-disk [-p ]... [-o ] get [-p ]... [-o ] get-serial-port-output [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] list-referrers [-p ]... [-o ] reset [-p ]... [-o ] set-deletion-protection [-p ]... [-o ] set-disk-auto-delete [-p ]... [-o ] set-labels (-r )... [-p ]... [-o ] set-machine-resources (-r )... [-p ]... [-o ] set-machine-type (-r )... [-p ]... [-o ] set-metadata (-r )... [-p ]... [-o ] set-min-cpu-platform (-r )... [-p ]... [-o ] set-scheduling (-r )... [-p ]... [-o ] set-service-account (-r )... [-p ]... [-o ] set-tags (-r )... [-p ]... [-o ] simulate-maintenance-event [-p ]... [-o ] start [-p ]... [-o ] start-with-encryption-key (-r )... [-p ]... [-o ] stop [-p ]... [-o ] update-access-config (-r )... [-p ]... [-o ] update-network-interface (-r )... [-p ]... [-o ] interconnect-attachments aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] interconnect-locations get [-p ]... [-o ] list [-p ]... [-o ] interconnects delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] license-codes get [-p ]... [-o ] test-iam-permissions (-r )... [-p ]... [-o ] licenses delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] test-iam-permissions (-r )... [-p ]... [-o ] machine-types aggregated-list [-p ]... [-o ] get [-p ]... [-o ] list [-p ]... [-o ] networks add-peering (-r )... [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] remove-peering (-r )... [-p ]... [-o ] switch-to-custom-mode [-p ]... [-o ] node-groups add-nodes (-r )... [-p ]... [-o ] aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] delete-nodes (-r )... [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] list-nodes [-p ]... [-o ] set-node-template (-r )... [-p ]... [-o ] node-templates aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] node-types aggregated-list [-p ]... [-o ] get [-p ]... [-o ] list [-p ]... [-o ] projects disable-xpn-host [-p ]... [-o ] disable-xpn-resource (-r )... [-p ]... [-o ] enable-xpn-host [-p ]... [-o ] enable-xpn-resource (-r )... [-p ]... [-o ] get [-p ]... [-o ] get-xpn-host [-p ]... [-o ] get-xpn-resources [-p ]... [-o ] list-xpn-hosts (-r )... [-p ]... [-o ] move-disk (-r )... [-p ]... [-o ] move-instance (-r )... [-p ]... [-o ] set-common-instance-metadata (-r )... [-p ]... [-o ] set-default-network-tier (-r )... [-p ]... [-o ] set-usage-export-bucket (-r )... [-p ]... [-o ] region-autoscalers delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] region-backend-services delete [-p ]... [-o ] get [-p ]... [-o ] get-health (-r )... [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] region-commitments aggregated-list [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] region-disk-types get [-p ]... [-o ] list [-p ]... [-o ] region-disks create-snapshot (-r )... [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] resize (-r )... [-p ]... [-o ] set-labels (-r )... [-p ]... [-o ] test-iam-permissions (-r )... [-p ]... [-o ] region-instance-group-managers abandon-instances (-r )... [-p ]... [-o ] delete [-p ]... [-o ] delete-instances (-r )... [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] list-managed-instances [-p ]... [-o ] recreate-instances (-r )... [-p ]... [-o ] resize [-p ]... [-o ] set-instance-template (-r )... [-p ]... [-o ] set-target-pools (-r )... [-p ]... [-o ] region-instance-groups get [-p ]... [-o ] list [-p ]... [-o ] list-instances (-r )... [-p ]... [-o ] set-named-ports (-r )... [-p ]... [-o ] region-operations delete [-p ]... get [-p ]... [-o ] list [-p ]... [-o ] regions get [-p ]... [-o ] list [-p ]... [-o ] routers aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] get-router-status [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] preview (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] routes delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] security-policies add-rule (-r )... [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] get-rule [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] patch-rule (-r )... [-p ]... [-o ] remove-rule [-p ]... [-o ] snapshots delete [-p ]... [-o ] get [-p ]... [-o ] list [-p ]... [-o ] set-labels (-r )... [-p ]... [-o ] ssl-certificates delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] ssl-policies delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] list-available-features [-p ]... [-o ] patch (-r )... [-p ]... [-o ] subnetworks aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] expand-ip-cidr-range (-r )... [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] list-usable [-p ]... [-o ] patch (-r )... [-p ]... [-o ] set-private-ip-google-access (-r )... [-p ]... [-o ] target-http-proxies delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-url-map (-r )... [-p ]... [-o ] target-https-proxies delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-quic-override (-r )... [-p ]... [-o ] set-ssl-certificates (-r )... [-p ]... [-o ] set-ssl-policy (-r )... [-p ]... [-o ] set-url-map (-r )... [-p ]... [-o ] target-instances aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] target-pools add-health-check (-r )... [-p ]... [-o ] add-instance (-r )... [-p ]... [-o ] aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] get-health (-r )... [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] remove-health-check (-r )... [-p ]... [-o ] remove-instance (-r )... [-p ]... [-o ] set-backup (-r )... [-p ]... [-o ] target-ssl-proxies delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-backend-service (-r )... [-p ]... [-o ] set-proxy-header (-r )... [-p ]... [-o ] set-ssl-certificates (-r )... [-p ]... [-o ] set-ssl-policy (-r )... [-p ]... [-o ] target-tcp-proxies delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-backend-service (-r )... [-p ]... [-o ] set-proxy-header (-r )... [-p ]... [-o ] target-vpn-gateways aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] url-maps delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] invalidate-cache (-r )... [-p ]... [-o ] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] validate (-r )... [-p ]... [-o ] vpn-tunnels aggregated-list [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] zone-operations delete [-p ]... get [-p ]... [-o ] list [-p ]... [-o ] zones get [-p ]... [-o ] list [-p ]... [-o ] compute1 --help

Configuration: [--scope

]... Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it. If unset, it defaults to the shortest scope url for a particular method. --config-dir A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation. [default: ~/.google-service-cli] --debug Output all server communication to standard error. and are placed into the same stream. --debug-auth Output all communication related to authentication to standard error. and are placed into the same stream.txrxtxrx

```

Configuration

The program will store all persistent data in the directory in files prefixed with . You can change the directory used to store configuration with the flag on a per-invocation basis.

~/.google-service-cliJSONcompute1---config-dir

More information about the various kinds of persistent data are given in the following paragraphs.

Authentication

Most APIs require a user to authenticate any request. If this is the case, the determines the set of permissions granted. The granularity of these is usually no more than or .

scoperead-onlyfull-access

If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a method that is read-only, it will ask only for a read-only scope. You may use the flag to specify a scope directly. All applicable scopes are documented in the respective method's CLI documentation.

--scope

The first time a scope is used, the user is asked for permission. Follow the instructions given by the CLI to grant permissions, or to decline.

If a scope was authenticated by the user, the respective information will be stored as in the configuration directory, e.g. . No manual management of these tokens is necessary.

JSON~/.google-service-cli/compute1-token-<scope-hash>.json

To revoke granted authentication, please refer to the .

official documentation

Application Secrets

In order to allow any application to use Google services, it will need to be registered using the . APIs the application may use are then enabled for it one by one. Most APIs can be used for free and have a daily quota.

Google Developer Console

To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI comes with a default application secret that is configured accordingly. This also means that heavy usage all around the world may deplete the daily quota.

You can workaround this limitation by putting your own secrets file at this location: , assuming that the required API was enabled for it. Such a secret file can be downloaded in the at and used as is.

~/.google-service-cli/compute1-secret.jsoncomputeGoogle Developer ConsoleAPIs & auth -> Credentials -> Download JSON

Learn more about how to setup Google projects and enable APIs using the .

official documentation

Debugging

Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know what exactly led to a particular issue. This is done by allowing all client-server communication to be output to standard error .

as-is

The flag will print all client-server communication to standard error, whereas the flag will cause all communication related to authentication to standard error. If the flag is set, error-results will be debug-printed, possibly yielding more information about the issue at hand.

--debug--debug-auth--debug

You may consider redirecting standard error into a file for ease of use, e.g. .

compute1 --debug <resource> <method> [options] 2>debug.txt