API-Vultr
view release on metacpan or search on metacpan
t/01-test.t view on Meta::CPAN
"deploy_name": "LEMP on CentOS 6 x64",
"type": "one-click",
"vendor": "vultr",
"image_id": ""
},
{
"id": 1028,
"name": "OpenLiteSpeed WordPress",
"short_name": "openlitespeedwordpress",
"deploy_name": "OpenLiteSpeed WordPress on Ubuntu 20.04 x64",
"type": "marketplace",
"vendor": "LiteSpeed_Technologies",
"image_id": "openlitespeed-wordpress"
}
],
"meta":
{
"total": 2,
"links":
{
"next": "",
"prev": ""
}
}
}';
$vultr_api->ua->map_response(
qr{api.vultr.com/v2/applications},
HTTP::Response->new(
'200', 'OK',
[ 'Content-Type' => 'application/json' ], $application_json
)
);
ok $vultr_api->get_applications->is_success;
ok $vultr_api->get_applications->decoded_content, $application_json;
ok $vultr_api->ua->last_http_request_sent;
is $vultr_api->ua->last_http_request_sent->header('Authorization'),
'Bearer 123';
is $vultr_api->ua->last_http_request_sent->uri,
'https://api.vultr.com/v2/applications';
ok $vultr_api->ua->last_http_response_received->is_success;
is $vultr_api->ua->last_http_response_received->decoded_content,
$application_json;
$vultr_api->ua->map_response(
qr{api.vultr.com/v2/instances},
HTTP::Response->new(
'200', 'OK',
[ 'Content-Type' => 'application/json' ], $application_json
)
);
ok $vultr_api->create_instance( name => 'foo' )->is_success;
is $vultr_api->ua->last_http_request_sent->uri,
'https://api.vultr.com/v2/instances';
is $vultr_api->ua->last_http_request_sent->method, 'POST';
is_deeply $vultr_api->ua->last_http_request_sent->content, { name => 'foo' };
done_testing;
( run in 0.938 second using v1.01-cache-2.11-cpan-7fcb06a456a )