View Source incident_io
An Elixir client for the incident.io API.
With just a few lines of code you can begin interacting:
Mix.install([
{:incident_io, "~> 0.1"}
])
client = IncidentIo.Client.new(%{api_key: System.fetch_env!("INCIDENT_API_KEY")
IncidentIo.IncidentsV2.create(client, idempotency_key: "you-idempotency-key", visibility: :public)
Requirements
You'll need an incident.io account to use this package. Sign up on their website if you don't already have one.
Installation
Add :incident_io
to the dependencies in your project's mix.exs
:
def deps do
[
{:incident_io, "~> 0.1"}
]
end
Getting started
You will need to create an API key via your incident.io dashboard to make requests. Please note their warning message about the scope for this API key:
When you create the key, you'll be able to choose what actions it can take for your account: choose carefully, as those roles can only be set when you first create the key.
Once you've created an API key then you're ready to start making requests.
Example
Assuming that you've created and configured your incident.io API key as an
environment variable named INCIDENT_API_KEY
, you can
create and read incidents as simply as the following example module:
defmodule MyIncidentIo do
use IncidentIo
alias IncidentIo.Client
alias IncidentIo.IncidentsV2
def create(idempotency_key)
IncidentsV2.create(client, idempotency_key: idempotency_key, visibility: :public)
end
def read(incident_id)
IncidentsV2.show(client, incident_id)
end
defp client
Client.new(%{api_key: System.fetch_env!("INCIDENT_API_KEY")
end
end
Development
To start working on this application, clone the repository and fetch its dependencies:
git clone https://github.com/sgerrand/ex_incident_io.git
cd ex_incident_io
mix deps.get
Then you can start running the tests.
mix test
Contributing
Bug reports and pull requests are welcomed.
License
This package is available as open source under the terms of the MIT License.