Apigee-Edge
view release on metacpan or search on metacpan
313233343536373839404142434445464748495051
required. organization name.
- usr
required. login email
- pwd
required. login password
- endpoint
## Apps
### get\_app
my
$app
=
$apigee
->get_app(
$app_id
);
lib/Apigee/Edge.pm view on Meta::CPAN
1415161718192021222324252627282930313233sub
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
{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
231232233234235236237238239240241242243244245246247248249250251sub
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
290291292293294295296297298299300301302303304305306307308309310required. 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
=head3 get_app
( run in 0.429 second using v1.01-cache-2.11-cpan-26ccb49234f )