import { BaseResource } from '@gitbeaker/requester-utils' ; import { UserSchema } from './Users' ; import { PipelineSchema , PipelineVariableSchema } from './Pipelines' ; import { BaseRequestOptions , endpoint , PaginatedRequestOptions , RequestHelper , Sudo , } from '../infrastructure' ; export interface PipelineScheduleSchema extends Record < string , unknown > { id : number ; description : string ; ref : string ; cron : string ; cron_timezone : string ; next_run_at : string ; active : boolean ; created_at : string ; updated_at : string ; owner : Pick < UserSchema , 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url' > ; } export interface PipelineScheduleExtendedSchema extends PipelineScheduleSchema { last_pipeline : Pick < PipelineSchema , 'id' | 'sha' | 'ref' | 'status' > ; } export class PipelineSchedules < C extends boolean = false > extends BaseResource < C > { all ( projectId , options ? ) { return RequestHelper . get < PipelineScheduleSchema [ ] > ( ) ( this , endpoint `projects/${ projectId }/pipeline_schedules` , options ) ; } create ( projectId , description , ref , cron , options ? ) { return RequestHelper . post < PipelineScheduleSchema & { variables ? : PipelineVariableSchema [ ] ; } > ( ) ( this , endpoint `projects/${ projectId }/pipeline_schedules` , { description , ref , cron , ... options , } ) ; } edit ( projectId , scheduleId , options ? ) { return RequestHelper . put < PipelineScheduleExtendedSchema > ( ) ( this , endpoint `projects/${ projectId }/pipeline_schedules/${ scheduleId }` , options ) ; } remove ( projectId , scheduleId , options ? ) { return RequestHelper . del < PipelineScheduleExtendedSchema > ( ) ( this , endpoint `projects/${ projectId }/pipeline_schedules/${ scheduleId }` , options ) ; } show ( projectId , scheduleId , options ? ) { return RequestHelper . get < PipelineScheduleExtendedSchema > ( ) ( this , endpoint `projects/${ projectId }/pipeline_schedules/${ scheduleId }` , options ) ; } takeOwnership ( projectId , scheduleId , options ? ) { return RequestHelper . post < PipelineScheduleExtendedSchema > ( ) ( this , endpoint `projects/${ projectId }/pipeline_schedules/${ scheduleId }/take_ownership` , options ) ; } }