//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Get group
* Returns a user group for a given group id.
**[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 | undefined) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/group/by-id`)
for (const [k, v] of [['id', id]]) {
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