Apigee-Edge
view release on metacpan or search on metacpan
examples/api_products.pl view on Meta::CPAN
use Apigee::Edge;
use Data::Dumper;
die "ENV APIGEE_ORG/APIGEE_USR/APIGEE_PWD is required." unless $ENV{APIGEE_ORG} and $ENV{APIGEE_USR} and $ENV{APIGEE_PWD};
my $apigee = Apigee::Edge->new(
org => $ENV{APIGEE_ORG},
usr => $ENV{APIGEE_USR},
pwd => $ENV{APIGEE_PWD}
);
# say "Create API Product...";
# my $product = $apigee->create_api_product(
# "approvalType" => "manual",
# "attributes" => [
# {
# "name" => "access",
# "value" => "private"
# },
# {
# "name" => "ATTR2",
# "value" => "V2"
examples/api_products.pl view on Meta::CPAN
# "displayName" => "TEST PRODUCT NAME",
# "name" => "test-product-name",
# "apiResources" => [ "/resource1", "/resource2"],
# "environments" => [ "test", "prod"],
# # "proxies" => ["{proxy1}", "{proxy2}", ...],
# # "quota" => "{quota}",
# # "quotaInterval" => "{quota_interval}",
# # "quotaTimeUnit" => "{quota_unit}",
# "scopes" => ["user", "repos"]
# );
# say Dumper(\$product);
# say "Get API Products...";
# my $products = $apigee->get_api_products(expand => 'true');
# say Dumper(\$products);
# say "Search API Products...";
# my $products = $apigee->search_api_products('attributename' => 'access', 'attributevalue' => 'public', expand => 'true');
# say Dumper(\$products);
# say "Update API Product...";
# my $product = $apigee->update_api_product(
# "test-product-name",
# {
# "approvalType" => "auto",
# "displayName" => "TEST PRODUCT NAME 4",
# }
# );
# say Dumper(\$product);
# say "Get API Product...";
# my $product = $apigee->get_api_product("test-product-name");
# say Dumper(\$product);
say "Get API Product Apps...";
my $apps = $apigee->get_api_product_details(
'test-product-name',
query => 'list', entity => 'apps' # or query => 'count', entity => 'keys, apps, developers, or companies'
);
say Dumper(\$apps);
1;
examples/apps.pl view on Meta::CPAN
use Apigee::Edge;
use Data::Dumper;
die "ENV APIGEE_ORG/APIGEE_USR/APIGEE_PWD is required." unless $ENV{APIGEE_ORG} and $ENV{APIGEE_USR} and $ENV{APIGEE_PWD};
my $apigee = Apigee::Edge->new(
org => $ENV{APIGEE_ORG},
usr => $ENV{APIGEE_USR},
pwd => $ENV{APIGEE_PWD}
);
say "Get Apps...";
my $apps = $apigee->get_apps(expand => 'true', includeCred => 'true');
say Dumper(\$apps);
1;
examples/developer.pl view on Meta::CPAN
use Apigee::Edge;
use Data::Dumper;
die "ENV APIGEE_ORG/APIGEE_USR/APIGEE_PWD is required." unless $ENV{APIGEE_ORG} and $ENV{APIGEE_USR} and $ENV{APIGEE_PWD};
my $apigee = Apigee::Edge->new(
org => $ENV{APIGEE_ORG},
usr => $ENV{APIGEE_USR},
pwd => $ENV{APIGEE_PWD}
);
say "Create Developer...";
my $developer = $apigee->create_developer(
"email" => 'fayland@binary.com',
"firstName" => "Fayland",
"lastName" => "Lam",
"userName" => "fayland.binary",
"attributes" => [
{
"name" => "Attr1",
"value" => "V1"
},
{
"name" => "A2",
"value" => "V2.v2"
}
]
) or die $apigee->errstr;
say Dumper(\$developer);
sleep 2;
say "Get Developer...";
my $developer = $apigee->get_developer('fayland@binary.com') or die $apigee->errstr;
say Dumper(\$developer);
sleep 1;
say "Get Developers...";
my $developers = $apigee->get_developers() or die $apigee->errstr;
say Dumper(\$developers);
sleep 1;
say "Delete Developer...";
my $developer = $apigee->delete_developer('fayland@binary.com') or die $apigee->errstr;
print Dumper(\$developer);
1;
examples/developer_app.pl view on Meta::CPAN
die "ENV APIGEE_ORG/APIGEE_USR/APIGEE_PWD is required." unless $ENV{APIGEE_ORG} and $ENV{APIGEE_USR} and $ENV{APIGEE_PWD};
my $apigee = Apigee::Edge->new(
org => $ENV{APIGEE_ORG},
usr => $ENV{APIGEE_USR},
pwd => $ENV{APIGEE_PWD}
);
my $email = 'fayland@binary.com';
say "Create Apps...";
my $app = $apigee->create_developer_app(
$email,
{
"name" => "Test App",
# "apiProducts" => [ "{apiproduct1}", "{apiproduct2}" ],
"keyExpiresIn" => "3600000",
"attributes" => [
{
"name" => "DisplayName",
"value" => "{display_name_value}"
examples/developer_app.pl view on Meta::CPAN
"value" => "{notes_for_developer_app}"
},
{
"name" => "{custom_attribute_name}",
"value" => "{custom_attribute_value}"
}
],
# "callbackUrl" : "{url}",
}
);
say Dumper(\$app);
say "Get Apps...";
my $apps = $apigee->get_developer_apps($email);
say Dumper(\$apps);
1;
xt/helper.t view on Meta::CPAN
org => $ENV{APIGEE_ORG},
usr => $ENV{APIGEE_USR},
pwd => $ENV{APIGEE_PWD}
);
my $email = 'fayland@binary.com';
## cleanup
$apigee->delete_developer($email);;
say "Register Apps...";
my $app = $apigee->refresh_developer_app(
email => $email,
name => 'Fayland Test App',
callbackUrl => 'http://fayland.me/oauth/callback',
# apiProducts => ['ProductName'],
firstName => 'Fayland',
lastName => 'Lam',
userName => 'fayland.binary',
);
# say Dumper(\$app);
ok($app->{appId});
is($app->{callbackUrl}, 'http://fayland.me/oauth/callback');
is($app->{name}, 'Fayland Test App');
is($app->{display_name}, 'Fayland Test App');
ok($app->{credentials});
ok($apigee->errstr =~ /registered/);
say "Get Clients...";
my $clients = $apigee->get_all_clients();
ok(grep { $_ eq $app->{credentials}->[0]->{consumerKey} } keys %$clients);
ok(grep { $_ eq 'Fayland Test App' } values %$clients);
say "Update Apps...";
$app = $apigee->refresh_developer_app(
app => $app,
email => $email,
name => 'Fayland Test App Changed',
callbackUrl => 'http://fayland.me/oauth/callback_changed',
# apiProducts => ['ProductName'],
firstName => 'Fayland',
lastName => 'Lam',
userName => 'fayland.binary',
);
# say Dumper(\$app);
ok($app->{appId});
is($app->{callbackUrl}, 'http://fayland.me/oauth/callback_changed');
is($app->{name}, 'Fayland Test App'); # this is not changed
is($app->{display_name}, 'Fayland Test App Changed');
ok($app->{credentials});
ok($apigee->errstr =~ /Update successful/);
say "Get Clients...";
my $clients = $apigee->get_all_clients();
ok(grep { $_ eq $app->{credentials}->[0]->{consumerKey} } keys %$clients);
ok(grep { $_ eq 'Fayland Test App Changed' } values %$clients);
done_testing();
1;
( run in 3.481 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )