import { BaseResource } from '@gitbeaker/requester-utils' ; import { RequestHelper , PaginatedRequestOptions , Sudo } from '../infrastructure' ; export type ImpersonationTokenScope = 'api' | 'read_user' ; export type ImpersonationTokenState = 'all' | 'active' | 'inactive' ; export interface UserImpersonationTokenSchema extends Record < string , unknown > { active : boolean ; user_id : number ; scopes ? : string [ ] ; revoked : boolean ; name : string ; id : number ; created_at : string ; impersonation : boolean ; expires_at : string ; } export class UserImpersonationTokens < C extends boolean = false > extends BaseResource < C > { all ( userId , options ? ) { return RequestHelper . get < UserImpersonationTokenSchema [ ] > ( ) ( this , `users/${ userId }/impersonation_tokens` , options ) ; } add ( userId , name , scopes , expiresAt , options ? ) { return RequestHelper . post < UserImpersonationTokenSchema > ( ) ( this , `users/${ userId }/impersonation_tokens` , { name , expiresAt , scopes , ... options , } ) ; } show ( userId , tokenId , options ? ) { return RequestHelper . get < UserImpersonationTokenSchema > ( ) ( this , `users/${ userId }/impersonation_tokens/${ tokenId }` , options ) ; } revoke ( userId , tokenId , options ? ) { return RequestHelper . del ( ) ( this , `users/${ userId }/impersonation_tokens/${ tokenId }` , options ) ; } }