//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Get long-running task
* Returns information about an active long-running task (e.g. space export),
such as how long it has been running and the percentage of the task that
has completed.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
Permission to access the Confluence site ('Can use' global permission).
*/
export async function main(auth: Confluence, id: string) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/longtask/${id}`)
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