View Source IncidentIo.WorkflowsV2 (IncidentIo v0.1.0)

Manage workflows.

Workflows allow you to automate certain actions and behaviors based on specific triggers.

Summary

Functions

Create a new workflow.

Archive an existing workflow.

List all workflows for an organisation.

Get a single workflow.

Update an existing workflow.

Functions

Link to this function

create(client \\ %Client{}, body)

View Source
@spec create(IncidentIo.Client.t(), request_body()) :: IncidentIo.response()

Create a new workflow.

Workflow body example:

%{
  annotations: %{
    "incident.io/terraform/version": "3.0.0"
  },
  condition_groups: [
    %{
      conditions: [
        %{
          operation: "one_of",
          param_bindings: [
            %{
              array_value: [
                %{
                  literal: "SEV123",
                  reference: "incident.severity"
                }
              ],
              value: %{
                literal: "SEV123",
                reference: "incident.severity"
              }
            }
          ],
          subject: "incident.severity"
        }
      ]
    }
  ],
  continue_on_step_error: true,
  delay: %{
    conditions_apply_over_delay: false,
    for_seconds: 60
  },
  expressions: [
    %{
      else_branch: %{
        result: %{
          array_value: [
            %{
              literal: "SEV123",
              reference: "incident.severity"
            }
          ],
          value: %{
            literal: "SEV123",
            reference: "incident.severity"
          }
        }
      },
      label: "Team Slack channel",
      operations: [
        %{
          branches: %{
            branches: [
              %{
                condition_groups: [
                  %{
                    conditions: [
                      %{
                        operation: "one_of",
                        param_bindings: [
                          %{
                            array_value: [
                              %{
                                literal: "SEV123",
                                reference: "incident.severity"
                              }
                            ],
                            value: %{
                              literal: "SEV123",
                              reference: "incident.severity"
                            }
                          }
                        ],
                        subject: "incident.severity"
                      }
                    ]
                  }
                ],
                result: %{
                  array_value: [
                    %{
                      literal: "SEV123",
                      reference: "incident.severity"
                    }
                  ],
                  value: %{
                    literal: "SEV123",
                    reference: "incident.severity"
                  }
                }
              }
            ],
            returns: %{
              array: true,
              type: "IncidentStatus"
            }
          },
          filter: %{
            condition_groups: [
              %{
                conditions: [
                  %{
                    operation: "one_of",
                    param_bindings: [
                      %{
                        array_value: [
                          %{
                            literal: "SEV123",
                            reference: "incident.severity"
                          }
                        ],
                        value: %{
                          literal: "SEV123",
                          reference: "incident.severity"
                        }
                      }
                    ],
                    subject: "incident.severity"
                  }
                ]
              }
            ]
          },
          navigate: %{
            reference: "catalog_attribute["01FCNDV6P870EA6S7TK1DSYD5H"]"
          },
          operation_type: "navigate",
          parse: %{
            returns: %{
              array: true,
              type: "IncidentStatus"
            },
            source: "metadata.annotations["github.com/repo"]"
          }
        }
      ],
      reference: "abc123",
      root_reference: "incident.status"
    }
  ],
  folder: "My folder 01",
  include_private_incidents: true,
  name: "My workflow",
  once_for: [
    "incident.url"
  ],
  runs_on_incident_modes: [
    "standard",
    "retrospective"
  ],
  runs_on_incidents: "newly_created",
  state: "active",
  steps: [
    %{
      for_each: "abc123",
      id: "abc123",
      name: "pagerduty.escalate",
      param_bindings: [
        %{
          array_value: [
            %{
              literal: "SEV123",
              reference: "incident.severity"
            }
          ],
          value: %{
            literal: "SEV123",
            reference: "incident.severity"
          }
        }
      ]
    }
  ],
  trigger: "incident.updated"
}

Example

IncidentIo.WorkflowsV2.create(client, body)

More information at: https://api-docs.incident.io/tag/Workflows-V2#operation/Workflows%20V2_Create

Link to this function

destroy(client \\ %Client{}, id)

View Source

Archive an existing workflow.

Example

IncidentIo.WorkflowsV2.destroy(client, "some-workflow-id")

More information at: https://api-docs.incident.io/tag/Workflows-V2#operation/Workflows%20V2_Delete

Link to this function

list(client \\ %Client{})

View Source

List all workflows for an organisation.

Example

IncidentIo.WorkflowsV2.list(client)

More information at: https://api-docs.incident.io/tag/Workflows-V2#operation/Workflows%20V2_List

Link to this function

show(client \\ %Client{}, id)

View Source

Get a single workflow.

Example

IncidentIo.WorkflowsV2.show(client, "some-workflow-id")

More information at: https://api-docs.incident.io/tag/Workflows-V2#operation/Workflows%20V2_Show

Link to this function

update(client \\ %Client{}, id, body)

View Source
@spec update(IncidentIo.Client.t(), binary(), request_body()) :: IncidentIo.response()

Update an existing workflow.

Workflow body example:

%{
  annotations: %{
    "incident.io/terraform/version": "3.0.0"
  },
  condition_groups: [
    %{
      conditions: [
        %{
          operation: "one_of",
          param_bindings: [
            %{
              array_value: [
                %{
                  literal: "SEV123",
                  reference: "incident.severity"
                }
              ],
              value: %{
                literal: "SEV123",
                reference: "incident.severity"
              }
            }
          ],
          subject: "incident.severity"
        }
      ]
    }
  ],
  continue_on_step_error: true,
  delay: %{
    conditions_apply_over_delay: false,
    for_seconds: 60
  },
  expressions: [
    %{
      else_branch: %{
        result: %{
          array_value: [
            %{
              literal: "SEV123",
              reference: "incident.severity"
            }
          ],
          value: %{
            literal: "SEV123",
            reference: "incident.severity"
          }
        }
      },
      label: "Team Slack channel",
      operations: [
        %{
          branches: %{
            branches: [
              %{
                condition_groups: [
                  %{
                    conditions: [
                      %{
                        operation: "one_of",
                        param_bindings: [
                          %{
                            array_value: [
                              %{
                                literal: "SEV123",
                                reference: "incident.severity"
                              }
                            ],
                            value: %{
                              literal: "SEV123",
                              reference: "incident.severity"
                            }
                          }
                        ],
                        subject: "incident.severity"
                      }
                    ]
                  }
                ],
                result: %{
                  array_value: [
                    %{
                      literal: "SEV123",
                      reference: "incident.severity"
                    }
                  ],
                  value: %{
                    literal: "SEV123",
                    reference: "incident.severity"
                  }
                }
              }
            ],
            returns: %{
              array: true,
              type: "IncidentStatus"
            }
          },
          filter: %{
            condition_groups: [
              %{
                conditions: [
                  %{
                    operation: "one_of",
                    param_bindings: [
                      %{
                        array_value: [
                          %{
                            literal: "SEV123",
                            reference: "incident.severity"
                          }
                        ],
                        value: %{
                          literal: "SEV123",
                          reference: "incident.severity"
                        }
                      }
                    ],
                    subject: "incident.severity"
                  }
                ]
              }
            ]
          },
          navigate: %{
            reference: "catalog_attribute["01FCNDV6P870EA6S7TK1DSYD5H"]"
          },
          operation_type: "navigate",
          parse: %{
            returns: %{
              array: true,
              type: "IncidentStatus"
            },
            source: "metadata.annotations["github.com/repo"]"
          }
        }
      ],
      reference: "abc123",
      root_reference: "incident.status"
    }
  ],
  folder: "My folder 01",
  include_private_incidents: true,
  name: "My workflow",
  once_for: [
    "incident.url"
  ],
  runs_on_incident_modes: [
    "standard",
    "retrospective"
  ],
  runs_on_incidents: "newly_created",
  state: "active",
  steps: [
    %{
      for_each: "abc123",
      id: "abc123",
      name: "pagerduty.escalate",
      param_bindings: [
        %{
          array_value: [
            %{
              literal: "SEV123",
              reference: "incident.severity"
            }
          ],
          value: %{
            literal: "SEV123",
            reference: "incident.severity"
          }
        }
      ]
    }
  ],
  trigger: "incident.updated"
}

Example

IncidentIo.WorkflowsV2.update(client, "some-workflow-id", body)

More information at: https://api-docs.incident.io/tag/Workflows-V2#operation/Workflows%20V2_Update