Akamai-PropertyFetcher

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    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 )