nodeping

package module
v0.0.0-...-2203b33 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 3 Imported by: 0

README

NodePing Go Client

Documentation

Index

Constants

View Source
const BaseURL = "https://api.nodeping.com/api/1"
View Source
const Version = "0.0.1"

Variables

This section is empty.

Functions

func CheckForError

func CheckForError(err error, client *NodePingClient) error

Types

type CheckNotification

type CheckNotification map[string]struct {
	Delay    int    `json:"delay"`
	Schedule string `json:"schedule"`
}

type CheckRequest

type CheckRequest struct {
	ID            string              `json:"id"`
	Type          string              `json:"type"`
	Target        string              `json:"target"`
	Label         string              `json:"label"`
	Interval      int                 `json:"interval"`
	Enabled       string              `json:"enabled"`
	Public        string              `json:"public"`
	Runlocations  []string            `json:"runlocations"`
	Homeloc       bool                `json:"homeloc"`
	Threshold     int                 `json:"threshold"`
	Sens          int                 `json:"sens"`
	Notifications []CheckNotification `json:"notifications"`
	Dep           string              `json:"dep"`
	Contentstring string              `json:"contentstring"`
	Follow        bool                `json:"follow"`
	Data          string              `json:"data"`
	Method        string              `json:"method"`
	Statuscode    string              `json:"statuscode"`
	Ipv6          bool                `json:"ipv6"`
}

type CheckResponse

type CheckResponse struct {
	ID            string              `json:"_id"`
	Rev           string              `json:"_rev"`
	CustomerID    string              `json:"customer_id"`
	Label         string              `json:"label"`
	Interval      int                 `json:"interval"`
	Notifications []CheckNotification `json:"notifications"`
	Type          string              `json:"type"`
	Status        string              `json:"status"`
	Modified      int64               `json:"modified"`
	Enable        string              `json:"enable"`
	Public        bool                `json:"public"`
	Parameters    struct {
		Target    string `json:"target"`
		Threshold int    `json:"threshold"`
		Sens      int    `json:"sens"`
	} `json:"parameters"`
	Created   int64       `json:"created"`
	Queue     interface{} `json:"queue"` // This is normally a string but can be a bool sometimes
	UUID      string      `json:"uuid"`
	State     int         `json:"state"`
	Firstdown int64       `json:"firstdown"`
}

type ClientConfig

type ClientConfig struct {
	BaseURL    string
	Token      string
	CustomerID string
}

ClientConfig type includes configuration options for NodePing client.

type ContactGroupResponse

type ContactGroupResponse struct {
	Type       string        `json:"type"`
	CustomerID string        `json:"customer_id"`
	Name       string        `json:"name"`
	Members    []interface{} `json:"members"`
}

type NodePingClient

type NodePingClient struct {
	Config      ClientConfig
	Error       NodePingError
	R           *resty.Request
	MockResults string
}

NodePingClient holds config and provides methods for various api calls

var Client NodePingClient

func New

func New(config ClientConfig) (*NodePingClient, error)

Initialize new NodePingClient

func (*NodePingClient) GetCheck

func (c *NodePingClient) GetCheck(id string) (CheckResponse, error)

GetCheck retrieves data about one Check using its id

func (*NodePingClient) GetUptime

func (c *NodePingClient) GetUptime(id string, start, end int64) (map[string]UptimeResponse, error)

GetUptime retrieves the uptime entries for a certain check within an optional date range (by Timestamp with microseconds)

func (*NodePingClient) ListChecks

func (c *NodePingClient) ListChecks() ([]CheckResponse, error)

ListChecks retrieves all the "Checks" in NodePing

func (*NodePingClient) ListContactGroups

func (c *NodePingClient) ListContactGroups() (map[string]ContactGroupResponse, error)

ListContactGroups retrieves the list of Contact Groups

type NodePingError

type NodePingError struct {
	Error string `json:"error"`
}

type UptimeResponse

type UptimeResponse struct {
	Enabled int64   `json:"enabled"`
	Down    int64   `json:"down"`
	Uptime  float32 `json:"uptime"`
}

Jump to

Keyboard shortcuts

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