//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Create audit record
* Creates a record in the audit log.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
'Confluence Administrator' global permission.
*/
export async function main(
auth: Confluence,
body: {
author?: {
type: 'user'
displayName?: string
operations?: {}
username?: string
userKey?: string
}
remoteAddress: string
creationDate?: number
summary?: string
description?: string
category?: string
sysAdmin?: false | true
affectedObject?: { name: string; objectType: string }
changedValues?: {
name: string
oldValue: string
hiddenOldValue?: string
newValue: string
hiddenNewValue?: string
}[]
associatedObjects?: { name: string; objectType: string }[]
}
) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/audit`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
},
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 235 days ago