GitLab-API-v4
view release on metacpan or search on metacpan
Also, review the `Changes` file included in the distribution as it outlines
the changes made to convert the v3 module to v4:
[https://github.com/bluefeet/GitLab-API-v4/blob/master/Changes](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:
[https://github.com/bluefeet/GitLab-API-v4/compare/72e384775c9570f60f8ef68dee3a1eecd347fb69...master](https://github.com/bluefeet/GitLab-API-v4/compare/72e384775c9570f60f8ef68dee3a1eecd347fb69...master)
Or clone the repo and run this command:
`git diff 72e384775c9570f60f8ef68dee3a1eecd347fb69..HEAD -- author/sections/`
## Credentials
Authentication credentials may be defined by setting either the ["access\_token"](#access_token)
or ["private\_token"](#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.
## Constants
The GitLab API, in rare cases, uses a hard-coded value to represent a state.
To make life easier the [GitLab::API::v4::Constants](https://metacpan.org/pod/GitLab%3A%3AAPI%3A%3Av4%3A%3AConstants) module exposes
these states as named variables.
## Exceptions
The API methods will all throw a useful exception if
an unsuccessful response is received from the API. That is except for
`GET` requests that return a `404` response - these will return `undef`
for methods that return a value.
If you'd like to catch and handle these exceptions consider using
[Try::Tiny](https://metacpan.org/pod/Try%3A%3ATiny).
## Logging
This module uses [Log::Any](https://metacpan.org/pod/Log%3A%3AAny) and produces some debug messages here
and there, but the most useful bits are the info messages produced
just before each API call.
## Project ID
Note that many API calls require a `$project_id`. This can be
specified as a numeric project `ID` or, in many cases, maybe all cases,
as a `NAMESPACE_PATH/PROJECT_PATH` string. The GitLab documentation on
this point is vague.
# REQUIRED ARGUMENTS
## url
The URL to your v4 API endpoint. Typically this will be something
like `https://git.example.com/api/v4`.
# OPTIONAL ARGUMENTS
## access\_token
A GitLab API OAuth2 token. If set then ["private\_token"](#private_token) may not be set.
See [https://docs.gitlab.com/ce/api/#oauth2-tokens](https://docs.gitlab.com/ce/api/#oauth2-tokens).
## private\_token
A GitLab API personal token. If set then ["access\_token"](#access_token) may not be set.
See [https://docs.gitlab.com/ce/api/#personal-access-tokens](https://docs.gitlab.com/ce/api/#personal-access-tokens).
## retries
The number of times the request should be retried in case it fails (5XX HTTP
response code). Defaults to `0` (false), meaning that a failed request will
not be retried.
## sudo\_user
The user to execute API calls as. You may find it more useful to use the
["sudo"](#sudo) method instead.
See [https://docs.gitlab.com/ce/api/#sudo](https://docs.gitlab.com/ce/api/#sudo).
## rest\_client
An instance of [GitLab::API::v4::RESTClient](https://metacpan.org/pod/GitLab%3A%3AAPI%3A%3Av4%3A%3ARESTClient) (or whatever ["rest\_client\_class"](#rest_client_class)
is set to). Typically you will not be setting this as it defaults to a new
instance and customization should not be necessary.
## rest\_client\_class
The class to use when constructing the ["rest\_client"](#rest_client).
Defaults to [GitLab::API::v4::RESTClient](https://metacpan.org/pod/GitLab%3A%3AAPI%3A%3Av4%3A%3ARESTClient).
# UTILITY METHODS
## paginator
```perl
my $paginator = $api->paginator( $method, @method_args );
my $members = $api->paginator('group_members', $group_id);
while (my $member = $members->next()) {
...
}
my $users_pager = $api->paginator('users');
while (my $users = $users_pager->next_page()) {
...
}
my $all_open_issues = $api->paginator(
'issues',
$project_id,
( run in 0.922 second using v1.01-cache-2.11-cpan-39bf76dae61 )