OpsGenie REST API

This package was created with the Swagger Code Generator using the OpsGenie OpenAPI Specification . The only modifications were made to this README and the file connection.ex in order to be able to initialize a connection with the Authorization header.

Installation

Add ops_genie_restapi to your list of dependencies in mix.exs:

def deps do
  [{:ops_genie_restapi, "~> 0.1.1"}]
end

Configuration

Add the OpsGenie API key to your config:

config :my_app, :opsgenie_api_key, "*******"

Create a connection:

  def create_connection() do
    case Application.get_env(:my_app, :opsgenie_api_key) do
      nil -> {:error, "No OpsGenie API key defined"}
      api_key -> {:ok, OpsGenieRESTAPI.Connection.new(api_key)}
    end
  end

Example

Use the function create_connection() above in the api calls. E.g. to create an alert:

  def create_alert(subject, body) do
    payload = %OpsGenieRESTAPI.Model.CreateAlertPayload{
      message: subject,
      description: body,
      tags: ["my_app"]
    }

    with {:ok, connection} <- create_connection() do
      OpsGenieRESTAPI.Api.Alert.create_alert(connection, payload)
    else
      {:error, error} -> IO.warn(error)
    end
  end