Edits history of script submission #18496 for ' Redeploy job (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Redeploy job
     *
     */
    export async function main(
    	auth: RT.Qovery,
    	jobId: string,
    	forceEvent?: 'START' | 'STOP' | 'DELETE' | 'CRON' | undefined
    ) {
    	const url = new URL(`https://api.qovery.com/job/${jobId}/redeploy`)
    	for (const [k, v] of [['forceEvent', forceEvent]]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			Authorization: 'Token ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago