Skip to content
Ettore Di Giacinto edited this page May 23, 2017 · 3 revisions

NAME

OpenQA::Client - special version of Mojo::UserAgent that handles authentication

SYNOPSIS

use OpenQA::Client;

# create new UserAgent that is meant to talk to localhost. Reads key
# and secret from config section [localhost]
my $ua = OpenQA::Client->new(api => 'localhost');

# specify key and secret manually
my $ua = OpenQA::Client->new(apikey => 'foo', apisecret => 'bar');

DESCRIPTION

OpenQA::Client inherits from Mojo::UserAgent. It automatically sets the correct authentication headers if API key and secret are available.

API key and secret can either be set manually in the constructor, via attributes or read from a config file. OpenQA::Client tries to find a config file in $OPENQA_CONFIG, ~/.config/openqa/client.conf or /etc/openqa/client.conf and reads whatever comes first.

See Mojo::UserAgent for more.

ATTRIBUTES

OpenQA::Client implmements the following attributes.

apikey

my $apikey = $ua->apikey;
$ua        = $ua->apikey('foo');

The API public key

apisecret

my $apisecret = $ua->apisecret;
$ua           = $ua->apisecret('bar');

The API secret key

METHODS

new

my $ua = OpenQA::Client->new(api => 'localhost');
my $ua = OpenQA::Client->new(apikey => 'foo', apisecret => 'bar');

Generate the OpenQA::Client object.

CONFIG FILE FORMAT

The config file is in ini format. The sections are the host name of the api.

[openqa.example.com]
key = foo
secret = bar

SEE ALSO

Mojo::UserAgent, Config::IniFiles