import { BaseResource } from '@gitbeaker/requester-utils'; import type { AccessTokenSchema } from '../templates/ResourceAccessTokens'; import type { ServiceAccountSchema } from './ServiceAccounts'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, MappedOmit, ShowExpanded, Sudo } from '../infrastructure'; export type ServiceAccountAccessTokenSchema = MappedOmit; export class GroupServiceAccounts extends BaseResource { create( groupId: string | number, options?: { name?: string; username?: string; } & Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`groups/${groupId}/service_accounts`, options, ); } // @deprecated In favor of `createPersonalAccessToken` addPersonalAccessToken( groupId: string | number, serviceAccountId: number, options?: { expiresAt?: string } & Sudo & ShowExpanded, ): Promise> { return this.createPersonalAccessToken(groupId, serviceAccountId, options); } createPersonalAccessToken( groupId: string | number, serviceAccountId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`groups/${groupId}/service_accounts/${serviceAccountId}`, options, ); } rotatePersonalAccessToken( groupId: string | number, serviceAccountId: number, tokenId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`groups/${groupId}/service_accounts/${serviceAccountId}/personal_access_tokens/${tokenId}/rotate`, options, ); } }