Apigee-Edge

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    required. organization name.
 
- usr
 
    required. login email
 
- pwd
 
    required. login password
 
- endpoint
 
    optional. default to https://api.enterprise.apigee.com/v1
 
## Apps
 
 
### get\_app
 
    my $app = $apigee->get_app($app_id);

lib/Apigee/Edge.pm  view on Meta::CPAN

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
sub errstr { return $errstr }
 
sub new {    ## no critic (ArgUnpacking)
    my $class = shift;
    my %args = @_ % 2 ? %{$_[0]} : @_;
 
    for (qw/org usr pwd/) {
        $args{$_} || croak "Param $_ is required.";
    }
 
    $args{endpoint} ||= 'https://api.enterprise.apigee.com/v1';
    $args{timeout}  ||= 60;                                       # for ua timeout
 
    return bless \%args, $class;
}
 
sub __ua {
    my $self = shift;
 
    return $self->{ua} if exists $self->{ua};

lib/Apigee/Edge.pm  view on Meta::CPAN

231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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;
    }

lib/Apigee/Edge.pm  view on Meta::CPAN

290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
required. organization name.
 
=item * usr
 
required. login email
 
=item * pwd
 
required. login password
 
=item * endpoint
 
 
=back
 
=head2 Apps
 
 
=head3 get_app



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