CloudHealth-API
view release on metacpan or search on metacpan
[CloudHealth::API::Call::UpdateAWSAccountAssignment](https://metacpan.org/pod/CloudHealth::API::Call::UpdateAWSAccountAssignment)
[CloudHealth::API::Call::DeleteAWSAccountAssignment](https://metacpan.org/pod/CloudHealth::API::Call::DeleteAWSAccountAssignment)
# AUTHENTICATION
As the documentation states, you need an API KEY to query the API. The default authentication
mechanism expects to find that API key in the `CLOUDHEALTH_APIKEY` environment variable.
You can also pass any object that implements an `api_key` method to the `credentials` attribute
of the constructor
# RESULTS
Results are returned as a Perl HashRef representing the JSON returned by the API.
# SEE ALSO
[https://apidocs.cloudhealthtech.com/](https://apidocs.cloudhealthtech.com/)
lib/CloudHealth/API.pm view on Meta::CPAN
package CloudHealth::API;
use Moo;
use Types::Standard qw/HasMethods/;
our $VERSION = '0.01';
has call_former => (is => 'ro', isa => HasMethods['params2request'], default => sub {
require CloudHealth::API::CallObjectFormer;
CloudHealth::API::CallObjectFormer->new;
});
has credentials => (is => 'ro', isa => HasMethods['api_key'], default => sub {
require CloudHealth::API::Credentials;
CloudHealth::API::Credentials->new;
});
has io => (is => 'ro', isa => HasMethods['call'], default => sub {
require CloudHealth::API::Caller;
CloudHealth::API::Caller->new;
});
has result_parser => (is => 'ro', isa => HasMethods['result2return'], default => sub {
require CloudHealth::API::ResultParser;
CloudHealth::API::ResultParser->new
});
sub _invoke {
my ($self, $method, $params) = @_;
my $req = $self->call_former->params2request($method, $self->credentials, $params);
my $result = $self->io->call($req);
return $self->result_parser->result2return($result);
}
sub method_classification {
{
aws_accounts => [ qw/EnableAWSAccount AWSAccounts SingleAWSAccount
UpdateExistingAWSAccount DeleteAWSAccount GetExternalID/ ],
perspectives => [ qw/RetrieveAllPerspectives RetrievePerspectiveSchema CreatePerspectiveSchema
UpdatePerspectiveSchema DeletePerspectiveSchema/ ],
lib/CloudHealth/API.pm view on Meta::CPAN
L<CloudHealth::API::Call::UpdateAWSAccountAssignment>
L<CloudHealth::API::Call::DeleteAWSAccountAssignment>
=head1 AUTHENTICATION
As the documentation states, you need an API KEY to query the API. The default authentication
mechanism expects to find that API key in the C<CLOUDHEALTH_APIKEY> environment variable.
You can also pass any object that implements an C<api_key> method to the C<credentials> attribute
of the constructor
=head1 RESULTS
Results are returned as a Perl HashRef representing the JSON returned by the API.
=head1 SEE ALSO
L<https://apidocs.cloudhealthtech.com/>
lib/CloudHealth/API/CallObjectFormer.pm view on Meta::CPAN
my $value = $call_object->$key;
next if (not defined $value);
my $location = defined $param->{ location } ? $param->{ location } : $key;
$body_struct->{ $location } = $value;
}
}
CloudHealth::API::Error->throw(
type => 'NoCredentials',
message => 'Cannot find credentials for the request'
) if (not $creds->is_set);
my $params = {
api_key => $creds->api_key,
};
foreach my $param (@{ $call_object->_query_params }) {
my $key = $param->{ name };
my $value = $call_object->$key;
next if (not defined $value);
t/05_classification_consistent.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use CloudHealth::API;
use CloudHealth::API::Credentials;
my $ch = CloudHealth::API->new(
credentials => CloudHealth::API::Credentials->new(api_key => 'stub')
);
my $classified_methods = {};
# See that all the methods in method_classification are effectively declared
# fill in classified_methods so we can later detect if there are methods in
# the API that have not been classified
foreach my $kind (keys %{ $ch->method_classification }) {
foreach my $method (@{ $ch->method_classification->{ $kind } }) {
ok($ch->can($method), "Method $method is declared");
$classified_methods->{ $method } = 1;
( run in 0.252 second using v1.01-cache-2.11-cpan-4d50c553e7e )