Skip to content

Instantly share code, notes, and snippets.

@madhurtandon
Last active May 19, 2016 19:27
Show Gist options
  • Save madhurtandon/96bb5d97a4bf6020b9977c5fa9bfdef3 to your computer and use it in GitHub Desktop.
Save madhurtandon/96bb5d97a4bf6020b9977c5fa9bfdef3 to your computer and use it in GitHub Desktop.
Monitor rules

INPUT_TYPE=INTEGER, FLOAT, STRING

Payload:

{
	"title": "Sample",
	"predicate_collections": [{
		"propositions": [{
			"field": "cases.subject",
			"operator": "string_contains",
			"value": "Case for testing trigger"
		}]
	}],
	"actions": [{
		"name": "customfield_10",
		"option": "CHANGE",
		"value": "4"
	}],
	"is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 11,
        "title": "Sample",
        "predicate_collections": [
            {
                "id": 34,
                "propositions": [
                    {
                        "id": 34,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 13,
                "name": "customfield_10",
                "option": "CHANGE",
                "value": "333",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 7,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-17T18:46:03+00:00",
        "updated_at": "2016-05-17T18:46:03+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/11"
    },
    "resource": "monitor"
}

INPUT_TYPE=BOOLEAN_TRUE

Same for BOOLEAN and BOOLEAN FALSE

Payload:

{
	"title": "Sample",
	"predicate_collections": [{
		"propositions": [{
			"field": "cases.subject",
			"operator": "string_contains",
			"value": "Case for testing trigger"
		}]
	}],
	"actions": [{
		"name": "satisfactionsurvey",
		"option": "SEND",
		"value": "true"
	}],
	"is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 13,
        "title": "Sample",
        "predicate_collections": [
            {
                "id": 36,
                "propositions": [
                    {
                        "id": 36,
                        "field": "cases.subject",
                        "operator": "string_contains",
                        "value": "Case for testing trigger",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 15,
                "name": "satisfactionsurvey",
                "option": "SEND",
                "value": "true",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 9,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-17T19:02:09+00:00",
        "updated_at": "2016-05-17T19:02:09+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/13"
    },
    "resource": "monitor"
}

INPUT_TYPE=OPTION

Payload:

{
	"title": "Sample",
	"predicate_collections": [{
		"propositions": [{
			"field": "cases.subject",
			"operator": "string_contains",
			"value": "Case for testing trigger"
		}]
	}],
	"actions": [{
		"name": "team",
		"option": "CHANGE",
		"value": "2"
	}],
	"is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 14,
        "title": "Sample",
        "predicate_collections": [
            {
                "id": 37,
                "propositions": [
                    {
                        "id": 37,
                        "field": "cases.subject",
                        "operator": "string_contains",
                        "value": "Case for testing trigger",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 16,
                "name": "team",
                "option": "CHANGE",
                "value": "2",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 10,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-17T19:05:13+00:00",
        "updated_at": "2016-05-17T19:05:13+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/14"
    },
    "resource": "monitor"
}

INPUT_TYPE=MULTIPLE

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "customfield_12",
        "option": "ADD",
        "value": "7,8"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 30,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 62,
                "propositions": [
                    {
                        "id": 63,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 28,
                "name": "customfield_12",
                "option": "ADD",
                "value": "7, 8",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 12,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T09:30:09+00:00",
        "updated_at": "2016-05-18T09:30:09+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/30"
    },
    "resource": "monitor"
}

INPUT_TYPE=TAGS

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "tags",
        "option": "ADD",
        "value": "test, test1"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 32,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 64,
                "propositions": [
                    {
                        "id": 65,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 30,
                "name": "tags",
                "option": "ADD",
                "value": "test, test1",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 14,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T12:26:49+00:00",
        "updated_at": "2016-05-18T12:26:49+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/32"
    },
    "resource": "monitor"
}

INPUT_TYPE=ENDPOINT_EMAIL

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "endpoint_1",
        "option": "SEND",
        "value": "message"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 2,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 2,
                "propositions": [
                    {
                        "id": 2,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 2,
                "name": "endpoint_1",
                "option": "SEND",
                "value": "message",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 2,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T18:37:08+00:00",
        "updated_at": "2016-05-18T18:37:08+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/2"
    },
    "resource": "monitor"
}

INPUT_TYPE=ENDPOINT_HTTP_JSON

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "endpoint_4",
        "option": "SEND",
        "value": "{\"foo\": \"example1\" }"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 10,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 10,
                "propositions": [
                    {
                        "id": 10,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 10,
                "name": "endpoint_4",
                "option": "SEND",
                "value": "{\"foo\": \"example1\" }",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 10,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T19:17:54+00:00",
        "updated_at": "2016-05-18T19:17:54+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/10"
    },
    "resource": "monitor"
}

INPUT_TYPE=ENDPOINT_HTTP_XML

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "endpoint_4",
        "option": "SEND",
        "value": "<name>Madhur</name>"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 21,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 21,
                "propositions": [
                    {
                        "id": 21,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 21,
                "name": "endpoint_5",
                "option": "SEND",
                "value": "<name>Robert</name>",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 21,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T19:29:58+00:00",
        "updated_at": "2016-05-18T19:29:58+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/21"
    },
    "resource": "monitor"
}

INPUT_TYPE=ENDPOINT_SLACK

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "endpoint_6",
        "option": "SEND",
        "value": "message"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 22,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 22,
                "propositions": [
                    {
                        "id": 22,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 22,
                "name": "endpoint_6",
                "option": "SEND",
                "value": "message",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 22,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T19:38:05+00:00",
        "updated_at": "2016-05-18T19:38:05+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/22"
    },
    "resource": "monitor"
}

INPUT_TYPE=ENDPOINT_NOTIFICATION_EMAIL

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "notificationuser",
        "option": "SEND",
        "value": "-2",
        "attributes": {"subject": "test", "message": "test"}
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 23,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 23,
                "propositions": [
                    {
                        "id": 23,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 23,
                "name": "notificationuser",
                "option": "SEND",
                "value": "-2",
                "attributes": [
                    {
                        "name": "subject",
                        "value": "test",
                        "resource_type": "automation_action_attribute"
                    },
                    {
                        "name": "message",
                        "value": "test",
                        "resource_type": "automation_action_attribute"
                    }
                ],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 23,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T19:41:46+00:00",
        "updated_at": "2016-05-18T19:41:46+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/23"
    },
    "resource": "monitor"
}

INPUT_TYPE=AUTOCOMPLETE

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "assignee",
        "option": "CHANGE",
        "value": "1"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 24,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 24,
                "propositions": [
                    {
                        "id": 24,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 24,
                "name": "assignee",
                "option": "CHANGE",
                "value": "1",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 24,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-18T19:43:54+00:00",
        "updated_at": "2016-05-18T19:43:54+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/24"
    },
    "resource": "monitor"
}

INPUT_TYPE=ENDPOINT_HTTP

Payload:

{
    "title": "monitor assignee take",
    "predicate_collections": [{
        "propositions": [{
            "field": "cases.casestatusid",
            "operator": "comparison_equalto",
            "value": "3"
        }]
    }],
    "actions": [{
        "name": "endpoint_1",
        "option": "SEND",
        "value": "{\"caseid\": \"{{case.id}}\" }"
    }],
    "is_enabled": "true"
}

Output:

{
    "status": 201,
    "data": {
        "id": 1,
        "title": "monitor assignee take",
        "predicate_collections": [
            {
                "id": 1,
                "propositions": [
                    {
                        "id": 1,
                        "field": "cases.casestatusid",
                        "operator": "comparison_equalto",
                        "value": "3",
                        "resource_type": "proposition"
                    }
                ],
                "resource_type": "predicate_collection"
            }
        ],
        "actions": [
            {
                "id": 1,
                "name": "endpoint_1",
                "option": "SEND",
                "value": "{\"caseid\": \"{{case.id}}\" }",
                "attributes": [],
                "resource_type": "automation_action"
            }
        ],
        "execution_order": 1,
        "is_enabled": true,
        "last_executed_at": null,
        "created_at": "2016-05-19T18:23:11+00:00",
        "updated_at": "2016-05-19T18:23:11+00:00",
        "resource_type": "monitor",
        "resource_url": "https://brewfictus.kayako.com/api/v1/monitors/1"
    },
    "resource": "monitor"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment