type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get project components paginated
* Returns a [paginated](#pagination) list of all components in a project.
*/
export async function main(
auth: Jira,
projectIdOrKey: string,
startAt: string | undefined,
maxResults: string | undefined,
orderBy:
| "description"
| "-description"
| "+description"
| "issueCount"
| "-issueCount"
| "+issueCount"
| "lead"
| "-lead"
| "+lead"
| "name"
| "-name"
| "+name"
| undefined,
componentSource: "jira" | "compass" | "auto" | undefined,
query: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/component`
);
for (const [k, v] of [
["startAt", startAt],
["maxResults", maxResults],
["orderBy", orderBy],
["componentSource", componentSource],
["query", query],
]) {
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 components paginated
* Returns a [paginated](#pagination) list of all components in a project.
*/
export async function main(
auth: Jira,
projectIdOrKey: string,
startAt: string | undefined,
maxResults: string | undefined,
orderBy:
| "description"
| "-description"
| "+description"
| "issueCount"
| "-issueCount"
| "+issueCount"
| "lead"
| "-lead"
| "+lead"
| "name"
| "-name"
| "+name"
| undefined,
componentSource: "jira" | "compass" | "auto" | undefined,
query: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/component`
);
for (const [k, v] of [
["startAt", startAt],
["maxResults", maxResults],
["orderBy", orderBy],
["componentSource", componentSource],
["query", query],
]) {
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 823 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get project components paginated
* Returns a [paginated](#pagination) list of all components in a project. See the [Get project components](#api-rest-api-2-project-projectIdOrKey-components-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"
| "issueCount"
| "-issueCount"
| "+issueCount"
| "lead"
| "-lead"
| "+lead"
| "name"
| "-name"
| "+name"
| undefined,
query: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/component`
);
for (const [k, v] of [
["startAt", startAt],
["maxResults", maxResults],
["orderBy", orderBy],
["query", query],
]) {
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