0

Collaborations

by
Published Dec 20, 2024

Provides the set of organizations of which a user is a member or a collaborator. The set of organizations that a user can collaborate on is composed of: * Organizations that the current user belongs to across VCS types (e.g. BitBucket, GitHub) * The parent organization of repository that the user can collaborate on, but is not necessarily a member of * The organization of the current user's account

Script circleci Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Circleci = {
3
	token: string
4
}
5
/**
6
 * Collaborations
7
 * Provides the set of organizations of which a user is a member or a collaborator.
8

9
The set of organizations that a user can collaborate on is composed of:
10

11
* Organizations that the current user belongs to across VCS types (e.g. BitBucket, GitHub)
12
* The parent organization of repository that the user can collaborate on, but is not necessarily a member of
13
* The organization of the current user's account
14
 */
15
export async function main(auth: Circleci) {
16
	const url = new URL(`https://circleci.com/api/v2/me/collaborations`)
17

18
	const response = await fetch(url, {
19
		method: 'GET',
20
		headers: {
21
			'Circle-Token': auth.token
22
		},
23
		body: undefined
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31