Apigee-Edge
view release on metacpan or search on metacpan
lib/Apigee/Edge.pm view on Meta::CPAN
my %args = @_ % 2 ? %{$_[0]} : @_;
my $url = Mojo::URL->new("/o/" . $self->{org} . "/apiproducts");
$url->query(\%args) if %args;
return $self->request('GET', $url->to_string);
}
sub search_api_products {
return (shift)->get_api_products(@_);
}
sub get_api_product_details { ## no critic (ArgUnpacking)
my $self = shift;
my $product = shift;
my %args = @_ % 2 ? %{$_[0]} : @_;
my $url = Mojo::URL->new("/o/" . $self->{org} . "/apiproducts/" . uri_escape($product));
$url->query(\%args) if %args;
return $self->request('GET', $url->to_string);
}
sub request {
my ($self, $method, $url, %params) = @_;
$errstr = ''; # reset
my $ua = $self->__ua;
my $header = {Authorization => 'Basic ' . b64_encode($self->{usr} . ':' . $self->{pwd}, '')};
$header->{'Content-Type'} = 'application/json' if %params;
my @extra = %params ? (json => \%params) : ();
my $tx = $ua->build_tx($method => $self->{endpoint} . $url => $header => @extra);
$tx->req->headers->accept('application/json');
$tx = $ua->start($tx);
if ($tx->res->headers->content_type and $tx->res->headers->content_type =~ 'application/json') {
return $tx->res->json;
}
if (!$tx->success) {
$errstr = "Failed to fetch $url: " . $tx->error->{message};
return;
}
$errstr = "Unknown Response.";
return;
}
1;
__END__
=encoding utf-8
=head1 NAME
Apigee::Edge - Apigee.com 'Edge' management API.
=head1 SYNOPSIS
use Apigee::Edge;
my $apigee = Apigee::Edge->new(
org => 'apigee_org',
usr => 'your_email',
pwd => 'your_password'
);
=head1 DESCRIPTION
Apigee::Edge is an object-oriented interface to facilitate management of Developers and Apps using the Apigee.com 'Edge' management API. see L<http://apigee.com/docs/api-services/content/api-reference-getting-started>
The API is incompleted. welcome to fork the repos on github L<https://github.com/binary-com/perl-Apigee-Edge> and send us pull-requests.
=head1 METHODS
=head2 new
=over 4
=item * org
required. organization name.
=item * usr
required. login email
=item * pwd
required. login password
=item * endpoint
optional. default to https://api.enterprise.apigee.com/v1
=back
=head2 Apps
L<http://apigee.com/docs/api/apps-0>
=head3 get_app
my $app = $apigee->get_app($app_id);
=head3 get_apps
my $app_ids = $apigee->get_apps();
my $apps = $apigee->get_apps(expand => 'true', includeCred => 'true');
=head3 get_apps_by_family
my $app_ids = $apigee->get_apps_by_family($family);
=head3 get_apps_by_keystatus
my $app_ids = $apigee->get_apps_by_keystatus($keystatus);
=head3 get_apps_by_type
my $app_ids = $apigee->get_apps_by_type($type);
=head2 Developers
L<http://apigee.com/docs/api/developers-0>
=head3 get_developers
my $developers = $apigee->get_developers();
=head3 get_app_developers
my $developers = $apigee->get_app_developers($app_name);
=head3 get_developer
my $developer = $apigee->get_developer('fayland@binary.com') or die $apigee->errstr;
=head3 create_developer
my $developer = $apigee->create_developer(
"email" => 'fayland@binary.com',
"firstName" => "Fayland",
"lastName" => "Lam",
"userName" => "fayland.binary",
"attributes" => [
{
"name" => "Attr1",
"value" => "V1"
},
( run in 0.832 second using v1.01-cache-2.11-cpan-df04353d9ac )