//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Get audit records
* Returns all records in the audit log, optionally for a certain date range.
This contains information about events like space exports, group membership
changes, app installations, etc. For more information, see
[Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html)
in the Confluence administrator's guide.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
'Confluence Administrator' global permission.
*/
export async function main(
auth: Confluence,
startDate: string | undefined,
endDate: string | undefined,
searchString: string | undefined,
start: string | undefined,
limit: string | undefined
) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/audit`)
for (const [k, v] of [
['startDate', startDate],
['endDate', endDate],
['searchString', searchString],
['start', start],
['limit', limit]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago