Akamai-PropertyFetcher
view release on metacpan or search on metacpan
lib/Akamai/PropertyFetcher.pm view on Meta::CPAN
my ($staging_version, $production_version);
foreach my $activation (sort { $b->{propertyVersion} <=> $a->{propertyVersion} } @{ $activations_data->{activations}->{items} }) {
if (!defined $staging_version && $activation->{network} eq 'STAGING' && $activation->{status} eq 'ACTIVE') {
$staging_version = $activation->{propertyVersion};
}
if (!defined $production_version && $activation->{network} eq 'PRODUCTION' && $activation->{status} eq 'ACTIVE') {
$production_version = $activation->{propertyVersion};
}
}
# If no active version found, skip to the next property
unless (defined $staging_version || defined $production_version) {
warn "No active version found for property ($property_name) - Skipping\n";
$pm->finish;
}
# Retrieve and save staging version details if an active version is found
if (defined $staging_version) {
my $staging_rules_endpoint = "$baseurl/papi/v1/properties/$property_id/versions/$staging_version/rules?contractId=$contract_id&groupId=$group_id";
my $staging_rules_resp = $agent->get($staging_rules_endpoint);
if ($staging_rules_resp->is_success) {
my $staging_rules_content = $staging_rules_resp->decoded_content;
my $staging_file_path = File::Spec->catfile($property_dir, "staging.json");
open my $fh, '>', $staging_file_path or die "Failed to create file: $staging_file_path";
print $fh $staging_rules_content;
close $fh;
print "Saved staging environment active property details: $staging_file_path\n";
} else {
warn "Error retrieving staging version details ($property_name): " . $staging_rules_resp->status_line . " - Skipping\n";
}
}
# Retrieve and save production version details if an active version is found
if (defined $production_version) {
my $production_rules_endpoint = "$baseurl/papi/v1/properties/$property_id/versions/$production_version/rules?contractId=$contract_id&groupId=$group_id";
my $production_rules_resp = $agent->get($production_rules_endpoint);
if ($production_rules_resp->is_success) {
my $production_rules_content = $production_rules_resp->decoded_content;
my $production_file_path = File::Spec->catfile($property_dir, "production.json");
open my $fh, '>', $production_file_path or die "Failed to create file: $production_file_path";
print $fh $production_rules_content;
close $fh;
print "Saved production environment active property details: $production_file_path\n";
} else {
warn "Error retrieving production version details ($property_name): " . $production_rules_resp->status_line . " - Skipping\n";
}
}
} else {
warn "Error retrieving activation information ($property_name): " . $activations_resp->status_line . " - Skipping\n";
}
# End the child process
$pm->finish;
}
} elsif ($properties_resp->code == 403 || $properties_resp->code == 404) {
warn "Error retrieving property list (Contract ID: $contract_id, Group ID: $group_id): " . $properties_resp->status_line . " - Skipping\n";
} else {
die "Unexpected error (Contract ID: $contract_id, Group ID: $group_id): " . $properties_resp->status_line;
}
}
}
# å
¨ã¦ã®åããã»ã¹ã®çµäºãå¾
æ©
$pm->wait_all_children;
}
1;
__END__
=head1 NAME
Akamai::PropertyFetcher - Akamaiããããã£ã®ã¢ã¯ãã£ããã¼ã¸ã§ã³æ
å ±ãåå¾ããã¢ã¸ã¥ã¼ã«
=head1 SYNOPSIS
use Akamai::PropertyFetcher;
my $fetcher = Akamai::PropertyFetcher->new(
config_file => "$ENV{HOME}/.edgerc",
max_processes => 4
);
$fetcher->retrieve_property_data();
=head1 DESCRIPTION
Akamai::PropertyFetcherã¯ãAkamaiã®APIããããããã£ã®ã¢ã¯ãã£ããã¼ã¸ã§ã³è©³ç´°ãåå¾ãããã¼ã«ã«ã«ä¿åããã¤ã³ã¿ã¼ãã§ã¼ã¹ãæä¾ãã¾ãã
=head1 METHODS
=head2 new
my $fetcher = Akamai::PropertyFetcher->new(%args);
Fetcherãåæåãã¾ãã弿°:
=over
=item * config_file
.edgercãã¡ã¤ã«ã®ãã¹ãããã©ã«ãã¯C<$ENV{HOME}/.edgerc>ã
=item * max_processes
並åããã»ã¹ã®æå¤§æ°ãããã©ã«ãã¯4ã
=back
=head2 retrieve_property_data
ããããã£ãã¼ã¿ãåå¾ãã¦ä¿åãã¾ãã
=head1 AUTHOR
( run in 1.493 second using v1.01-cache-2.11-cpan-bbb979687b5 )