Edits history of script submission #18379 for ' List Azure AKS available instance types (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * List Azure AKS available instance types
     *
     */
    export async function main(
    	auth: RT.Qovery,
    	region: string,
    	only_meets_resource_reqs?: string | undefined,
    	with_gpu?: string | undefined,
    	gpu?: 'ONLY' | 'INCLUDE' | 'EXCLUDE' | undefined
    ) {
    	const url = new URL(`https://api.qovery.com/azure/aks/instanceType/${region}`)
    	for (const [k, v] of [
    		['only_meets_resource_reqs', only_meets_resource_reqs],
    		['with_gpu', with_gpu],
    		['gpu', gpu]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		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