//native
type Circleci = {
token: string
}
/**
* Update a schedule
* Not yet available to projects that use GitLab or GitHub App. Updates a schedule and returns the updated schedule.
*/
export async function main(
auth: Circleci,
schedule_id: string,
body: {
description?: string
name?: string
timetable?: {
'per-hour'?: number
'hours-of-day'?: number[]
'days-of-week'?: 'TUE' | 'SAT' | 'SUN' | 'MON' | 'THU' | 'WED' | 'FRI'[]
'days-of-month'?: number[]
months?:
| 'MAR'
| 'NOV'
| 'DEC'
| 'JUN'
| 'MAY'
| 'OCT'
| 'FEB'
| 'APR'
| 'SEP'
| 'AUG'
| 'JAN'
| 'JUL'[]
}
'attribution-actor'?: 'current' | 'system'
parameters?: {}
}
) {
const url = new URL(`https://circleci.com/api/v2/schedule/${schedule_id}`)
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'Circle-Token': auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago