Artifactory-Client
view release on metacpan or search on metacpan
## delete\_local\_multi\_push\_replication( $url )
Deletes a local multi-push replication configuration. Supported by local and local-cached repositories
## 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.
## get\_global\_system\_replication\_configuration
Returns the global system replication configuration status, i.e. if push and pull replications are blocked or unblocked.
## get\_remote\_repositories\_registered\_for\_replication
Returns a list of all the listeners subscribed for event-based pull replication on the specified repository.
## 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.
## 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.
## 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.
## file\_list( $dir, %opts )
## 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.
## retrieve\_user\_lock\_policy
Retrieves the currently configured user lock policy.
## get\_locked\_out\_users
If locking out users is enabled, lists all users that were locked out due to recurrent incorrect login attempts.
## unlock\_locked\_out\_user
Unlocks a single user that was locked out due to recurrent incorrect login attempts.
## unlock\_locked\_out\_users
Unlocks a list of users that were locked out due to recurrent incorrect login attempts.
## unlock\_all\_locked\_out\_users
Unlocks all users that were locked out due to recurrent incorrect login attempts.
## create\_api\_key( apiKey => '3OloposOtVFyCMrT+cXmCAScmVMPrSYXkWIjiyDCXsY=' )
Create an API key for the current user
## get\_api\_key
Get the current user's own API key
## revoke\_api\_key
Returned default Export Settings JSON
## export\_system( exportPath => '/export/path', includeMetadata => 'true' etc )
Export full system to a server local directory
## 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.
## 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.
## 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).
## create\_bundle( %hash of data structure )
Create a new support bundle
lib/Artifactory/Client.pm view on Meta::CPAN
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
lib/Artifactory/Client.pm view on Meta::CPAN
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 )
lib/Artifactory/Client.pm view on Meta::CPAN
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
lib/Artifactory/Client.pm view on Meta::CPAN
=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
t/01_unit.t view on Meta::CPAN
subtest 'retrieve_user_lock_policy', sub {
my $client = setup();
local *{'LWP::UserAgent::get'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->retrieve_user_lock_policy();
is( $resp->code, 200, 'request succeeded' );
};
subtest 'get_locked_out_users', sub {
my $client = setup();
local *{'LWP::UserAgent::get'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->get_locked_out_users();
is( $resp->code, 200, 'request succeeded' );
};
subtest 'unlock_locked_out_user', sub {
my $client = setup();
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->unlock_locked_out_user('admin');
is( $resp->code, 200, 'request succeeded' );
};
subtest 'unlock_locked_out_users', sub {
my $client = setup();
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->unlock_locked_out_users( 'admin', 'davids' );
is( $resp->code, 200, 'request succeeded' );
};
subtest 'unlock_all_locked_out_users', sub {
my $client = setup();
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->unlock_all_locked_out_users();
is( $resp->code, 200, 'request succeeded' );
};
subtest 'create_api_key', sub {
my $client = setup();
my %data = ( apiKey => '3OloposOtVFyCMrT+cXmCAScmVMPrSYXkWIjiyDCXsY=' );
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->create_api_key(%data);
t/01_unit.t view on Meta::CPAN
subtest 'ignore_xray_alert', sub {
my $client = setup();
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->ignore_xray_alert('/foo');
is( $resp->code, 200, 'request succeeded' );
};
subtest 'allow_download_of_blocked_artifacts', sub {
my $client = setup();
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->allow_download_of_blocked_artifacts('true');
is( $resp->code, 200, 'request succeeded' );
};
subtest 'allow_download_when_xray_is_unavailable', sub {
my $client = setup();
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->allow_download_when_xray_is_unavailable('true');
is( $resp->code, 200, 'request succeeded' );
( run in 0.540 second using v1.01-cache-2.11-cpan-49f99fa48dc )