//native
type Render = {
apiKey: string
}
/**
* Scale instance count
* [Scale](https://docs.render.com/scaling#manual-scaling) the service with the provided ID to a fixed number of instances.
Render ignores this value as long as autoscaling is enabled for the service.
*/
export async function main(auth: Render, serviceId: string, body: { numInstances: number }) {
const url = new URL(`https://api.render.com/v1/services/${serviceId}/scale`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 235 days ago