lib/YuiRestClient/Http/HttpClient.pm

NAME

YuiRestClient::Http::HttpClient - Interface to the Rest API on the server

COPYRIGHT

Copyright 2020 SUSE LLC

SPDX-License-Identifier: FSFAP

AUTHORS

QE Yam <qe-yam at suse de>

SYNOPSIS

my $response = YuiRestClient::Http::HttpClient::http_get($uri);
my $response = YuiRestClient::Http::HttpClient::http_post($uri);
my $uri = YuiRestClient::Http::HttpClient::compose_uri(
    host => $self->{host},
    port => $self->{port},
    path => $self->{api_version} . '/widgets',
    params => $args
);

DESCRIPTION

Overview

Class to handle the HTTP traffic with the libYUI instance on the SUT. Uses Mojo::UserAgent for HTTP protocol.

Class and object methods

http_get($url) - perform a HTTP/GET to the specified URL

If the GET is successful (HTTP 200) then the data that was retrieved will be returned. If HTTP errors occur the method will log a "Widget not found by url" error message and then die with the error message returned by the server.

http_post($url) - perform a HTTP/POST to the specified URL

If the POST is successful (HTTP 200) then the data that was retrieved will be returned. If HTTP errors occur the method will log a "Widget not found by url" error message and then die with the error message returned by the server.

compose_url(%args) - compose an URL using the named parameter list

This method uses a hash for a named parameter list. The following parameters can be used:

With those parameters compose_url() will create an URL that looks like this:

http://{host}:{port}/{path}?{params}