type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Publish draft workflow scheme
* Publishes a draft workflow scheme.
*/
export async function main(
auth: Jira,
id: string,
validateOnly: string | undefined,
body: {
statusMappings?: {
issueTypeId: string;
newStatusId: string;
statusId: string;
}[];
}
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/${id}/draft/publish`
);
for (const [k, v] of [["validateOnly", validateOnly]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Publish draft workflow scheme
* Publishes a draft workflow scheme.
*/
export async function main(
auth: Jira,
id: string,
validateOnly: string | undefined,
body: {
statusMappings?: {
issueTypeId: string;
newStatusId: string;
statusId: string;
}[];
}
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/${id}/draft/publish`
);
for (const [k, v] of [["validateOnly", validateOnly]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 948 days ago