Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ $ kbn-alert create test.always-firing test 1s '{index:test_alert_from_cli}' "[{g
"id": "8fe59625-fda4-400b-94a6-cf75938c163b"
}
],
"alertTypeParams": {
"params": {
"index": "test_alert_from_cli"
},
"enabled": true,
Expand All @@ -185,7 +185,7 @@ $ kbn-alert update 0bdbb930-b485-11e9-86c5-c9b4ac6d5f40 'updated test' 1m '{inde
"id": "8fe59625-fda4-400b-94a6-cf75938c163b"
}
],
"alertTypeParams": {
"params": {
"index": "test_alert_from_cli"
}
}
Expand Down
22 changes: 11 additions & 11 deletions lib/alert-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ async function ls (baseUrl, id, args, opts) {
async function create (baseUrl, id, args, opts) {
if (id == null) throw new Error('id parameter required')

const [name, interval, alertTypeParamsJSON, actionsJSON] = args
const [name, interval, paramsJSON, actionsJSON] = args
if (interval == null) throw new Error('interval parameter required')

if (name == null) throw new Error('name parameter required')

if (alertTypeParamsJSON == null) {
if (paramsJSON == null) {
throw new Error('JSON alert type params object required')
}

const alertTypeParams = JSONparse(alertTypeParamsJSON)
const params = JSONparse(paramsJSON)

if (actionsJSON == null) {
throw new Error('JSON actions required')
Expand All @@ -65,7 +65,7 @@ async function create (baseUrl, id, args, opts) {
name,
interval,
actions,
alertTypeParams
params
}

const uri = 'api/alert'
Expand Down Expand Up @@ -97,16 +97,16 @@ async function get (baseUrl, id, args, opts) {
async function update (baseUrl, id, args, opts) {
if (id == null) throw new Error('id parameter required')

const [name, interval, alertTypeParamsJSON, actionsJSON, throttle = null] = args
const [name, interval, paramsJSON, actionsJSON, throttle = null] = args
if (name == null) throw new Error('name parameter required')

if (interval == null) throw new Error('interval parameter required')

if (alertTypeParamsJSON == null) {
if (paramsJSON == null) {
throw new Error('JSON alert type params object required')
}

const alertTypeParams = JSONparse(alertTypeParamsJSON)
const params = JSONparse(paramsJSON)

if (actionsJSON == null) {
throw new Error('JSON actions required')
Expand All @@ -119,7 +119,7 @@ async function update (baseUrl, id, args, opts) {
name,
interval,
actions,
alertTypeParams,
params,
throttle,
}

Expand Down Expand Up @@ -153,13 +153,13 @@ async function del (baseUrl, id, args, opts) {
async function fire (baseUrl, id, args, opts) {
if (id == null) throw new Error('id parameter required')

const [alertTypeParamsJSON] = args
const [paramsJSON] = args

if (alertTypeParamsJSON == null) {
if (paramsJSON == null) {
throw new Error('JSON params object required')
}

const params = JSONparse(alertTypeParamsJSON)
const params = JSONparse(paramsJSON)
const body = { params }

const uri = `api/alert/${id}/_fire`
Expand Down