type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get audit records
* Returns a list of audit records.
*/
export async function main(
auth: Jira,
offset: string | undefined,
limit: string | undefined,
filter: string | undefined,
from: string | undefined,
to: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/auditing/record`
);
for (const [k, v] of [
["offset", offset],
["limit", limit],
["filter", filter],
["from", from],
["to", to],
]) {
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 audit records
* Returns a list of audit records.
*/
export async function main(
auth: Jira,
offset: string | undefined,
limit: string | undefined,
filter: string | undefined,
from: string | undefined,
to: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/auditing/record`
);
for (const [k, v] of [
["offset", offset],
["limit", limit],
["filter", filter],
["from", from],
["to", to],
]) {
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