Edits history of script submission #15269 for ' Get content restriction status for group (confluence)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Confluence = {
    	email: string
    	apiToken: string
    	domain: string
    }
    /**
     * Get content restriction status for group
     * Returns whether the specified content restriction applies to a group.
     */
    export async function main(
    	auth: Confluence,
    	id: string,
    	operationKey: 'read' | 'update',
    	groupId: string
    ) {
    	const url = new URL(
    		`https://${auth.domain}/wiki/rest/api/content/${id}/restriction/byOperation/${operationKey}/byGroupId/${groupId}`
    	)
    
    	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.text()
    }
    

    Submitted by hugo697 235 days ago