Commit 6156528e authored by gregor herrmann's avatar gregor herrmann

dpt-salsa: activate and improve user functions

Gbp-Dch: Ignore
parent 7633899e
......@@ -30,6 +30,7 @@ Build-Depends-Indep: dpkg-dev (>= 1.17.0),
libtest-mockmodule-perl,
libtest-pod-perl,
libtest-spelling-perl,
libutf8-all-perl,
libwww-mechanize-perl,
libyaml-libyaml-perl,
lintian (>= 2.5.28~),
......@@ -61,6 +62,7 @@ Depends: ${misc:Depends},
libparse-debianchangelog-perl,
libproc-invokeeditor-perl,
librt-client-rest-perl,
libutf8-all-perl,
lintian (>= 2.5.28~),
openssh-client | ssh-client,
pristine-tar,
......
......@@ -8,9 +8,7 @@ use Pod::Usage qw( pod2usage );
use GitLab::API::v4;
use GitLab::API::v4::Constants qw( :all );
use JSON;
#use utf8::all; # XXX
#use App::Cmd; # XXX
use utf8::all;
# config
## defaults
......@@ -61,6 +59,23 @@ my $api = GitLab::API::v4->new(
private_token => $config{private_token},
);
# data
my %levels_name = (
guest => $GITLAB_ACCESS_LEVEL_GUEST,
reporter => $GITLAB_ACCESS_LEVEL_REPORTER,
developer => $GITLAB_ACCESS_LEVEL_DEVELOPER,
master => $GITLAB_ACCESS_LEVEL_MASTER,
owner => $GITLAB_ACCESS_LEVEL_OWNER,
);
my %levels_code = (
$GITLAB_ACCESS_LEVEL_GUEST => 'guest',
$GITLAB_ACCESS_LEVEL_REPORTER => 'reporter',
$GITLAB_ACCESS_LEVEL_DEVELOPER => 'developer',
$GITLAB_ACCESS_LEVEL_MASTER => 'master',
$GITLAB_ACCESS_LEVEL_OWNER => 'owner',
);
# run command
if ( $command eq 'version' ) {
version();
......@@ -120,17 +135,9 @@ sub adduser {
my $user_id = user2userid($user);
my %levels = (
guest => $GITLAB_ACCESS_LEVEL_GUEST,
reporter => $GITLAB_ACCESS_LEVEL_REPORTER,
developer => $GITLAB_ACCESS_LEVEL_DEVELOPER,
master => $GITLAB_ACCESS_LEVEL_MASTER,
owner => $GITLAB_ACCESS_LEVEL_OWNER,
);
my $access_level = $levels{ lc($level) };
my $access_level = $levels_name{ lc($level) };
die "Unknown access level '$level'." unless $access_level;
...;
$api->add_group_member( $config{'perl_team_modules_id'},
{ user_id => $user_id, access_level => $access_level } );
}
......@@ -140,21 +147,23 @@ sub removeuser {
my ($user) = @args;
die 'Required parameter username|userid missing.' unless $user;
my $user_id = user2userid($user);
...;
$api->remove_group_member( $config{'perl_team_modules_id'}, $user_id );
}
## listmembers()
sub listmembers {
my $members = $api->group_members( $config{'perl_team_modules_id'} );
...;
my $members
= $api->paginator( 'group_members', $config{'perl_team_modules_id'} )
->all();
foreach ( @{$members} ) {
if ( $opts{json} ) {
say prettyjson($_);
} else {
say "Id: " . $_->{id};
say "Username: " . $_->{username};
say "Name: " . $_->{name};
my $access_level = $levels_code{ $_->{access_level} };
say "Id: " . $_->{id};
say "Username: " . $_->{username};
say "Name: " . $_->{name};
say "Access level: " . $access_level;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment