2 * collectd - src/utils_gce.h
5 * Copyright (C) 2017 Florian Forster
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 * Florian Forster <octo at collectd.org>
26 /* gce_check returns 1 when running on Google Compute Engine (GCE) and 0
28 _Bool gce_check(void);
30 /* gce_project_id returns the project ID of the instance, as configured when
31 * creating the project.
32 * For example "example-project-a". */
33 char *gce_project_id(void);
35 /* gce_instance_id returns the unique ID of the GCE instance. */
36 char *gce_instance_id(void);
38 /* gce_zone returns the zone in which the GCE instance runs. */
41 /* gce_scope returns the list of scopes for the given service account (or the
42 * default service account when NULL is passed). */
43 char *gce_scope(char const *email);
45 /* gce_access_token acquires an OAuth access token for the given service account
47 * the default service account when NULL is passed) and stores it in buffer.
48 * Access tokens are automatically cached and renewed when they expire. Returns
49 * zero on success, non-zero otherwise. */
50 int gce_access_token(char const *email, char *buffer, size_t buffer_size);