| 1 |
/** |
| 2 |
* collectd - src/utils_gce.h |
| 3 |
* ISC license |
| 4 |
* |
| 5 |
* Copyright (C) 2017 Florian Forster |
| 6 |
* |
| 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. |
| 10 |
* |
| 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. |
| 18 |
* |
| 19 |
* Authors: |
| 20 |
* Florian Forster <octo at collectd.org> |
| 21 |
**/ |
| 22 |
|
| 23 |
#ifndef UTILS_GCE_H |
| 24 |
#define UTILS_GCE_H 1 |
| 25 |
|
| 26 |
/* gce_check returns 1 when running on Google Compute Engine (GCE) and 0 |
| 27 |
* otherwise. */ |
| 28 |
_Bool gce_check(void); |
| 29 |
|
| 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); |
| 34 |
|
| 35 |
/* gce_instance_id returns the unique ID of the GCE instance. */ |
| 36 |
char *gce_instance_id(void); |
| 37 |
|
| 38 |
/* gce_zone returns the zone in which the GCE instance runs. */ |
| 39 |
char *gce_zone(void); |
| 40 |
|
| 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); |
| 44 |
|
| 45 |
/* gce_access_token acquires an OAuth access token for the given service account |
| 46 |
* (or |
| 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); |
| 51 |
|
| 52 |
#endif |