Module to use Google Cloud APIs from Perl via the gcloud CLI
GCloud::CLIWrapper - Module to use Google Cloud APIs via the gcloud CLI
use GCloud::CLIWrapper;
my $api = GCloud::CLIWrapper->new();
my $result = $api->run('info');
# $result->success == 1 if the command executed correctly
# $result->output contains the output of the command
my $result = $api->json('info', '--format', 'json');
# $result->success == 1 if the command executed correctly
# $result->output contains the output of the command
# $result->json is a hashref with the result of the parsed JSON output of the command
This module helps you use the GCloud API. It sends all it’s commands
via the CLI command line tool gcloud
.
By default initialized to gcloud
. It will try to find kubectl in the PATH. You can
set it explicitly to a specific gcloud excecutable.
An ArrayRef of options to always add to the command line invocations.
my $api = GCloud::CLIWrapper->new(
gcloud_options => [ 'info' ],
);
my $result = $api->run;
# $result->success == 1 if the command executed correctly
# $result->output contains the output of the command
my $result = $api->json('--format', 'json');
# $result->success == 1 if the command executed correctly
# $result->output contains the output of the command
# $result->json is a hashref with the result of the parsed JSON output of the command
Will run gcloud with the parameters. Returns a :Result">GCloud::Result object
with output
set to the output of the command, and success
a Boolean to indicate
if the command reported successful execution.
Will run gcloud with the parameters, trying to parse the output as json. Note that you are
responsible for passing the command-line option to output in a json format. Returns a :Result">Kubectl::Result object
with output
set to the output of the command, and json
set to a hashref with the parsed
JSON. success
will be false if JSON parsing fails.
https://cloud.google.com/sdk/gcloud/
Jose Luis Martinez
CAPSiDE
jlmartinez@capside.com
The source code is located here: https://github.com/pplu/GCloud-CLIWrapper.git
Please report bugs to: https://github.com/pplu/GCloud-CLIWrapper/issues
Copyright (c) 2018 by CAPSiDE
This code is distributed under the Apache 2 License. The full text of the
license can be found in the LICENSE file included with this module.