API-Vultr

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    region => 'ewr',
    plan => 'vc2-6c-16gb',
    label => 'My Instance',
    os_id => 215,
    user_data => 'QmFzZTY4EVsw32WfsGGHsjKJI',
    backups => 'enabled',
    hostname => 'hostname'
);

if ($create_response->is_success) {
    print Dumper($create_response->decoded_content);
}
else {
    die $create_response->status_line;
}
```

## License

This project is licensed under the Artistic 2.0 license. Please read the `LICENSE` file at the root of the
project for more information on what that means.

lib/API/Vultr.pm  view on Meta::CPAN

        region => 'ewr',
        plan => 'vc2-6c-16gb',
        label => 'My Instance',
        os_id => 215,
        user_data => 'QmFzZTY4EVsw32WfsGGHsjKJI',
        backups => 'enabled',
        hostname => 'hostname'
    );

    if ($create_response->is_success) {
        print Dumper($create_response->decoded_content);
    }
    else {
        die $create_response->status_line;
    }

=head1 API

=head2 ua

Set, or get the L<LWP::UserAgent> associated L<API::Vultr> instance.

t/01-test.t  view on Meta::CPAN

}';

$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
    )
);



( run in 0.367 second using v1.01-cache-2.11-cpan-26ccb49234f )