| 1 | #!/usr/bin/perl -w | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # $Id: rundeckAPI.pm, v1.0 r1 04/02/2020 13:58:58 CET XH Exp $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Copyright 2020 Xavier Humbert <xavier.humbert@ac-nancy-metz.fr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # modify it under the terms of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # as published by the Free Software Foundation; either version 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # along with this program ; if not, write to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Free Software Foundation, Inc., | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # 59 Temple Place - Suite 330, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Boston, MA 02111-1307, USA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | #** @class RundeckAPI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # RundeckAPI - simplifies authenticate, connect, queries to a Rundeck instance via REST API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | package RundeckAPI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use POSIX qw(setlocale strftime); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | use HTTP::Cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | use REST::Client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | our @EXPORT_OK = qw(get post put delete postData putData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ## CONSTANTS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | our $TIMEOUT = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | our $VERSION = "1.3.8.0"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | our $APIVERSION = '37'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ## VARIABLES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ## CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | #** @method public new (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # @ creates a connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # @param value %options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # @retval value the created class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $rc = 403; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'url' => $args{'url'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'login' => $args{'login'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'password' => $args{'password'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'token' => $args{'token'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'debug' => $args{'debug'} //= 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'verbose' => $args{'verbose'} //= 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 'result' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 'apivers' => $args{'apivers'} //= $APIVERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | 'timeout' => $args{'timeout'} //= $TIMEOUT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/10
$args{"debug"} //= 0
$args{"verbose"} //= 0
$args{"apivers"} //= $RundeckAPI::APIVERSION
$args{"timeout"} //= $RundeckAPI::TIMEOUT
MC/DC0%0/1
$args{"debug"} //= 0
$args{"debug"}
MC/DC0%0/1
$args{"verbose"} //= 0
$args{"verbose"}
MC/DC0%0/2
$args{"apivers"} //= $RundeckAPI::APIVERSION
$args{"apivers"}
$RundeckAPI::APIVERSION
MC/DC0%0/2
$args{"timeout"} //= $RundeckAPI::TIMEOUT
$args{"timeout"}
$RundeckAPI::TIMEOUT
Truth table0%0/2
A
A= $args{"debug"}
Truth table0%0/2
A
A= $args{"verbose"}
Truth table0%0/3
A //= B
A= $args{"apivers"}B= $RundeckAPI::APIVERSION
Truth table0%0/3
A //= B
A= $args{"timeout"}B= $RundeckAPI::TIMEOUT
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # create and store a cookie jar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $cookie_jar = HTTP::Cookies->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | autosave => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ignore_discard => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->{'cookie_jar'} = $cookie_jar; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # with this cookie, cretae an User-Agent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my($prog, $dirs, $suffix) = fileparse($0, (".pl")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | my $ua = LWP::UserAgent->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 'agent' => $prog . "-" . $VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 'timeout' => $self->{'timeout'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | 'cookie_jar' => $self->{'cookie_jar'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 'requests_redirectable' => ['GET', 'HEAD', 'POST', 'PUT', 'DELETE'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $ua->show_progress ($args{'verbose'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $ua->proxy( ['http', 'https'], $args{'proxy'}) if (defined $args{'proxy'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->{'ua'} = $ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # connect to the client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | my $client = REST::Client->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | host => $self->{'url'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | timeout => $self->{'timeout'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | useragent => $ua, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | follow => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $client->addHeader ("Content-Type", 'application/x-www-form-urlencoded'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $client->addHeader ("Accept", "application/json"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->{'client'} = $client; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # if we have a token, use it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if (defined $self->{'token'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $client->addHeader ("X-Rundeck-Auth-Token", $self->{'token'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $client->GET("/api/$self->{'apivers'}/tokens/$self->{'login'}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $rc = $client->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if (($rc-$rc%100 == 200) && (index($client->{'_res'}{'_content'}, 'alert alert-danger') == -1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rc - $rc % 100 == 200 and (index($client->{"_res"}{"_content"}, "alert alert-danger") == -1)
MC/DC0%0/2
$rc - $rc % 100 == 200 and (index($client->{"_res"}{"_content"}, "alert alert-danger") == -1)
$rc - $rc % 100 == 200
(index($client->{"_res"}{"_content"}, "alert alert-danger") == -1)
Truth table0%0/3
A and B
A= $rc - $rc % 100 == 200B= (index($client->{"_res"}{"_content"}, "alert alert-danger") == -1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $rc = 200; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $rc = 403; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # post user/passwd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $client->POST( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | "j_security_check", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | "j_username=$self->{'login'}" . "&" . "j_password=$self->{'password'}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $rc = $client->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ($rc-$rc%100 != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->{'result'}->{'reqstatus' } = 'UNKN'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $self->{'result'}->{'reqstatus'} = 'OK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->{'result'}->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # done, bless object and return it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | bless ($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $self->_logV1 ("Connected to $self->{'url'}") if ($rc-$rc%100 == 200); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $self->_logD($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ## METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | #** @method public get (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # @ sends a GET query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # @param endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # @retval the response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub get (){ # endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $endpt = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $endpoint = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ($endpt =~ /^\/api\/[0-9]+\/(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $endpoint = "/api/$self->{'apivers'}/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $endpoint = "/api/$self->{'apivers'}/$endpt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $responsehash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # Handle secial case where endpoint is /api/XX/job, returns YAML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # Obsolete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | #~ if ($endpoint =~ /api\/[0-9]+\/job/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | #~ $endpoint .= '?format=yaml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | #~ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $self->_logV2("endpoint = $endpoint"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->{'client'}->GET($endpoint); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $rc = $self->{'client'}->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ($rc-$rc%100 != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $responseType = $self->{'client'}->responseHeader('content-type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $responseContent = $self->{'client'}->responseContent(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $responsehash = $self->_handleResponse($rc, $responseType, $responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return dclone ($responsehash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | #** @method public post (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # @ sends a POST request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # @param endpoint, the JSON to POST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # @retval the response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub post(){ # endpoint, json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $endpt = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $json = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $endpoint = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if ($endpt =~ /^\/api\/[0-9]+\/(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $endpoint = "/api/$self->{'apivers'}/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $endpoint = "/api/$self->{'apivers'}/$endpt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $responsehash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->{'client'}->addHeader ("Content-Type", 'application/json'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self->_logV2("endpoint = $endpoint"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->{'client'}->POST($endpoint, $json); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $rc = $self->{'client'}->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->{'result'}->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ($rc-$rc%100 != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $responseType = $self->{'client'}->responseHeader('content-type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $responseContent = $self->{'client'}->responseContent(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $responsehash = $self->_handleResponse($rc, $responseType, $responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return dclone ($responsehash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | #** @method public put (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # @ sends a PUT query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # @param endpoint, the JSON to PUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # @retval the response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub put(){ # endpoint, json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $endpt = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $json = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $endpoint = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($endpt =~ /^\/api\/[0-9]+\/(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $endpoint = "/api/$self->{'apivers'}/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $endpoint = "/api/$self->{'apivers'}/$endpt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $responsehash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $self->{'client'}->addHeader ("Content-Type", 'application/json'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->_logV2("endpoint = $endpoint"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $self->{'client'}->PUT($endpoint, $json); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $rc = $self->{'client'}->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->{'result'}->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if ($rc-$rc%100 != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $responseType = $self->{'client'}->responseHeader('content-type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $responseContent = $self->{'client'}->responseContent(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $responsehash = $self->_handleResponse($rc, $responseType, $responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | return dclone ($responsehash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | #** @method public delete (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # @ sends a DELETE query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # @param endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # @retval the response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub delete () { # endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $endpt = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $endpoint = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ($endpt =~ /^\/api\/[0-9]+\/(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $endpoint = "/api/$self->{'apivers'}/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $endpoint = "/api/$self->{'apivers'}/$endpt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $responsehash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->_logV2("endpoint = $endpoint"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->{'client'}->DELETE($endpoint); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $rc = $self->{'client'}->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($rc-$rc%100 != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $responseType = $self->{'client'}->responseHeader('content-type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $responseContent = $self->{'client'}->responseContent(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $responsehash = $self->_handleResponse($rc, $responseType, $responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return dclone ($responsehash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | #** @method public postData (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # @ sends a POST query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # @param endpoint, mimetype, data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # @retval the response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub postData() { # endpoint, mimetype, data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
postData: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $endpt = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $mimetype = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $endpoint = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($endpt =~ /^\/api\/[0-9]+\/(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $endpoint = "/api/$self->{'apivers'}/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $endpoint = "/api/$self->{'apivers'}/$endpt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $responsehash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->{'client'}->addHeader ("Content-Type", $mimetype); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $self->_logV2("endpoint = $endpoint"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->{'client'}->POST($endpoint, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $rc = $self->{'client'}->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->{'result'}->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($rc-$rc%100 != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $responseType = $self->{'client'}->responseHeader('content-type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $responseContent = $self->{'client'}->responseContent(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $responsehash = $self->_handleResponse($rc, $responseType, $responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return dclone ($responsehash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | #** @method public putData (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # @ sends a PUT query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # @param endpoint, mimetype, data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # @retval the response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | sub putData() { # endpoint, mimetype, data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
putData: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $endpt = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $mimetype = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my $endpoint = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if ($endpt =~ /^\/api\/[0-9]+\/(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $endpoint = "/api/$self->{'apivers'}/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $endpoint = "/api/$self->{'apivers'}/$endpt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $responsehash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $self->{'client'}->addHeader ("Content-Type", $mimetype); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $self->_logV2("endpoint = $endpoint"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $self->{'client'}->PUT($endpoint, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $rc = $self->{'client'}->responseCode (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $self->{'result'}->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if ($rc-$rc%100 != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $responseType = $self->{'client'}->responseHeader('content-type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my $responseContent = $self->{'client'}->responseContent(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $responsehash = $self->_handleResponse($rc, $responseType, $responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | return dclone ($responsehash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | #** @method private _handleResponse (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # @ manage with the various responses, build a hash with the data received | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # @param rc, responseType, responseContent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # @retval the response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub _handleResponse () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handleResponse: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my $rc = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $responseType = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $responseContent = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $responseJSON = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $responsehash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $responsehash->{'reqstatus'} = 'OK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $responsehash->{'httpstatus'} = $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # is data JSON ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if (defined $responseType) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->_logV2($responseType); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | if ($responseType =~ /^application\/json.*/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $self->_logV2($responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | $responseJSON = decode_json($responseContent) if $responseContent ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $reftype = reftype($responseJSON); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if (not defined $reftype) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $responsehash->{'httpstatus'} = 415; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } elsif ($reftype eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $self->_logV2("copying array"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $responsehash->{'content'}{'arraycount'} = $#$responseJSON+1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | for (my $i = 0; $i <= $#$responseJSON; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $responsehash->{'content'}{$i} = $responseJSON->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } elsif ($reftype eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $responsehash->{'reqstatus'} = 'CRIT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $responsehash->{'httpstatus'} = 415; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } elsif ($reftype eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $self->_logV2("copying hash"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $responsehash->{'content'} = $responseJSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } elsif ($responseType =~ /text\/plain.*/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $self->_logV2($responseContent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $responsehash->{'content'} = $responseContent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } else { # assume binary, like text, but do not log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $responsehash->{'content'} = $responseContent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return $responsehash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | #** @method private _logV1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # @ print a message if verbose > 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # @param message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | sub _logV1() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_logV1: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ($self->{'verbose'} >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if (defined $msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | print "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | print "unknown $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | #** @method private _logV2 (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # @ dumps an object if verbose > 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # @param message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | sub _logV2() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_logV2: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | if ($self->{'verbose'} >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | if (defined $obj) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | print Dumper ($obj); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | print "unknown object $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | #** @method private _logD (parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # @ dumps an object if debug enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # @param object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | #* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | sub _logD() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_logD: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | print Dumper ($object) if $self->{'debug'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | RundeckAPI - simplifies authenticate, connect, queries to a Rundeck instance via REST API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | use RundeckAPI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # create an object of type RundeckAPI : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | my $api = RundeckAPI->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 'url' => "https://my.rundeck.instance:4440", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 'login' => "admin", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 'token' => <token as generated with GUI, as an admin> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 'debug' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 'apivers' => '42', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 'proxy' => "http://proxy.mycompany.com/", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | my $hashRef = $api->get("system/info"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | my $json = '{some: value}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | $hashRef = $api->put(endpoint_for_put, $json); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | =over 12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | =item C<new> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | Returns an object authenticated and connected to a Rundeck Instance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | The field 'login' is not stricto sensu required, but it is a good security mesure to check if login/token match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | =item C<get> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | Sends a GET query. Request one argument, the enpoint to the API. Returns a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | =item C<post> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | Sends a POST query. Request two arguments, the enpoint to the API an the data in json format. Returns a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | =item C<put> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | Sends a PUT query. Similar to post | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | =item C<delete> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | Sends a DELETE query. Similar to get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | =item C<postData> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | POST some data. Request three arguments : endpoint, mime-type and the appropriate data. Returns a hash reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | =item C<putData> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | PUT some data. Similar to postData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | =item C<postFile> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | Alias for compatibility for postData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | =item C<putFile> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | Alias for compatibility for putData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | =head1 RETURN VALUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | Returns a hash reference containing the data sent by Rundeck. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | The returned value is structured like the following : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | the fields `httpstatus` (200, 403, etc) and `requstatus` (OK, CRIT) are always present. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | the field `content` is a hash (if the mime-type of the result is JSON), text or binary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | See documentation for Rundeck's API https://docs.rundeck.com/docs/api/rundeck-api.html and returned data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | Xavier Humbert <xavier.humbert-at-ac-nancy-metz-dot-fr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||