Akamai-PropertyFetcher
view release on metacpan or search on metacpan
perl Makefile.PL
make
make test
make install
ä½¿ãæ¹:
use Akamai::PropertyFetcher;
my $fetcher = Akamai::PropertyFetcher->new(
config_file => "$ENV{HOME}/.edgerc",
max_processes => 4
);
$fetcher->retrieve_property_data();
詳細ã¯ããã¥ã¡ã³ããåç
§ãã¦ãã ããã
lib/Akamai/PropertyFetcher.pm view on Meta::CPAN
our $VERSION = '0.01';
sub new {
my ($class, %args) = @_;
my $self = bless {}, $class;
$self->{agent} = Akamai::Edgegrid->new(
config_file => $args{config_file} || "$ENV{HOME}/.edgerc",
section => $args{section} || "default"
);
$self->{max_processes} = $args{max_processes} || 4;
return $self;
}
sub retrieve_property_data {
my ($self) = @_;
my $agent = $self->{agent};
my $pm = Parallel::ForkManager->new($self->{max_processes});
# åºæ¬URL
my $baseurl = "https://" . $agent->{host};
# Endpoint to retrieve contract IDs
my $contracts_endpoint = "$baseurl/papi/v1/contracts";
my $contracts_resp = $agent->get($contracts_endpoint);
die "Error retrieving contract ID: " . $contracts_resp->status_line unless $contracts_resp->is_success;
my $contracts_data = decode_json($contracts_resp->decoded_content);
my @contract_ids = map { $_->{contractId} } @{ $contracts_data->{contracts}->{items} };
lib/Akamai/PropertyFetcher.pm view on Meta::CPAN
foreach my $group_id (@group_ids) {
my $properties_endpoint = "$baseurl/papi/v1/properties?contractId=$contract_id&groupId=$group_id";
my $properties_resp = $agent->get($properties_endpoint);
if ($properties_resp->is_success) {
# Retrieve property information
my $properties_data = decode_json($properties_resp->decoded_content);
my $properties = $properties_data->{properties}->{items};
foreach my $property (@$properties) {
# Fork a new process for each property
$pm->start and next;
my $property_id = $property->{propertyId};
my $property_name = $property->{propertyName};
# Create a directory for the property
my $base_dir = "property";
my $property_dir = File::Spec->catdir($base_dir, $property_name);
make_path($property_dir) unless -d $property_dir;
lib/Akamai/PropertyFetcher.pm view on Meta::CPAN
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;
}
}
}
lib/Akamai/PropertyFetcher.pm view on Meta::CPAN
=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
lib/Akamai/PropertyFetcher.pm view on Meta::CPAN
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 0.231 second using v1.01-cache-2.11-cpan-8d75d55dd25 )