//native
type Phrase = {
token: string
baseUrl: string
}
/**
* Lock a job
* If you are the job owner, you may lock a job using this API request.
*/
export async function main(
auth: Phrase,
project_id: string,
id: string,
branch: string | undefined
) {
const url = new URL(`${auth.baseUrl}/projects/${project_id}/jobs/${id}/lock`)
for (const [k, v] of [['branch', branch]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: 'ApiToken ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 235 days ago