Skip to content

Instantly share code, notes, and snippets.

@lawrencejones
Last active November 10, 2021 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawrencejones/a3b44dd9e7bb33485202506894b3f36e to your computer and use it in GitHub Desktop.
Save lawrencejones/a3b44dd9e7bb33485202506894b3f36e to your computer and use it in GitHub Desktop.
Exemplar API responses from the workflow service

Workflow APIs

Exemplar API responses from the workflows service.

// GET /api/workflows/custom_workflows/01FKTS9GQB75BW52RSJKDTY1F1
{
custom_workflow: {
id: '01FKTS9GQB75BW52RSJKDTY1F1',
organisation_id: '01FD7MSVXV4GXH2C6X6QN98CH2',
workflow_id: '01FKEB8M77650Y6FCNKRCZVKWH',
name: 'My little workflow',
version: 3,
conditions: [
{
subject: {
label: 'Incident Severity',
icon: 'severity',
reference: 'incident.severity',
},
operation: {
label: 'is at least',
value: 'gte',
},
params: [
{
name: 'this',
label: 'this',
type: 'IncidentSeverity',
array: false,
},
],
param_bindings: [
{
value: '01FD7MSVXVYG7GVMRQ831CZTY3',
value_option: {
label: 'Major',
value: '01FD7MSVXVYG7GVMRQ831CZTY3',
sort_key: '00000002',
},
},
],
},
{
subject: {
label: 'Incident Team',
icon: 'custom_field',
reference: 'incident.custom_field["01FDS3ZR1TSWW2DVF1Q7F0MXHQ"]',
},
operation: {
label: 'is one of',
value: 'one_of',
},
params: [
{
name: 'set',
label: 'set',
type: 'IncidentCustomFieldOption["01FDS3ZR1TSWW2DVF1Q7F0MXHQ"]',
array: true,
},
],
param_bindings: [
{
array_value: [
'01FDS3ZR3JE3B89V67B2HQZS62',
],
array_value_options: [
{
label: 'Red',
value: '01FDS3ZR3JE3B89V67B2HQZS62',
sort_key: '00000010',
},
],
},
],
},
],
steps: [
{
name: 'incident.post_announcement',
label: 'Incident Post Announcement',
description: 'Posts an incident announcement message to a channel.',
params: [
{
name: 'incident',
label: 'Incident',
type: 'Incident',
array: false,
},
{
name: 'channel',
label: 'Channel',
type: 'SlackChannel',
array: false,
},
],
param_bindings: [
{
reference: 'incident',
},
{
value: 'C02A1FSP1J6',
value_option: {
label: 'stuff',
value: 'C02A1FSP1J6',
sort_key: 'stuff',
},
},
],
},
],
created_at: '2021-11-06T11:20:00.074361Z',
updated_at: '2021-11-06T11:20:00.074361Z',
},
}
// GET /api/workflows/steps/incident.post_announcement
{
step: {
name: 'incident.post_announcement',
label: 'Incident Post Announcement',
description: 'Posts an incident announcement message to a channel.',
resources: [
{
type: 'Incident',
operations: [],
field_config: {
type: 'none',
array_type: 'none',
icon: 'incident',
placeholder: 'Select incident',
array_placeholder: 'Select incidents',
},
},
{
type: 'SlackChannel',
operations: [],
field_config: {
type: 'single_external_user_select',
array_type: 'multi_external_user_select',
icon: 'slack_channel',
placeholder: 'Select channel',
array_placeholder: 'Select channels',
},
},
],
params: [
{
name: 'incident',
type: 'Incident',
array: false,
label: 'Incident',
},
{
name: 'channel',
type: 'SlackChannel',
array: false,
label: 'Channel',
},
],
},
}
// GET /api/workflows/steps/slack.post_message
{
step: {
name: 'slack.post_message',
label: 'Slack Post Message',
description: 'Posts a message to a Slack channel.',
resources: [
{
type: 'SlackChannel',
operations: [],
field_config: {
type: 'single_external_user_select',
array_type: 'multi_external_user_select',
icon: 'slack_channel',
placeholder: 'Select channel',
array_placeholder: 'Select channels',
},
},
],
params: [
{
name: 'channel',
type: 'SlackChannel',
array: false,
label: 'Channel',
},
],
},
}
// GET /api/workflows/steps
{
steps: [
{
name: 'debug.echo',
label: 'Debug Echo',
description: 'Logs a message whenever the step runs.',
},
{
name: 'incident.post_announcement',
label: 'Incident Post Announcement',
description: 'Posts an incident announcement message to a channel.',
},
{
name: 'incident.post_announcement_default',
label: 'Incident Post Announcement (Default)',
description: 'Posts an incident announcement message to the default announcement channel.',
},
{
name: 'slack.post_message',
label: 'Slack Post Message',
description: 'Posts a message to a Slack channel.',
},
],
}
// GET /api/workflows/triggers/incident.updated
{
trigger: {
name: 'incident.updated',
label: 'Incident updated',
description: 'Fired whenever an incident is updated, such as a severity change, role assignment or status change.',
resources: [
{
type: 'User',
operations: [
{
name: 'is_set',
label: 'is set',
params: [],
},
{
name: 'one_of',
label: 'is one of',
params: [
{
type: 'User',
array: true,
label: 'set',
},
],
},
{
name: 'not_one_of',
label: 'is not one of',
params: [
{
type: 'User',
array: true,
label: 'set',
},
],
},
],
field_config: {
type: 'single_external_user_select',
array_type: 'multi_external_user_select',
icon: 'user',
placeholder: 'Select user',
array_placeholder: 'Select users',
},
},
{
type: 'IncidentCustomFieldOption["01FH0J7MTA61XF4T61N42Z88ZH"]',
operations: [
{
name: 'is_set',
label: 'is set',
params: [],
},
{
name: 'is_not_set',
label: 'is not set',
params: [],
},
{
name: 'one_of',
label: 'is one of',
params: [
{
type: 'IncidentCustomFieldOption["01FH0J7MTA61XF4T61N42Z88ZH"]',
array: true,
label: 'set',
},
],
},
{
name: 'not_one_of',
label: 'is not one of',
params: [
{
type: 'IncidentCustomFieldOption["01FH0J7MTA61XF4T61N42Z88ZH"]',
array: true,
label: 'set',
},
],
},
],
field_config: {
type: 'single_static_select',
array_type: 'multi_static_select',
icon: 'custom_field',
placeholder: 'Select Blame',
array_placeholder: 'Select Blame',
},
options: [
{
label: 'Chris',
value: '01FH0J7MTAGZ9VG0FNM9RMRKKC',
sort_key: '00000030',
},
{
label: 'Pete',
value: '01FH0J7MTANRPHEY9MV8AQXQSE',
sort_key: '00000010',
},
{
label: 'Stephen',
value: '01FH0J7MTAP1APVZKMMPXYW3VK',
sort_key: '00000020',
},
],
},
{
type: 'IncidentCustomFieldMultiValue["01FDS3ZR1TSWW2DVF1Q7F0MXHQ"]',
operations: [
{
name: 'is_set',
label: 'is set',
params: [],
},
{
name: 'is_not_set',
label: 'is not set',
params: [],
},
{
name: 'one_of',
label: 'is one of',
params: [
{
type: 'IncidentCustomFieldOption["01FDS3ZR1TSWW2DVF1Q7F0MXHQ"]',
array: true,
label: 'set',
},
],
},
{
name: 'not_one_of',
label: 'is not one of',
params: [
{
type: 'IncidentCustomFieldOption["01FDS3ZR1TSWW2DVF1Q7F0MXHQ"]',
array: true,
label: 'set',
},
],
},
],
field_config: {
type: 'single_static_select',
array_type: 'multi_static_select',
icon: 'custom_field',
placeholder: 'Select Team',
array_placeholder: 'Select Team',
},
},
{
type: 'IncidentCustomFieldOption["01FH0J8VJT4NT8Z8WVRY13YHMK"]',
operations: [
{
name: 'is_set',
label: 'is set',
params: [],
},
{
name: 'is_not_set',
label: 'is not set',
params: [],
},
{
name: 'one_of',
label: 'is one of',
params: [
{
type: 'IncidentCustomFieldOption["01FH0J8VJT4NT8Z8WVRY13YHMK"]',
array: true,
label: 'set',
},
],
},
{
name: 'not_one_of',
label: 'is not one of',
params: [
{
type: 'IncidentCustomFieldOption["01FH0J8VJT4NT8Z8WVRY13YHMK"]',
array: true,
label: 'set',
},
],
},
],
field_config: {
type: 'single_static_select',
array_type: 'multi_static_select',
icon: 'custom_field',
placeholder: 'Select Type',
array_placeholder: 'Select Type',
},
options: [
{
label: 'Bad',
value: '01FH0J8VJT3M9D57Z79A2A6FPS',
sort_key: '00000010',
},
{
label: 'Good',
value: '01FH0J8VJTEMCPPW2QF265BE5C',
sort_key: '00000030',
},
{
label: 'Ok',
value: '01FH0J8VJTAVG5YYJ5QX36QMFM',
sort_key: '00000020',
},
],
},
{
type: 'Incident',
operations: [],
field_config: {
type: 'none',
array_type: 'none',
icon: 'incident',
placeholder: 'Select incident',
array_placeholder: 'Select incidents',
},
},
{
type: 'IncidentStatus',
operations: [
{
name: 'one_of',
label: 'is one of',
params: [
{
type: 'IncidentStatus',
array: true,
label: 'set',
},
],
},
{
name: 'not_one_of',
label: 'is not one of',
params: [
{
type: 'IncidentStatus',
array: true,
label: 'set',
},
],
},
],
field_config: {
type: 'single_static_select',
array_type: 'multi_static_select',
icon: 'status',
placeholder: 'Select status',
array_placeholder: 'Select statuses',
},
options: [
{
label: 'Investigating',
value: 'investigating',
sort_key: 'Investigating',
},
{
label: 'Fixing',
value: 'fixing',
sort_key: 'Fixing',
},
{
label: 'Monitoring',
value: 'monitoring',
sort_key: 'Monitoring',
},
{
label: 'Closed',
value: 'closed',
sort_key: 'Closed',
},
],
},
{
type: 'IncidentSeverity',
operations: [
{
name: 'one_of',
label: 'is one of',
params: [
{
type: 'IncidentSeverity',
array: true,
label: 'set',
},
],
},
{
name: 'not_one_of',
label: 'is not one of',
params: [
{
type: 'IncidentSeverity',
array: true,
label: 'set',
},
],
},
{
name: 'lte',
label: 'is at most',
params: [
{
type: 'IncidentSeverity',
array: false,
label: 'this',
},
],
},
{
name: 'gte',
label: 'is at least',
params: [
{
type: 'IncidentSeverity',
array: false,
label: 'this',
},
],
},
],
field_config: {
type: 'single_static_select',
array_type: 'multi_static_select',
icon: 'severity',
placeholder: 'Select severity',
array_placeholder: 'Select severities',
},
options: [
{
label: 'Critical',
value: '01FD7MSVXVX28DYTA002RSAMR7',
sort_key: '00000003',
},
{
label: 'Investigation',
value: '01FHAAY7D55BYDEJGPSXEEAX08',
sort_key: '00000000',
},
{
label: 'Major',
value: '01FD7MSVXVYG7GVMRQ831CZTY3',
sort_key: '00000002',
},
{
label: 'Minor',
value: '01FD7MSVXV954DD0B3WWAE859Q',
sort_key: '00000001',
},
],
},
{
type: 'SlackChannel',
operations: [],
field_config: {
type: 'single_external_user_select',
array_type: 'multi_external_user_select',
icon: 'slack_channel',
placeholder: 'Select channel',
array_placeholder: 'Select channels',
},
},
],
scope: [
{
key: 'incident',
label: 'Incident',
type: 'Incident',
},
{
key: 'incident.status',
label: 'Incident Status',
type: 'IncidentStatus',
},
{
key: 'incident.severity',
label: 'Incident Severity',
type: 'IncidentSeverity',
},
{
key: 'incident.slack_channel',
label: 'Incident SlackChannel',
type: 'SlackChannel',
},
{
key: 'incident.role["01FD7MSVZY2Z1JF2K9MD1GYKW9"]',
label: 'Incident Incident Lead',
type: 'User',
},
{
key: 'incident.custom_field["01FH0J7MTA61XF4T61N42Z88ZH"]',
label: 'Incident Blame',
type: 'IncidentCustomFieldOption["01FH0J7MTA61XF4T61N42Z88ZH"]',
},
{
key: 'incident.custom_field["01FDS3ZR1TSWW2DVF1Q7F0MXHQ"]',
label: 'Incident Team',
type: 'IncidentCustomFieldMultiValue["01FDS3ZR1TSWW2DVF1Q7F0MXHQ"]',
},
{
key: 'incident.custom_field["01FH0J8VJT4NT8Z8WVRY13YHMK"]',
label: 'Incident Type',
type: 'IncidentCustomFieldOption["01FH0J8VJT4NT8Z8WVRY13YHMK"]',
},
],
},
}
// GET /api/workflows/triggers
{
triggers: [
{
name: 'incident.updated',
label: 'Incident updated',
description: 'Fired whenever an incident is updated, such as a severity change, role assignment or status change.',
},
{
name: 'slack.message_posted',
label: 'Slack message posted',
description: 'Fired whenever someone posts a message in an incident channel.',
},
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment