This file is indexed.

/usr/bin/gitlab-api-v4 is in libgitlab-api-v4-perl 0.04-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env perl
use strictures 2;

use GitLab::API::v4;
use GitLab::API::v4::Constants qw( :all );
use GitLab::API::v4::Config;

use Log::Any qw( $log );
use Log::Any::Adapter;
use Log::Any::Adapter::Screen;
use Try::Tiny;
use JSON;

use Getopt::Long qw( GetOptions );
use Pod::Usage qw( pod2usage );

Getopt::Long::Configure(qw(
    gnu_getopt no_ignore_case
    pass_through
));

GetOptions(
    'a|all' => \my $all,

    'h|help'    => \my $help,
    'v|verbose' => \my $verbose,
    'q|quiet'   => \my $quiet,
) or fail('Unable to process options!');

if ($help or @ARGV and $ARGV[0] eq 'help') {
    pod2usage( -verbose => 2 );
    exit 0;
}

my $min_level = 'info';
$min_level = 'trace' if $verbose;
$min_level = 'error' if $quiet;

my $config = GitLab::API::v4::Config->new();

Log::Any::Adapter->set(
    'Screen',
    min_level => $min_level,
    stderr    => 1,
);

my $access_levels = {
    '--access-level-guest'     => $GITLAB_ACCESS_LEVEL_GUEST,
    '--access-level-reporter'  => $GITLAB_ACCESS_LEVEL_REPORTER,
    '--access-level-developer' => $GITLAB_ACCESS_LEVEL_DEVELOPER,
    '--access-level-master'    => $GITLAB_ACCESS_LEVEL_MASTER,
    '--access-level-owner'     => $GITLAB_ACCESS_LEVEL_OWNER,
};

my @args;
my $params = {};
foreach my $arg (@ARGV) {
    if (defined $access_levels->{$arg}) {
        $params->{access_level} = $access_levels->{$arg};
    }
    elsif ($arg =~ m{^--(no-|)?([^\s=]+)(=(.*)|)$}) {
        my ($no, $key, $has_value, $value) = ($1, $2, $3, $4);
        $key =~ s{-}{_}g;
        $value = $has_value ? $value : $no ? 0 : 1;
        $params->{$key} = $value;
    }
    else {
        push @args, $arg;
    }
}

my $method = shift( @args );
fail( 'No method was specified.' ) if !$method;
$method =~ s{-}{_}g;

if ($method eq 'configure') {
    $config->configure();
    exit;
}

try {
    my $api = GitLab::API::v4->new( $config->args() );

    if ($all) {
        @args = ( $method, @args );
        $method = 'paginator';
    }

    my $data = $api->$method(
        @args,
        %$params ? $params : (),
    );

    $data = $data->all() if $all;

    binmode STDOUT, ':utf8';
    my $json = JSON->new->allow_nonref();
    print $json->encode( $data );
}
catch {
    fail( $_ );
};

sub fail {
    $log->fatal( @_ );
    exit 1;
}

__END__

=head1 NAME

gitlab-api-v4 - Command line interface to the GitLab API v4.

=head1 SYNOPSIS

    # Generally:
    gitlab-api-v4 <method> [<arg> ...] [--<param>=<value> ...]
    
    # List all groups:
    gitlab-api-v4 groups
    
    # List information about a project:
    gitlab-api-v4 project <project_id>
    
    # Create an admin user:
    gitlab-api-v4 create-user \
        --email=<email> --password=<password> --username=<username> --name=<name> --admin

=head1 CONFIGURING

You may configure this module with envornment variables, command line options,
and a configuration file.  To setup the configuration file run:

    gitlab-api-v4 configure

This will ask several interactive questions to help you configure this script.
The information, which may include GitLab authentication tokens, is stored in
C<~/.gitlab-api-v4.json>.

Read more at L<GitLab::API::v4::Config>.

=head1 OPTIONS

=head2 method

    <method>

The API method to call (one of the methods documented in
L<GitLab::API::v4>).

=head2 args

    <arg> ...

Any arguments that the L</method> requires.

=head2 params

    --<param>=<value> ...

Any parameters that the L</method> accepts.

=head2 access level

    --access-level-guest
    --access-level-reporter
    --access-level-developer
    --access-level-master
    --access-level-owner

=head2 all

    --all

Retrieves all results when the results would normally be paged.

=head1 AUTHORS

See L<GitLab::API::v4/AUTHOR> and L<GitLab::API::v4/CONTRIBUTORS>.

=head1 LICENSE

This script is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.