1 | type Jira = { |
2 | username: string; |
3 | password: string; |
4 | domain: string; |
5 | }; |
6 | |
7 | * Update project |
8 | * Updates the [project details](https://confluence. |
9 | */ |
10 | export async function main( |
11 | auth: Jira, |
12 | projectIdOrKey: string, |
13 | expand: string | undefined, |
14 | body: { |
15 | assigneeType?: "PROJECT_LEAD" | "UNASSIGNED"; |
16 | avatarId?: number; |
17 | categoryId?: number; |
18 | description?: string; |
19 | issueSecurityScheme?: number; |
20 | key?: string; |
21 | lead?: string; |
22 | leadAccountId?: string; |
23 | name?: string; |
24 | notificationScheme?: number; |
25 | permissionScheme?: number; |
26 | url?: string; |
27 | } |
28 | ) { |
29 | const url = new URL( |
30 | `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}` |
31 | ); |
32 | for (const [k, v] of [["expand", expand]]) { |
33 | if (v !== undefined && v !== "") { |
34 | url.searchParams.append(k, v); |
35 | } |
36 | } |
37 | const response = await fetch(url, { |
38 | method: "PUT", |
39 | headers: { |
40 | "Content-Type": "application/json", |
41 | Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`), |
42 | }, |
43 | body: JSON.stringify(body), |
44 | }); |
45 | if (!response.ok) { |
46 | const text = await response.text(); |
47 | throw new Error(`${response.status} ${text}`); |
48 | } |
49 | return await response.json(); |
50 | } |
51 |
|