import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, ShowExpanded, Sudo } from '../infrastructure'; import { SimpleProjectSchema } from './Projects'; import { CondensedGroupSchema } from './Groups'; export interface JobTokenScopeSchema extends Record { inbound_enabled: boolean; outbound_enabled: boolean; } export interface ProjectAllowListSchema extends Record { source_project_id: number; target_project_id: number; } export interface GroupAllowListSchema extends Record { source_project_id: number; target_group_id: number; } export class ProjectJobTokenScopes extends BaseResource { show( projectId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/job_token_scope`, options, ); } edit( projectId: string | number, enabled: boolean, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.patch()( this, endpoint`projects/${projectId}/job_token_scope`, { ...options, enabled }, ); } showInboundAllowList( projectId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/job_token_scope/allowlist`, options, ); } addToInboundAllowList( projectId: string | number, targetProjectId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/job_token_scope/allowlist`, { ...options, targetProjectId }, ); } removeFromInboundAllowList( projectId: string | number, targetProjectId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()( this, endpoint`projects/${projectId}/job_token_scope/allowlist/${targetProjectId}`, options, ); } showGroupsAllowList( projectId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/job_token_scope/groups_allowlist`, options, ); } addToGroupsAllowList( projectId: string | number, targetGroupId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/job_token_scope/groups_allowlist`, { ...options, targetGroupId }, ); } removeFromGroupsAllowList( projectId: string | number, targetGroupId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()( this, endpoint`projects/${projectId}/job_token_scope/groups_allowlist/${targetGroupId}`, options, ); } }