YuiRestClient::Http::HttpClient - Interface to the Rest API on the server
Copyright 2020 SUSE LLC
SPDX-License-Identifier: FSFAP
QE Yam <qe-yam at suse de>
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
);
Class to handle the HTTP traffic with the libYUI instance on the SUT. Uses Mojo::UserAgent for HTTP protocol.
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:
{port} - the port number of the libYUI rest server, defaults to 80.
{host} - The host name or IP address of the libYUI server.
{path} - The access path. This is optional and can be omitted.
{params} - Query parameters that can be used. This is optional and can be omitted.
With those parameters compose_url() will create an URL that looks like this:
http://{host}:{port}/{path}?{params}