NAME
GRNOC::WebService::Client - GlobalNOC Web Service Client
SYNOPSIS
Module to implement clients that interact with cosign protected GRNOC CDS web services.
Default Method is GET but POST can be used as well.
Quick summary of what the module does.
Perhaps a little code snippet.
use GRNOC::WebService::Client;
my $svc = GRNOC::WebService::Client->new(
url => "https://sherpa.grnoc.iu.edu/web-service/foobar/example.cgi",
uid => "test_uid",
passwd => $password,
realm => 'Authentication Required', # needed for HTTP basic auth
usePost => 0,
debug => 0
);
#--- get list of available methods
my $res= $svc->help();
if(!defined $res){
print Dumper($svc->get_error());
}
else{
print Dumper($res);
}
#-- get help for specific method
my $res= $svc->help(method_name => 'echo');
if(!defined $res){
print Dumper($svc->get_error());
}
else{
print Dumper($res);
}
#--- call a web service method
my $res= $svc->echo(data => 'This is a test');
if(!defined $res){
print Dumper($svc->get_error());
}
else{
print Dumper($res);
}
...
FUNCTIONS
The list of methods available is dependent upon the web service you have bound to. Use get_methods() to retrieve
the list of available methods. Only the methods implemented in the client library are listed here.
new()
constructor that takes four named parameters: .
- url
-
the url that directly indentifies a servcie
- service_name
-
the GlobalNOC service identifier, with this client will consult the service
naming service to resolve, best URL to use.
- service_cache_file
-
the location of the service cache file to use on disk (if not specified does direct nameservice queries)
- name_services
-
array containing the locations of nameservices to use
- uid
-
user id for authentication
- passwd
-
user password
- timeout
-
timeout value in seconds for the connection, if no activity observed in this time period LWP will abort.
- usePost
-
boolean value for whether or not we are using http POST style or not
- use_keep_alive
-
boolean value for whether or not to try and use keep_alives
-
boolean value for wether or not to use a GRNOC::WebService::Client::Paginator object to iterate through results
- user_agent
-
string to use as the User-Agent string in request headers, defaults to $0
- verify_hostname
-
If set to 1 then ssl certs are validated. Set to 0 when working with untrusted or self-signed certs. Defaults to 1.
- retry_error_codes
-
hash of http error codes to retry the request on if the request fails
get_error()
gets the last error encountered or undef.
get_content_type
Returns the Content-Type header of the last issue request
Returns all the headers as an array of objects from the last request
get_retries
Returns the number of retries
get_retry_interval
Returns the retry interval in seconds
set_retries
Sets the number of retries if the initial request fails
get_realm
Returns the realm set
set_retry_interval
Sets the retry interval in seconds
set_raw_output
Disables or enables returning the raw output instead of attempting to decode JSON. This method
should be passed 1 to enable raw output and 0 to disable raw output. Raw output is disabled by
default--is can also be set by passing the raw_output parameter in the constructor.
set_timeout
Changes the timeout value in the underlying LWP object. Can only be set by passing timeout in the constructor
call.
set_cookie_jar
Updates the cookie jar associated with the underlying LWP object. This can be passed a string representing
a file on disk or an HTTP::Cookies object.
save_cookies
Method to ask the underlying LWP UserAgent to save any cookies it might have.
set_url
interface to change URL of an existing client, useful in stateful mod_perl.
Note: This wipes out any existing URLs that may have been loaded from a service identifier
clear_urls
Wipes out all knowledge the client has about URLs, useful if trying to use one client persistently
for multiple requests such as the proxy service
set_service_identifier
interface to change what service identifier we are using.
Note: This wipes out any existing URLs that may have been loaded from a service identifier
set_credentials
interface to change the username, password, and/or realm of the client
set_cookies
interface to change cookies of an existing client, useful in stateful mod_perl. Object given must be a HTTP::Cookies object
AUTHOR
GRNOC Systems Engineering, C<< <syseng at grnoc.iu.edu> >>
BUGS
Please report any bugs or feature requests to C<< <syseng at grnoc.iu.edu> >>
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc GRNOC::WebService::Client
ACKNOWLEDGEMENTS