Skip to end of banner
Go to start of banner

opEvents: Dynamically update Events using API or CLI.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

opEvents CLI

opEvents CLI is now able to dynamically update events using the act=set parameter.

PARAMETERS

Value

act

set

event_id

event id of the given event

entry.prop-name

value to be updated for the given event

CLI command : /usr/local/omk/bin/opevents-cli.pl  act=set event_id = 672a9b95ad7949330256138a entry.details=”update event details” entry.level=Minor

opEvents API

opEvents API is now able to dynamically update events using a PATCH request.

PATCH

/omk/opEvents/api/v1/events/event_id

Payload example:
{
    "details" : "updating fake event with api 1110110",
    "level" : "Minor"
}


This will update the Event with the given data.

Successful Response

HTTP Status

Body

Description

200 OK

JSON object with success message.
{"success":"Event successfully updated"}

The success property is set to Event successfully updated and only if the request was successful.

Bad Responses

Payload example:
{
    // empty payload
}

HTTP Status

Body

Description

400 Bad Request

JSON object with error message.
{"error":"Empty input: Please provide the necessary data in the request body.","errorTitle":"Invalid Input"}

The error message is set to "Empty input: Please provide the necessary data in the request body."

HTTP Status

Payload example

Body

Description

400 Bad Request

/omk/opEvents/api/v1/events/672a9b95ad794933025xxxx

{"error":"Invalid event id :672a9b95ad7949330256138x is not a valid OID.\n"}

Invalid event id in API

400 Bad Request

empty payload

{"error":"Empty input: Please provide the necessary data in the request body.","errorTitle":"Invalid Input"}

The error message is set to "Empty input: Please provide the necessary data in the request body."

opEvents CLI and API Validations

The opEvents CLI and API both follow a set of validation rules to maintain data integrity:

These validations are on prop-names, which cannot be modified by either CLI or API,

List of default prop-names which can not be modified.

{
  '_id' => 1,
  'actions' => 1,
  'planned_outage' => 1,
  'node' => 1,
  'nodeinfo' => 1,
  'host' => 1,
  'action_checked' => 1,
  'script' => 1,
  'node_uuid' => 1
};


Custom prop-names can be added to opCommon.json under opevents.
These will then be merged to default props and will invalidate the CLI/API request.

/opevents/opevents_list_validation_props : ["details","level","priority"]

Invalid props example

{
    "node" : "xxxxx",
    "level" : "Minor"
}

HTTP Status

Body

Description

400 Bad Request

JSON object with error message.
{"error":"Failed to update event, not allowed to change the element: node. List of invalid props: actions|node|action_checked|node_uuid|_id|nodeinfo|script|planned_outage|host"}

The error message is set and will show the list of invalid props.

  • No labels