type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get project versions paginated
* Returns a [paginated](#pagination) list of all versions in a project. See the [Get project versions](#api-rest-api-2-project-projectIdOrKey-versions-get) resource if you want to get a full list of versions without pagination.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
*/
export async function main(
auth: Jira,
projectIdOrKey: string,
startAt: string | undefined,
maxResults: string | undefined,
orderBy:
| "description"
| "-description"
| "+description"
| "name"
| "-name"
| "+name"
| "releaseDate"
| "-releaseDate"
| "+releaseDate"
| "sequence"
| "-sequence"
| "+sequence"
| "startDate"
| "-startDate"
| "+startDate"
| undefined,
query: string | undefined,
status: string | undefined,
expand: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/version`
);
for (const [k, v] of [
["startAt", startAt],
["maxResults", maxResults],
["orderBy", orderBy],
["query", query],
["status", status],
["expand", expand],
]) {
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 project versions paginated
* Returns a [paginated](#pagination) list of all versions in a project. See the [Get project versions](#api-rest-api-2-project-projectIdOrKey-versions-get) resource if you want to get a full list of versions without pagination.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
*/
export async function main(
auth: Jira,
projectIdOrKey: string,
startAt: string | undefined,
maxResults: string | undefined,
orderBy:
| "description"
| "-description"
| "+description"
| "name"
| "-name"
| "+name"
| "releaseDate"
| "-releaseDate"
| "+releaseDate"
| "sequence"
| "-sequence"
| "+sequence"
| "startDate"
| "-startDate"
| "+startDate"
| undefined,
query: string | undefined,
status: string | undefined,
expand: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/version`
);
for (const [k, v] of [
["startAt", startAt],
["maxResults", maxResults],
["orderBy", orderBy],
["query", query],
["status", status],
["expand", expand],
]) {
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