gcloud compute disks bulk set-labels

NAME
gcloud compute disks bulk set-labels - add or remove labels on multiple Compute Engine disks
SYNOPSIS
gcloud compute disks bulk set-labels (--source=SOURCE     | --disks=[DISK_NAME,…] --labels=[KEY=VALUE,…]) [--zone=ZONE] [GCLOUD_WIDE_FLAG]
DESCRIPTION
gcloud compute disks bulk set-labels allows you to add or remove labels on multiple Compute Engine disks in a single zone. Labels are key-value pairs that help you organize your Google Cloud resources.

You can specify the disks and their labels in two ways:

1. By providing a JSON file using the --source flag. Each request in the JSON list must specify the disk name and labels, and may optionally include label_fingerprint for optimistic concurrency control.

2. By providing a list of disk names using the --disks flag and the labels to apply using the --labels flag.

EXAMPLES
To set the labels env=production and team=sre on disk-1 and disk-2 in zone us-central1-a, run:
gcloud compute disks bulk set-labels --zone=us-central1-a --disks=disk-1,disk-2 --labels=env=production,team=sre

To clear all labels on disk-3 and disk-4 in zone europe-west1-b provide an empty value to --labels, run:

gcloud compute disks bulk set-labels --zone=europe-west1-b --disks=disk-3,disk-4 --labels=''

To set labels based on a JSON file named disk_labels.json, run:

Example `disk_labels.json` content:

[
  {
    "name": "disk-1",
    "labels": { "env": "production", "team": "sre" },
    "label_fingerprint": "42WmSpB8rSM="
  },
  {
    "name": "disk-2",
    "labels": { "env": "production", "team": "sre" }
  }
]
gcloud compute disks bulk set-labels --zone=us-central1-a --source=disk_labels.json ```

To clear all labels on disk-3 and disk-4 in zone europe-west1-b provide an empty labels value in the JSON file, run:

Example `disk_labels.json` content:

[
  {
    "name": "disk-3",
    "labels": {}
  },
  {
    "name": "disk-4",
    "labels": {}
  }
]
gcloud compute disks bulk set-labels --zone=europe-west1-b --source=disk_labels.json
REQUIRED FLAGS
Exactly one of these must be specified:
--source=SOURCE
Path to a JSON file containing a list of disk label update requests. Each request object must specify "name" and "labels", and may optionally include "label_fingerprint".
Or at least one of these can be specified:
--disks=[DISK_NAME,…]
Comma-separated list of disk names to update.

This flag argument must be specified if any of the other arguments in this group are specified.

--labels=[KEY=VALUE,…]
List of label KEY=VALUE pairs to set on all specified disks.

This flag argument must be specified if any of the other arguments in this group are specified.

OPTIONAL FLAGS
--zone=ZONE
Zone of the disk to update labels. If not specified and the compute/zone property isn't set, you might be prompted to select a zone (interactive mode only).

To avoid prompting when this flag is omitted, you can set the compute/zone property:

gcloud config set compute/zone ZONE

A list of zones can be fetched by running:

gcloud compute zones list

To unset the property, run:

gcloud config unset compute/zone

Alternatively, the zone can be stored in the environment variable CLOUDSDK_COMPUTE_ZONE.

GCLOUD WIDE FLAGS
These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.

Run $ gcloud help for details.

NOTES
These variants are also available:
gcloud alpha compute disks bulk set-labels
gcloud beta compute disks bulk set-labels
gcloud preview compute disks bulk set-labels