//native
/**
* Update View
* Use this method to update a view. You can change the view configuration details; add or remove view specific alerts; or attach and detach preset alerts.
*/
export async function main(auth: RT.Mezmo, viewId: string, body: Body) {
const url = new URL(`https://api.mezmo.com/v1/config/view/${viewId}`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: 'Token ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
/**
* Name of a view.
*/
name: string
/**
* Search query.
*/
query?: string
hosts?: string[]
apps?: string[]
levels?: string[]
tags?: string[]
category?: string[]
/**
* ID of a preset alert.
*/
presetid?: string
channels?: {
/**
* Defines the type of notification channel. Valid values are: `email`, `webhook`, `slack`, and `pagerduty`
*/
integration?: string
emails?: string[]
/**
* Webhook URL.
*/
url?: string
/**
* PagerDuty key.
*/
key?: string
/**
* Specify the number of log lines that match the view's filtering and search criteria. When the number of log lines is reached, an alert is triggered.
*/
triggerlimit?: string
/**
* Specify how often to trigger an alert. Valid values are: 30 seconds, 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 12 hours, 24 hours
*/
triggerinterval?: string
/**
* Set to true if you want the trigger condition to be evaluated as soon as the triggerlimit is reached.
*/
immediate?: boolean
/**
* Set to true if you want the trigger condition to be evaluated after the time that you specify in the triggerinterval field is reached.
*/
terminal?: boolean
/**
* Type of alert. Valid values are: `presence`and `absence`.
*/
operator?: string
/**
* Timezone used to report timestamps. This can be any value defined in the tz database https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
*/
timezone?: string
/**
* WebHook method such as POST.
*/
method?: 'POST' | 'PUT' | 'PATCH'
headers?: {
/**
* Header value
*/
timestamp?: string
[k: string]: unknown
}
bodyTemplate?: {
/**
* Define the webhook body.
*/
timestamp?: string
[k: string]: unknown
}
/**
* Set to true if you want the set a condition to resolve the incident that was raised by this alert. This property only applies to PagerDuty.
*/
autoresolve?: boolean
/**
* Interval of time to aggregate and check # of matched lines against the auto resolve limit. Valid values are: 30 seconds, 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 12 hours, 24 hours, 25 hours.
*/
autoresolveinterval?: string
/**
* Specify the number of log lines that match the view's filtering and search criteria. When the number of log lines is reached, this incident will be set to resolved in PagerDuty.
*/
autoresolvelimit?: string
[k: string]: unknown
}[]
[k: string]: unknown
}
Submitted by hugo697 235 days ago