Artifactory-Client

 view release on metacpan or  search on metacpan

lib/Artifactory/Client.pm  view on Meta::CPAN

    return $self->post(
        $url,
        "Content-Type" => 'application/json',
        Content        => $self->_json->encode($payload)
    );
}

=head2 create_or_replace_local_multi_push_replication( $payload )

Creates or replaces a local multi-push replication configuration. Supported by local and local-cached repositories

=cut

sub create_or_replace_local_multi_push_replication {
    my ( $self, $payload ) = @_;
    return $self->_handle_multi_push_replication( $payload, 'put' );
}

=head2 update_local_multi_push_replication( $payload )

Updates a local multi-push replication configuration. Supported by local and local-cached repositories

=cut

sub update_local_multi_push_replication {
    my ( $self, $payload ) = @_;
    return $self->_handle_multi_push_replication( $payload, 'post' );
}

=head2 delete_local_multi_push_replication( $url )

Deletes a local multi-push replication configuration. Supported by local and local-cached repositories

=cut

sub delete_local_multi_push_replication {
    my ( $self, $url, %args ) = @_;
    my $repository = $args{repository} || $self->repository();
    my $call_url = $self->_api_url() . "/replications/$repository?url=$url";
    return $self->delete($call_url);
}

=head2 enable_or_disable_multiple_replications( 'enable|disable', include => [ ], exclude => [ ] )

Enables/disables multiple replication tasks by repository or Artifactory server based in include and exclude patterns.

=cut

sub enable_or_disable_multiple_replications {
    my ( $self, $flag, %args ) = @_;
    my $url = $self->_api_url() . "/replications/$flag";
    return $self->post(
        $url,
        "Content-Type" => 'application/json',
        Content        => $self->_json->encode( \%args )
    );
}

=head2 get_global_system_replication_configuration

Returns the global system replication configuration status, i.e. if push and pull replications are blocked or unblocked.

=cut

sub get_global_system_replication_configuration {
    my $self = shift;
    my $url  = $self->_api_url() . "/system/replications";
    return $self->get($url);
}

=head2 get_remote_repositories_registered_for_replication

Returns a list of all the listeners subscribed for event-based pull replication on the specified repository.

=cut

sub get_remote_repositories_registered_for_replication {
    my ( $self, $repo ) = @_;
    my $repository = $repo || $self->repository();

    my $url  = $self->_api_url() . "/replications/$repository";
    return $self->get($url);
}

=head2 block_system_replication( push => 'false', pull => 'true' )

Blocks replications globally. Push and pull are true by default. If false, replication for the corresponding type is not
blocked.

=cut

sub block_system_replication {
    my ( $self, %args ) = @_;
    return $self->_handle_block_system_replication( 'block', %args );
}

=head2 unblock_system_replication( push => 'false', pull => 'true' )

Unblocks replications globally. Push and pull are true by default. If false, replication for the corresponding type is
not unblocked.

=cut

sub unblock_system_replication {
    my ( $self, %args ) = @_;
    return $self->_handle_block_system_replication( 'unblock', %args );
}

=head2 artifact_sync_download( $path, content => 'progress', mark => 1000 )

Downloads an artifact with or without returning the actual content to the client. When tracking the progress marks are
printed (by default every 1024 bytes). This is extremely useful if you want to trigger downloads on a remote Artifactory
server, for example to force eager cache population of large artifacts, but want to avoid the bandwidth consumption
involved in transferring the artifacts to the triggering client. If no content parameter is specified the file content
is downloaded to the client.

=cut

sub artifact_sync_download {
    my ( $self, $path, %args ) = @_;
    my $repository = $args{repository} || $self->repository();
    my $url = $self->_api_url() . "/download/$repository" . $path;
    $url .= "?" . $self->_stringify_hash( '&', %args ) if (%args);
    return $self->get($url);
}

=head2 file_list( $dir, %opts )

Get a flat (the default) or deep listing of the files and folders (not included by default) within a folder

=cut

sub file_list {
    my ( $self, $dir, %opts ) = @_;
    $dir = $self->_merge_repo_and_path($dir);
    my $url = $self->_api_url() . "/storage/$dir?list";

    for my $opt ( keys %opts ) {
        my $val = $opts{$opt};
        $url .= "&${opt}=$val";
    }
    return $self->get($url);
}

=head2 get_background_tasks

Retrieves list of background tasks currently scheduled or running in Artifactory. In HA, the nodeId is added to each
task. Task can be in one of few states: scheduled, running, stopped, canceled. Running task also shows the task start
time.

=cut

sub get_background_tasks {
    my $self = shift;
    my $url  = $self->_api_url() . "/tasks";
    return $self->get($url);
}

=head2 empty_trash_can

lib/Artifactory/Client.pm  view on Meta::CPAN

    );
}

=head2 get_password_expiration_policy

Retrieves the password expiration policy

=cut

sub get_password_expiration_policy {
    my $self = shift;
    my $url  = $self->_api_url() . "/security/configuration/passwordExpirationPolicy";
    return $self->get($url);
}

=head2 set_password_expiration_policy

Sets the password expiration policy

=cut

sub set_password_expiration_policy {
    my ( $self, %info ) = @_;
    my $url = $self->_api_url() . "/security/configuration/passwordExpirationPolicy";
    return $self->put(
        $url,
        'Content-Type' => 'application/json',
        content        => $self->_json->encode( \%info )
    );
}

=head2 configure_user_lock_policy( enabled => 'true|false', loginAttempts => $num )

Configures the user lock policy that locks users out of their account if the number of repeated incorrect login attempts
exceeds the configured maximum allowed.

=cut

sub configure_user_lock_policy {
    my ( $self, %info ) = @_;
    my $url = $self->_api_url() . "/security/userLockPolicy";
    return $self->put(
        $url,
        'Content-Type' => 'application/json',
        content        => $self->_json->encode( \%info )
    );
}

=head2 retrieve_user_lock_policy

Retrieves the currently configured user lock policy.

=cut

sub retrieve_user_lock_policy {
    my $self = shift;
    my $url  = $self->_api_url() . "/security/userLockPolicy";
    return $self->get($url);
}

=head2 get_locked_out_users

If locking out users is enabled, lists all users that were locked out due to recurrent incorrect login attempts.

=cut

sub get_locked_out_users {
    my $self = shift;
    my $url  = $self->_api_url() . "/security/lockedUsers";
    return $self->get($url);
}

=head2 unlock_locked_out_user

Unlocks a single user that was locked out due to recurrent incorrect login attempts.

=cut

sub unlock_locked_out_user {
    my ( $self, $name ) = @_;
    my $url = $self->_api_url() . "/security/unlockUsers/$name";
    return $self->post($url);
}

=head2 unlock_locked_out_users

Unlocks a list of users that were locked out due to recurrent incorrect login attempts.

=cut

sub unlock_locked_out_users {
    my ( $self, @users ) = @_;
    my $url = $self->_api_url() . "/security/unlockUsers";
    return $self->post(
        $url,
        'Content-Type' => 'application/json',
        content        => $self->_json->encode( \@users )
    );
}

=head2 unlock_all_locked_out_users

Unlocks all users that were locked out due to recurrent incorrect login attempts.

=cut

sub unlock_all_locked_out_users {
    my $self = shift;
    my $url  = $self->_api_url() . "/security/unlockAllUsers";
    return $self->post($url);
}

=head2 create_api_key( apiKey => '3OloposOtVFyCMrT+cXmCAScmVMPrSYXkWIjiyDCXsY=' )

Create an API key for the current user

=cut

sub create_api_key {
    my ( $self, %args ) = @_;
    return $self->_handle_api_key( 'post', %args );
}

=head2 get_api_key

Get the current user's own API key

=cut

sub get_api_key {
    my $self = shift;
    return $self->_handle_api_key('get');
}

=head2 revoke_api_key

Revokes the current user's API key

=cut

sub revoke_api_key {
    my $self = shift;
    return $self->_handle_revoke_api_key('/apiKey/auth');
}

=head2 revoke_user_api_key

Revokes the API key of another user

=cut

sub revoke_user_api_key {
    my ( $self, $user ) = @_;
    return $self->_handle_revoke_api_key("/apiKey/auth/$user");
}

=head2 revoke_all_api_keys

Revokes all API keys currently defined in the system

=cut

sub revoke_all_api_keys {
    my ( $self, %args ) = @_;
    my $deleteall = ( defined $args{deleteAll} ) ? $args{deleteAll} : 1;
    return $self->_handle_revoke_api_key("/apiKey?deleteAll=$deleteall");
}

lib/Artifactory/Client.pm  view on Meta::CPAN


Import one or more repositories

=cut

sub import_repository_content {
    my ( $self, %args ) = @_;

    my $url = $self->_api_url() . "/import/repositories?";
    $url .= $self->_stringify_hash( '&', %args );
    return $self->post($url);
}

=head2 import_system_settings_example

Returned default Import Settings JSON

=cut

sub import_system_settings_example {
    my $self = shift;
    return $self->_handle_system_settings('import');
}

=head2 full_system_import( importPath => '/import/path', includeMetadata => 'false' etc )

Import full system from a server local Artifactory export directory

=cut

sub full_system_import {
    my ( $self, %args ) = @_;
    return $self->_handle_system_settings( 'import', %args );
}

=head2 export_system_settings_example

Returned default Export Settings JSON

=cut

sub export_system_settings_example {
    my $self = shift;
    return $self->_handle_system_settings('export');
}

=head2 export_system( exportPath => '/export/path', includeMetadata => 'true' etc )

Export full system to a server local directory

=cut

sub export_system {
    my ( $self, %args ) = @_;
    return $self->_handle_system_settings( 'export', %args );
}

=head2 ignore_xray_alert( $path )

Sets an alert to be ignored until next time the repository hosting the artifact about which the alert was issued, is scanned. Note that this endpoint does not
affect artifacts that are blocked because they have not been scanned at all.

=cut

sub ignore_xray_alert {
    my ( $self, $path ) = @_;
    my $url = $self->_api_url() . "/xray/setAlertIgnored?path=$path";
    return $self->post($url);
}

=head2 allow_download_of_blocked_artifacts( 'true'|'false' )

When a repository is configured to block downloads of artifacts, you may override that configuration (and allow download of blocked artifacts). Note that this
setting cannot override the blocking of unscanned artifacts.

=cut

sub allow_download_of_blocked_artifacts {
    my ( $self, $bool ) = @_;
    my $url = $self->_api_url() . "/xray/allowBlockedArtifactsDownload?allow=$bool";
    return $self->post($url);
}

=head2 allow_download_when_xray_is_unavailable( 'true'|'false' )

You may configure Artifactory to block downloads of artifacts when the connected Xray instance is unavailable. This endpoint lets you override that
configuration (and allow download of artifacts).

=cut

sub allow_download_when_xray_is_unavailable {
    my ( $self, $bool ) = @_;
    my $url = $self->_api_url() . "/xray/allowDownloadWhenUnavailable?allow=$bool";
    return $self->post($url);
}

=head2 create_bundle( %hash of data structure )

Create a new support bundle

=cut

sub create_bundle {
    my ( $self, %args ) = @_;
    my $url = $self->_api_url() . '/support/bundles';
    %args = () unless %args;

    return $self->post(
        $url,
        "Content-Type" => 'application/json',
        Content        => $self->_json->encode( \%args )
    );
}

=head2 list_bundles

Lists previously created bundle currently stored in the system

=cut

sub list_bundles {
    my $self = shift;
    my $url  = $self->_api_url() . '/support/bundles';
    return $self->get( $url, "Content-Type" => 'application/json', );
}

=head2 get_bundle_metadata( $name )

Downloads a previously created bundle currently stored in the system

=cut

sub get_bundle_metadata {
    my ( $self, $bundle ) = @_;
    my $url = $self->_api_url() . '/support/bundles/' . $bundle;
    return $self->get( $url, "Content-Type" => 'application/json', );
}

=head2 get_bundle( $name )



( run in 1.895 second using v1.01-cache-2.11-cpan-40ba7b3775d )