Skip to content

Commit 8ac1f5c

Browse files
committed
support impersonation tokens
1 parent 2d4f374 commit 8ac1f5c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

lib/Gitlab/Api/Users.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,49 @@ public function email($id)
253253
{
254254
return $this->get('user/emails/'.$this->encodePath($id));
255255
}
256+
257+
/**
258+
* @param int $user_id
259+
* @return mixed
260+
*/
261+
public function userImpersonationTokens($user_id)
262+
{
263+
return $this->get('users/'.$this->encodePath($user_id).'/impersonation_tokens/');
264+
}
265+
266+
/**
267+
* @param int $user_id
268+
* @param int $impersonation_token_id
269+
* @return mixed
270+
*/
271+
public function userImpersonationToken($user_id, $impersonation_token_id)
272+
{
273+
return $this->get('users/'.$this->encodePath($user_id).'/impersonation_tokens/'.$this->encodePath($impersonation_token_id));
274+
}
275+
276+
/**
277+
* @param int $user_id
278+
* @param string $name
279+
* @param array $scopes
280+
* @param null $expires_at
281+
* @return mixed
282+
*/
283+
public function createImpersonationToken($user_id, $name, array $scopes, $expires_at = null)
284+
{
285+
return $this->post('users/'.$this->encodePath($user_id).'/impersonation_tokens', array(
286+
'name' => $name,
287+
'scopes' => $scopes,
288+
'expires_at' => $expires_at
289+
));
290+
}
291+
292+
/**
293+
* @param int $user_id
294+
* @param int $impersonation_token_id
295+
* @return mixed
296+
*/
297+
public function removeImpersonationToken($user_id, $impersonation_token_id)
298+
{
299+
return $this->delete('users/'.$this->encodePath($user_id).'/impersonation_tokens/'.$this->encodePath($impersonation_token_id));
300+
}
256301
}

0 commit comments

Comments
 (0)