//native
type Circleci = {
token: string
}
/**
* Set the decision settings
* This endpoint allows modifying decision settings (eg enable/disable policy evaluation)
*/
export async function main(
auth: Circleci,
ownerID: string,
context: string,
body: { enabled?: false | true }
) {
const url = new URL(
`https://circleci.com/api/v2/owner/${ownerID}/context/${context}/decision/settings`
)
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