healthchecksio

package module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 8 Imported by: 5

README

go-healthchecksio

A go client for working with the healthchecks.io api.

Installation

go get github.com/kristofferahl/go-healthchecksio

Usage

package main

import (
	"log"
	"os"

	"github.com/kristofferahl/go-healthchecksio"
)

func main() {
	apiKey := os.Getenv("HEALTHCHECKSIO_API_KEY") // See https://healthchecks.io/docs/api/

	client := healthchecksio.NewClient(apiKey)
	check := healthchecksio.Healthcheck{
		Name: "My first test",
		Tags: "go ftw",
	}

	healthcheck, err := client.Create(check)
	if err != nil {
		log.Printf("[ERROR] error creating healthcheck: %s", err)
		os.Exit(1)
	}

	log.Printf("[DEBUG] created healthcheck: %s", healthcheck)
}

Documentation

Docs can be found at godoc.org.

Developing

Running the tests requires a valid healthchecks.io API key (See https://healthchecks.io/docs/api/). Make sure the following environment variables are set.

export HEALTHCHECKSIO_API_KEY='{your api key}'

Roadmap

  • Required fields validation

Contributing

...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey      string
	BaseURL     string
	ContentType string
	HTTPClient  *http.Client
}

Client provides access to create, read, update and delete healthchecks.io resources

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new client

func (*Client) Create

func (c *Client) Create(check Healthcheck) (*HealthcheckResponse, error)

Create creates a new healthcheck

func (*Client) Delete

func (c *Client) Delete(id string) (*HealthcheckResponse, error)

Delete deletes an existing healthcheck

func (*Client) GetAll

func (c *Client) GetAll() ([]*HealthcheckResponse, error)

GetAll returns all healthchecks

func (*Client) GetAllChannels

func (c *Client) GetAllChannels() ([]*HealthcheckChannelResponse, error)

GetAllChannels returns all channels

func (*Client) Pause

func (c *Client) Pause(id string) (*HealthcheckResponse, error)

Pause pauses monitoring on existing healthcheck

func (*Client) Update

func (c *Client) Update(id string, check Healthcheck) (*HealthcheckResponse, error)

Update updates an existing healthcheck

type Healthcheck

type Healthcheck struct {
	Channels    string   `json:"channels,omitempty"`
	Grace       int      `json:"grace,omitempty"`
	Name        string   `json:"name,omitempty"`
	Schedule    string   `json:"schedule,omitempty"`
	Tags        string   `json:"tags,omitempty"`
	Timeout     int      `json:"timeout,omitempty"`
	Timezone    string   `json:"tz,omitempty"`
	Unique      []string `json:"unique,omitempty"`
	Description string   `json:"desc,omitempty"`
	Methods     string   `json:"methods,omniempty"`
}

Healthcheck represents a healthcheck

func (*Healthcheck) ToJSON

func (hc *Healthcheck) ToJSON() (string, error)

ToJSON returns a json representation of a healthcheck data

type HealthcheckChannelResponse

type HealthcheckChannelResponse struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Kind string `json:"kind,omitempty"`
}

HealthcheckChannelResponse represents a channel response of healthcheck api

func (*HealthcheckChannelResponse) String

func (hc *HealthcheckChannelResponse) String() string

func (*HealthcheckChannelResponse) ToJSON

func (hc *HealthcheckChannelResponse) ToJSON() (string, error)

ToJSON returns a json representation of a healthcheck channel

type HealthcheckResponse

type HealthcheckResponse struct {
	Channels    string `json:"channels,omitempty"`
	Grace       int    `json:"grace,omitempty"`
	LastPing    string `json:"last_ping,omitempty"`
	Name        string `json:"name,omitempty"`
	NextPing    string `json:"next_ping,omitempty"`
	PauseURL    string `json:"pause_url,omitempty"`
	Pings       int    `json:"n_pings,omitempty"`
	PingURL     string `json:"ping_url,omitempty"`
	Schedule    string `json:"schedule,omitempty"`
	Status      string `json:"status,omitempty"`
	Tags        string `json:"tags,omitempty"`
	Timeout     int    `json:"timeout,omitempty"`
	Timezone    string `json:"tz,omitempty"`
	UpdateURL   string `json:"update_url,omitempty"`
	Description string `json:"desc,omitempty"`
	Methods     string `json:"methods,omniempty"`
}

HealthcheckResponse represents a healthcheck api response

func (*HealthcheckResponse) ID

func (hc *HealthcheckResponse) ID() string

ID returns the identifier of a healthcheck

func (*HealthcheckResponse) String

func (hc *HealthcheckResponse) String() string

func (*HealthcheckResponse) ToJSON

func (hc *HealthcheckResponse) ToJSON() (string, error)

ToJSON returns a json representation of a healthcheck

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL