//native
type Neondb = {
apiKey: string
}
/**
* Update a project
* Updates the specified project.
You can obtain a `project_id` by listing the projects for your Neon account.
Neon permits updating the project name only.
*/
export async function main(
auth: Neondb,
project_id: string,
body: {
project: {
settings?: {
quota?: {
active_time_seconds?: number
compute_time_seconds?: number
written_data_bytes?: number
data_transfer_bytes?: number
logical_size_bytes?: number
}
allowed_ips?: {
ips?: string[]
protected_branches_only?: false | true
}
enable_logical_replication?: false | true
maintenance_window?: {
weekdays: number[]
start_time: string
end_time: string
}
block_public_connections?: false | true
block_vpc_connections?: false | true
}
name?: string
default_endpoint_settings?: {
pg_settings?: {}
pgbouncer_settings?: {}
autoscaling_limit_min_cu?: number
autoscaling_limit_max_cu?: number
suspend_timeout_seconds?: number
}
history_retention_seconds?: number
}
}
) {
const url = new URL(`https://console.neon.tech/api/v2/projects/${project_id}`)
const response = await fetch(url, {
method: 'PATCH',
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.json()
}
Submitted by hugo697 428 days ago