//native
type Circleci = {
token: string
}
/**
* Retrieves the owner's decision audit logs.
* This endpoint will return a list of decision audit logs that were made using this owner's policies.
*/
export async function main(
auth: Circleci,
ownerID: string,
context: string,
status: string | undefined,
after: string | undefined,
before: string | undefined,
branch: string | undefined,
project_id: string | undefined,
build_number: string | undefined,
offset: string | undefined
) {
const url = new URL(`https://circleci.com/api/v2/owner/${ownerID}/context/${context}/decision`)
for (const [k, v] of [
['status', status],
['after', after],
['before', before],
['branch', branch],
['project_id', project_id],
['build_number', build_number],
['offset', offset]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
'Circle-Token': auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago