Artifactory-Client

 view release on metacpan or  search on metacpan

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

    my $url = $self->_art_url() . "/$path";
    return $self->delete($url);
}

=head2 copy_item( from => $from, to => $to, dry => 1, suppressLayouts => 0/1, failFast => 0/1 )

Copies an artifact from $from to $to.  Note that for this particular API call, the $from and $to must include repository
names as copy source and destination may be different repositories.  You can also supply dry, suppressLayouts and
failFast values as specified in the documentation.

=cut

sub copy_item {
    my ( $self, %args ) = @_;
    $args{method} = 'copy';
    return $self->_handle_item(%args);
}

=head2 move_item( from => $from, to => $to, dry => 1, suppressLayouts => 0/1, failFast => 0/1 )

Moves an artifact from $from to $to.  Note that for this particular API call, the $from and $to must include repository
names as copy source and destination may be different repositories.  You can also supply dry, suppressLayouts and
failFast values as specified in the documentation.

=cut

sub move_item {
    my ( $self, %args ) = @_;
    $args{method} = 'move';
    return $self->_handle_item(%args);
}

=head2 get_repository_replication_configuration

Get repository replication configuration

=cut

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

=head2 set_repository_replication_configuration( $payload )

Set repository replication configuration

=cut

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

=head2 update_repository_replication_configuration( $payload )

Update repository replication configuration

=cut

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

=head2 delete_repository_replication_configuration

Delete repository replication configuration

=cut

sub delete_repository_replication_configuration {
    my $self = shift;
    return $self->_handle_repository_replication_configuration('delete');
}

=head2 scheduled_replication_status

Gets scheduled replication status of a repository

=cut

sub scheduled_replication_status {
    my ( $self, %args ) = @_;
    my $repository = $args{repository} || $self->repository();
    my $url = $self->_api_url() . "/replication/$repository";
    return $self->get($url);
}

=head2 pull_push_replication( payload => $payload, path => $path )

Schedules immediate content replication between two Artifactory instances

=cut

sub pull_push_replication {
    my ( $self, %args ) = @_;
    my $payload = $args{payload};
    my $path    = $args{path};
    $path = $self->_merge_repo_and_path($path);
    my $url = $self->_api_url() . "/replication/execute/$path";
    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' )

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

    my $url = $self->_api_url() . "/docker/$repository/v2/$image_name/tags/list";
    $url .= '?' . $self->_stringify_hash( '&', %args ) if (%args);

    return $self->get($url);
}

=head1 SECURITY

=cut

=head2 get_users

Get the users list

=cut

sub get_users {
    my $self = shift;
    return $self->_handle_security( undef, 'get', 'users' );
}

=head2 get_user_details( $user )

Get the details of an Artifactory user

=cut

sub get_user_details {
    my ( $self, $user ) = @_;
    return $self->_handle_security( $user, 'get', 'users' );
}

=head2 get_user_encrypted_password

Get the encrypted password of the authenticated requestor

=cut

sub get_user_encrypted_password {
    my $self = shift;
    return $self->_handle_security( undef, 'get', 'encryptedPassword' );
}

=head2 create_or_replace_user( $user, %args )

Creates a new user in Artifactory or replaces an existing user

=cut

sub create_or_replace_user {
    my ( $self, $user, %args ) = @_;
    return $self->_handle_security( $user, 'put', 'users', %args );
}

=head2 update_user( $user, %args )

Updates an exiting user in Artifactory with the provided user details

=cut

sub update_user {
    my ( $self, $user, %args ) = @_;
    return $self->_handle_security( $user, 'post', 'users', %args );
}

=head2 delete_user( $user )

Removes an Artifactory user

=cut

sub delete_user {
    my ( $self, $user ) = @_;
    return $self->_handle_security( $user, 'delete', 'users' );
}

=head2 expire_password_for_a_single_user( $user )

Expires a user's password

=cut

sub expire_password_for_a_single_user {
    my ( $self, $user ) = @_;
    my $url = $self->_api_url() . "/security/users/authorization/expirePassword/$user";
    return $self->post($url);
}

=head2 expire_password_for_multiple_users( $user1, $user2 )

Expires password for a list of users

=cut

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

=head2 expire_password_for_all_users

Expires password for all users

=cut

sub expire_password_for_all_users {
    my ( $self, @users ) = @_;
    my $url = $self->_api_url() . "/security/users/authorization/expirePasswordForAllUsers";
    return $self->post($url);
}

=head2 unexpire_password_for_a_single_user( $user )

Unexpires a user's password

=cut

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

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");
}

=head2 get_groups

Get the groups list

=cut

sub get_groups {
    my $self = shift;
    return $self->_handle_security( undef, 'get', 'groups' );
}

=head2 get_group_details( $group )

Get the details of an Artifactory Group

=cut

sub get_group_details {
    my ( $self, $group ) = @_;
    return $self->_handle_security( $group, 'get', 'groups' );
}

=head2 create_or_replace_group( $group, %args )

Creates a new group in Artifactory or replaces an existing group

=cut

sub create_or_replace_group {
    my ( $self, $group, %args ) = @_;
    return $self->_handle_security( $group, 'put', 'groups', %args );
}

=head2 update_group( $group, %args )

Updates an exiting group in Artifactory with the provided group details

=cut

sub update_group {
    my ( $self, $group, %args ) = @_;
    return $self->_handle_security( $group, 'post', 'groups', %args );
}

=head2 delete_group( $group )

Removes an Artifactory group

=cut

sub delete_group {
    my ( $self, $group ) = @_;
    return $self->_handle_security( $group, 'delete', 'groups' );
}

=head2 get_permission_targets

Get the permission targets list

=cut

sub get_permission_targets {
    my $self = shift;
    return $self->_handle_security( undef, 'get', 'permissions' );
}

=head2 get_permission_target_details( $name )

Get the details of an Artifactory Permission Target

=cut

sub get_permission_target_details {
    my ( $self, $name ) = @_;
    return $self->_handle_security( $name, 'get', 'permissions' );
}

=head2 create_or_replace_permission_target( $name, %args )

Creates a new permission target in Artifactory or replaces an existing permission target

=cut

sub create_or_replace_permission_target {
    my ( $self, $name, %args ) = @_;
    return $self->_handle_security( $name, 'put', 'permissions', %args );
}

=head2 delete_permission_target( $name )

Deletes an Artifactory permission target

=cut

sub delete_permission_target {
    my ( $self, $name ) = @_;
    return $self->_handle_security( $name, 'delete', 'permissions' );
}

=head2 effective_item_permissions( $path )

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

    return $self->delete($url);
}

=head1 REPOSITORIES

=cut

=head2 get_repositories( $type )

Returns a list of minimal repository details for all repositories of the specified type

=cut

sub get_repositories {
    my ( $self, $type ) = @_;

    my $url = $self->_api_url() . "/repositories";
    $url .= "?type=$type" if ($type);

    return $self->get($url);
}

=head2 repository_configuration( $name, %args )

Retrieves the current configuration of a repository

=cut

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

    $repo =~ s{^\/}{}xi;
    $repo =~ s{\/$}{}xi;

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

=head2 create_or_replace_repository_configuration( $name, \%payload, %args )

Creates a new repository in Artifactory with the provided configuration or replaces the configuration of an existing
repository

=cut

sub create_or_replace_repository_configuration {
    my ( $self, $repo, $payload, %args ) = @_;
    return $self->_handle_repositories( $repo, $payload, 'put', %args );
}

=head2 update_repository_configuration( $name, \%payload )

Updates an exiting repository configuration in Artifactory with the provided configuration elements

=cut

sub update_repository_configuration {
    my ( $self, $repo, $payload ) = @_;
    return $self->_handle_repositories( $repo, $payload, 'post' );
}

=head2 delete_repository( $name )

Removes a repository configuration together with the whole repository content

=cut

sub delete_repository {
    my ( $self, $repo ) = @_;
    return $self->_handle_repositories( $repo, undef, 'delete' );
}

=head2 calculate_yum_repository_metadata( async => 0/1 )

Calculates/recalculates the YUM metdata for this repository, based on the RPM package currently hosted in the repository

=cut

sub calculate_yum_repository_metadata {
    my ( $self, %args ) = @_;
    my $repository = $args{repository} || $self->repository();
    return $self->_handle_repository_reindex( "/yum/$repository", %args );
}

=head2 calculate_nuget_repository_metadata

Recalculates all the NuGet packages for this repository (local/cache/virtual), and re-annotate the NuGet properties for
each NuGet package according to it's internal nuspec file

=cut

sub calculate_nuget_repository_metadata {
    my ( $self, %args ) = @_;
    my $repository = $args{repository} || $self->repository();
    return $self->_handle_repository_reindex("/nuget/$repository/reindex");
}

=head2 calculate_npm_repository_metadata

Recalculates the npm search index for this repository (local/virtual). Please see the Npm integration documentation for
more details.

=cut

sub calculate_npm_repository_metadata {
    my ( $self, %args ) = @_;
    my $repository = $args{repository} || $self->repository();
    return $self->_handle_repository_reindex("/npm/$repository/reindex");
}

=head2 calculate_maven_index( repos => [ 'repo1', 'repo2' ], force => 0/1 )

Calculates/caches a Maven index for the specified repositories

=cut

sub calculate_maven_index {

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


=cut

sub verify_connection {
    my ( $self, %args ) = @_;
    my $url = $self->_api_url() . "/system/verifyconnection";

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

=head2 system_health_ping

Get a simple status response about the state of Artifactory

=cut

sub system_health_ping {
    my $self = shift;
    return $self->_handle_system('ping');
}

=head2 general_configuration

Get the general configuration (artifactory.config.xml)

=cut

sub general_configuration {
    my $self = shift;
    return $self->_handle_system('configuration');
}

=head2 save_general_configuration( $file )

Save the general configuration (artifactory.config.xml)

=cut

sub save_general_configuration {
    my ( $self, $xml ) = @_;

    my $file = Path::Tiny::path($xml)->slurp( { binmode => ":raw" } );
    my $url = $self->_api_url() . "/system/configuration";
    return $self->post(
        $url,
        'Content-Type' => 'application/xml',
        content        => $file
    );
}

=head2 update_custom_url_base( $url )

Changes the Custom URL base

=cut

sub update_custom_url_base {
    my ( $self, $base ) = @_;
    my $url = $self->_api_url() . '/system/configuration/baseUrl';
    return $self->put(
        $url,
        'Content-Type' => 'text/plain',
        content        => $base
    );
}

=head2 license_information

Retrieve information about the currently installed license

=cut

sub license_information {
    my $self = shift;

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

=head2 install_license( $licensekey )

Install new license key or change the current one

=cut

sub install_license {
    my ( $self, $key ) = @_;
    my $url = $self->_api_url() . "/system/license";

    return $self->post(
        $url,
        'Content-Type' => 'application/json',
        content        => $self->_json->encode( { licenseKey => $key } )
    );
}

=head2 ha_license_information

Retrieve information about the currently installed licenses in an HA cluster

=cut

sub ha_license_information {
    my $self = shift;

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

=head2 install_ha_cluster_licenses( [ { licenseKey => 'foobar' }, { licenseKey => 'barbaz' } ] )

Install a new license key(s) on an HA cluster

=cut

sub install_ha_cluster_licenses {
    my ( $self, $ref ) = @_;
    my $url = $self->_api_url() . "/system/licenses";

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

=head2 delete_ha_cluster_license( 'licenseHash1', 'licenseHash2' )

Deletes a license key from an HA cluster

=cut

sub delete_ha_cluster_license {
    my ( $self, @licenses ) = @_;
    my $url = $self->_api_url() . "/system/licenses?";
    $url .= $self->_handle_non_matrix_props( 'licenseHash', \@licenses );
    return $self->delete( $url, 'Content-Type' => 'application/json' );
}

=head2 version_and_addons_information

Retrieve information about the current Artifactory version, revision, and currently installed Add-ons

=cut

sub version_and_addons_information {
    my $self = shift;

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

=head2 get_reverse_proxy_configuration

Retrieves the reverse proxy configuration

=cut

sub get_reverse_proxy_configuration {
    my $self = shift;

    my $url = $self->_api_url() . "/system/configuration/webServer";
    return $self->get($url);
}

=head2 update_reverse_proxy_configuration(%data)

Updates the reverse proxy configuration

=cut

sub update_reverse_proxy_configuration {
    my ( $self, %data ) = @_;

    my $url = $self->_api_url() . "/system/configuration/webServer";
    return $self->post(
        $url,
        'Content-Type' => 'application/json',
        content        => $self->_json->encode( \%data )
    );
}

=head2 get_reverse_proxy_snippet

Gets the reverse proxy configuration snippet in text format

=cut

sub get_reverse_proxy_snippet {
    my $self = shift;

    my $url = $self->_api_url() . "/system/configuration/reverseProxy/nginx";
    return $self->get($url);
}

=head2 start_sha256_migration_task( "batchThreshold" => 10, etc etc )

Starts the SHA-256 migration process.

=cut

sub start_sha256_migration_task {
    my ( $self, %data ) = @_;

    my $url = $self->_api_url() . "/system/migration/sha2/start";
    return $self->post(
        $url,
        'Content-Type' => 'application/json',
        content        => $self->_json->encode( \%data )
    );
}

=head2 stop_sha256_migration_task( "sleepIntervalMillis" => 5000, etc etc )

Stops the SHA-256 migration process

=cut

sub stop_sha256_migration_task {
    my ( $self, %data ) = @_;

    my $url = $self->_api_url() . "/system/migration/sha2/stop";
    return $self->post(
        $url,
        'Content-Type' => 'application/json',
        content        => $self->_json->encode( \%data )
    );
}

=head1 PLUGINS

=cut



( run in 1.906 second using v1.01-cache-2.11-cpan-39bf76dae61 )