//native
type Telnyx = {
apiKey: string
}
/**
* Global IP Assignment Health Check Metrics
*
*/
export async function main(
auth: Telnyx,
filter_global_ip_id__in_: string | undefined,
filter_global_ip_assignment_id__in_: string | undefined,
filter_timestamp__gt_: string | undefined,
filter_timestamp__lt_: string | undefined
) {
const url = new URL(`https://api.telnyx.com/v2/global_ip_assignment_health`)
for (const [k, v] of [
['filter[global_ip_id][in]', filter_global_ip_id__in_],
['filter[global_ip_assignment_id][in]', filter_global_ip_assignment_id__in_],
['filter[timestamp][gt]', filter_timestamp__gt_],
['filter[timestamp][lt]', filter_timestamp__lt_]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + 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 428 days ago