GitLab-API-v4
view release on metacpan or search on metacpan
author/header.pm view on Meta::CPAN
package GitLab::API::v4;
our $VERSION = '0.26';
=encoding utf8
=head1 NAME
GitLab::API::v4 - A complete GitLab API v4 client.
=head1 SYNOPSIS
use GitLab::API::v4;
my $api = GitLab::API::v4->new(
url => $v4_api_url,
private_token => $token,
);
my $branches = $api->branches( $project_id );
=head1 DESCRIPTION
This module provides a one-to-one interface with the GitLab
API v4. Much is not documented here as it would just be duplicating
GitLab's own L<API Documentation|http://doc.gitlab.com/ce/api/README.html>.
Note that this distribution also includes the L<gitlab-api-v4> command-line
interface (CLI).
=head2 Upgrading
If you are upgrading from L<GitLab::API::v3> make sure you read:
L<https://docs.gitlab.com/ce/api/v3_to_v4.html>
Also, review the C<Changes> file included in the distribution as it outlines
the changes made to convert the v3 module to v4:
L<https://github.com/bluefeet/GitLab-API-v4/blob/master/Changes>
Finally, be aware that many methods were added, removed, renamed, and/or altered.
If you want to review exactly what was changed you can use GitHub's compare tool:
L<https://github.com/bluefeet/GitLab-API-v4/compare/72e384775c9570f60f8ef68dee3a1eecd347fb69...master>
Or clone the repo and run this command:
C<git diff 72e384775c9570f60f8ef68dee3a1eecd347fb69..HEAD -- author/sections/>
=head2 Credentials
Authentication credentials may be defined by setting either the L</access_token>
or L</private_token> arguments.
If no credentials are supplied then the client will be anonymous and greatly
limited in what it can do with the API.
Extra care has been taken to hide the token arguments behind closures. This way,
if you dump your api object, your tokens won't accidentally leak into places you
don't want them to.
=head2 Constants
The GitLab API, in rare cases, uses a hard-coded value to represent a state.
To make life easier the L<GitLab::API::v4::Constants> module exposes
these states as named variables.
=head2 Exceptions
The API methods will all throw a useful exception if
an unsuccessful response is received from the API. That is except for
C<GET> requests that return a C<404> response - these will return C<undef>
for methods that return a value.
If you'd like to catch and handle these exceptions consider using
L<Try::Tiny>.
=head2 Logging
This module uses L<Log::Any> and produces some debug messages here
and there, but the most useful bits are the info messages produced
just before each API call.
=head2 Project ID
Note that many API calls require a C<$project_id>. This can be
specified as a numeric project C<ID> or, in many cases, maybe all cases,
as a C<NAMESPACE_PATH/PROJECT_PATH> string. The GitLab documentation on
this point is vague.
=cut
use Carp qw( croak );
use GitLab::API::v4::Paginator;
use GitLab::API::v4::RESTClient;
use Log::Any qw( $log );
use Types::Common::Numeric -types;
use Types::Common::String -types;
use Types::Standard -types;
use Moo;
use strictures 2;
use namespace::clean;
sub BUILD {
my ($self) = @_;
# Ensure any token arguments get moved into their closure before we return
# the built object.
$self->access_token();
$self->private_token();
$log->debugf( "An instance of %s has been created.", ref($self) );
return;
( run in 0.547 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )