type Bitbucket = {
username: string;
password: string;
};
/**
* Check issue import status
* When using GET, this endpoint reports the status of the current import task.
After the job has been scheduled, but before it starts executing, the endpoint
returns a 202 response with status `ACCEPTED`.
Once it starts running, it is a 202 response with status `STARTED` and progress filled.
After it is finished, it becomes a 200 response with status `SUCCESS` or `FAILURE`.
*/
export async function main(
auth: Bitbucket,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/import`
);
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 375 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Check issue import status
* When using GET, this endpoint reports the status of the current import task.
After the job has been scheduled, but before it starts executing, the endpoint
returns a 202 response with status `ACCEPTED`.
Once it starts running, it is a 202 response with status `STARTED` and progress filled.
After it is finished, it becomes a 200 response with status `SUCCESS` or `FAILURE`.
*/
export async function main(
auth: Bitbucket,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/import`
);
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 935 days ago