type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get my permissions
* Returns a list of permissions indicating which permissions the user has.
*/
export async function main(
auth: Jira,
projectKey: string | undefined,
projectId: string | undefined,
issueKey: string | undefined,
issueId: string | undefined,
permissions: string | undefined,
projectUuid: string | undefined,
projectConfigurationUuid: string | undefined,
commentId: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/mypermissions`
);
for (const [k, v] of [
["projectKey", projectKey],
["projectId", projectId],
["issueKey", issueKey],
["issueId", issueId],
["permissions", permissions],
["projectUuid", projectUuid],
["projectConfigurationUuid", projectConfigurationUuid],
["commentId", commentId],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get my permissions
* Returns a list of permissions indicating which permissions the user has.
*/
export async function main(
auth: Jira,
projectKey: string | undefined,
projectId: string | undefined,
issueKey: string | undefined,
issueId: string | undefined,
permissions: string | undefined,
projectUuid: string | undefined,
projectConfigurationUuid: string | undefined,
commentId: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/mypermissions`
);
for (const [k, v] of [
["projectKey", projectKey],
["projectId", projectId],
["issueKey", issueKey],
["issueId", issueId],
["permissions", permissions],
["projectUuid", projectUuid],
["projectConfigurationUuid", projectConfigurationUuid],
["commentId", commentId],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 948 days ago