Skip to content

iLert/ilert-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5fc572b · Jul 12, 2022

History

91 Commits
Jul 4, 2022
Oct 16, 2020
Apr 15, 2022
Feb 22, 2021
Jul 4, 2022
Jun 17, 2022
Jul 8, 2022
Jul 12, 2022
Jul 12, 2022
Jun 30, 2022
Jul 8, 2022
Apr 15, 2022
Apr 8, 2021
Jul 4, 2022
Jun 17, 2022
Apr 9, 2021
Apr 8, 2021
Oct 19, 2020
Jul 8, 2022
Jul 12, 2022
Apr 8, 2021
Jul 12, 2022
Jul 8, 2022
Jul 8, 2022
Apr 8, 2021
Jul 8, 2022
Jul 8, 2022
Jul 12, 2022

Repository files navigation

ilert-go

The official iLert Go api bindings.

Legacy API

If you want to use the old client with v1 resources, please install it with the following command: go get github.com/iLert/ilert-go

Create an incident (manually)

package main

import (
	"log"
	"github.com/iLert/ilert-go/v2"
)

func main() {

	// We strongly recommend to enable a retry logic if an error occurs
	client := ilert.NewClient(ilert.WithRetry(10, 5*time.Second, 20*time.Second))

	var apiKey = "alert source API Key"
	event := &ilert.Event{
		APIKey:      apiKey,
		EventType:   ilert.EventTypes.Alert,
		Summary:     "My test alert summary",
		AlertKey: "123456",
	}

	input := &ilert.CreateEventInput{Event: event}
	result, err := client.CreateEvent(input)
	if err != nil {
		log.Println(result)
		log.Fatalln("ERROR:", err)
	}

	log.Println("Event processed!")
}

Ping heartbeat

package main

import (
	"log"
	"github.com/iLert/ilert-go/v2"
)

func main() {

	client := ilert.NewClient()

	var apiKey = "heartbeat API Key"
	result, err := client.PingHeartbeat(&ilert.PingHeartbeatInput{
		APIKey: ilert.String(apiKey),
		Method: ilert.String(ilert.HeartbeatMethods.HEAD),
	})

	if err != nil {
		log.Println(result)
		log.Fatalln("ERROR:", err)
	}

	log.Println("Heartbeat is ok!")
}

Using proxy

package main

import (
	"log"
	"github.com/iLert/ilert-go/v2"
)

func main() {
	client := ilert.NewClient(ilert.WithProxy("http://proxyserver:8888"))
	...
}

Getting help

We are happy to respond to GitHub issues as well.


License

Licensed under Apache License, Version 2.0
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in ilert-go by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.