type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Find users with permissions
* Returns a list of users who fulfill these criteria:
* their user attributes match a search string.
*/
export async function main(
auth: Jira,
query: string | undefined,
username: string | undefined,
accountId: string | undefined,
permissions: string | undefined,
issueKey: string | undefined,
projectKey: string | undefined,
startAt: string | undefined,
maxResults: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/user/permission/search`
);
for (const [k, v] of [
["query", query],
["username", username],
["accountId", accountId],
["permissions", permissions],
["issueKey", issueKey],
["projectKey", projectKey],
["startAt", startAt],
["maxResults", maxResults],
]) {
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;
};
/**
* Find users with permissions
* Returns a list of users who fulfill these criteria:
* their user attributes match a search string.
*/
export async function main(
auth: Jira,
query: string | undefined,
username: string | undefined,
accountId: string | undefined,
permissions: string | undefined,
issueKey: string | undefined,
projectKey: string | undefined,
startAt: string | undefined,
maxResults: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/user/permission/search`
);
for (const [k, v] of [
["query", query],
["username", username],
["accountId", accountId],
["permissions", permissions],
["issueKey", issueKey],
["projectKey", projectKey],
["startAt", startAt],
["maxResults", maxResults],
]) {
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