cachet

package module
v0.0.0-...-34d0d14 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 10 Imported by: 9

README

cachet

GoDoc Build Status Go Report Card

Go(lang) client library for Cachet (open source status page system).

Features

  • Full API support
    • Components
    • Incidents
    • Metrics
    • Subscribers
  • Various authentication methods (Basic Auth and Token based)
  • Fully tested

Installation

It is go gettable

$ go get github.com/andygrunwald/cachet

(optional) to run unit / example tests:

$ cd $GOPATH/src/github.com/andygrunwald/cachet
$ go test -v ./...

API

Please have a look at the GoDoc documentation for a detailed API description.

Authentication

Cachet supports two different ways for authentication: BasicAuth and API Token. Both are supported by this library.

For BasicAuth you need to call the AuthenticationService and apply your email address and your password:

client.Authentication.SetBasicAuth("test@test.com", "test123")

To use the API Token way, you do nearly the same but use the SetTokenAuth function:

client.Authentication.SetTokenAuth("MY-SECRET-TOKEN")

Examples

Further a few examples how the API can be used. A few more examples are available in the GoDoc examples section.

Ping

Call the API test endpoint. Example without error handling. Full example available in the GoDoc examples section.

package main

import (
    "fmt"
    "github.com/andygrunwald/cachet"
)

func main() {
    client, _ := cachet.NewClient("https://demo.cachethq.io/", nil)
    pong, resp, _ := client.General.Ping()

    fmt.Printf("Result: %s\n", pong)
    fmt.Printf("Status: %s\n", resp.Status)

    // Output: Result: Pong!
    // Status: 200 OK
}
Create a new component

Calling /components. Example without error handling. Full example available in the GoDoc examples section.

package main

import (
    "fmt"
    "github.com/andygrunwald/cachet"
)

func main() {
    client, _ := cachet.NewClient("https://demo.cachethq.io/", nil)
    client.Authentication.SetBasicAuth("test@test.com", "test123")

    component := &cachet.Component{
        Name:        "Beer Fridge",
        Description: "Status of the beer fridge in the kitchen",
        Status:      cachet.ComponentStatusOperational,
    }
    newComponent, resp, _ := client.Components.Create(component)

    fmt.Printf("Result: %s\n", newComponent.Name)
    if newComponent.ID > 0 {
        fmt.Println("ID > 0!")
    }
    fmt.Printf("Status: %s\n", resp.Status)

    // Output: Beer Fridge
    // ID > 0!
    // Status: 200 OK
}

Supported versions

Tested with v1.2.1 of Cachet. It may works with older and / or newer versions. Newer versions will be supported. Older versions not.

License

This project is released under the terms of the MIT license.

Contribution and Contact

Contribution, in any kind of way, is highly welcome! It doesn't matter if you are not able to write code. Creating issues or holding talks and help other people to use cachet is contribution, too! A few examples:

  • Correct typos in the README / documentation
  • Reporting bugs
  • Implement a new feature or endpoint
  • Sharing the love if cachet and help people to get use to it

If you are new to pull requests, checkout Collaborating on projects using issues and pull requests / Creating a pull request. If you've found a bug, a typo, have a question or a want to request new feature, please report it as a GitHub issue.

For other queries, i'm available on Twitter (@andygrunwald).

Documentation

Overview

Package cachet provides a client for using the Cachet API (https://cachethq.io/).

Construct a new Cachet client, then use the various services on the client to access different parts of the Cachet API. For example:

instance := "https://demo.cachethq.io/"
client, err := cachet.NewClient(instance, nil)

// Get all components
components, resp, err := client.Components.GetAll()

The services of a client divide the API into logical chunks and correspond to the structure of the Cachet API documentation at https://docs.cachethq.io/docs/.

Authentication

The cachet library supports various methods to support the authentication. This methods are combined in the AuthenticationService that is available at client.Authentication.

One way is an authentication via HTTP BasicAuth:

instance := "https://demo.cachethq.io/"
client, err := cachet.NewClient(instance, nil)

client.Authentication.SetBasicAuth("test@test.com", "test123")

component := &cachet.Component{
	Name:        "Beer Fridge",
	Description: "Status of the beer fridge in the kitchen",
	Status:      cachet.ComponentStatusOperational,
}
newComponent, resp, err := client.Components.Create(component)

fmt.Printf("Result: %s\n", newComponent.Name)
// Result: Beer Fridge

The other way is the API Token by Cachet:

instance := "https://demo.cachethq.io/"
client, err := cachet.NewClient(instance, nil)

client.Authentication.SetTokenAuth("MY-SECRET-TOKEN")

// ... your action here

Additionally when creating a new client, pass an http.Client that supports further actions for you. For more information regarding authentication have a look at the Cachet documentation: https://docs.cachethq.io/docs/api-authentication

Index

Examples

Constants

View Source
const (
	// ComponentGroupVisibilityPublic means "Viewable by public"
	ComponentGroupVisibilityPublic = 1
	// ComponentGroupVisibilityLoggedIn means "Only visible to logged in users"
	ComponentGroupVisibilityLoggedIn = 0
)
View Source
const (

	// ComponentStatusUnknown means "The component's status is not known."
	ComponentStatusUnknown = 0
	// ComponentStatusOperational means "The component is working."
	ComponentStatusOperational = 1
	// ComponentStatusPerformanceIssues means "The component is experiencing some slowness."
	ComponentStatusPerformanceIssues = 2
	// ComponentStatusPartialOutage means "The component may not be working for everybody."
	// This could be a geographical issue for example.
	ComponentStatusPartialOutage = 3
	// ComponentStatusMajorOutage means "The component is not working for anybody."
	ComponentStatusMajorOutage = 4
)
View Source
const (

	// IncidentStatusScheduled means "This status is used for a scheduled status."
	IncidentStatusScheduled = 0
	// IncidentStatusInvestigating means "You have reports of a problem and you're currently looking into them."
	IncidentStatusInvestigating = 1
	// IncidentStatusIdentified means "You've found the issue and you're working on a fix."
	IncidentStatusIdentified = 2
	// IncidentStatusWatching means "You've since deployed a fix and you're currently watching the situation."
	IncidentStatusWatching = 3
	// IncidentStatusFixed means "The fix has worked, you're happy to close the incident."
	IncidentStatusFixed = 4

	// IncidentVisibilityPublic means "Viewable by public"
	IncidentVisibilityPublic = 1
	// IncidentVisibilityLoggedIn means "Only visible to logged in users"
	IncidentVisibilityLoggedIn = 0
)
View Source
const (
	// MetricsViewLastHour means "Default view: Last Hour"
	MetricsViewLastHour = 0
	// MetricsViewLast12Hours means "Default view: Last 12 Hours"
	MetricsViewLast12Hours = 1
	// MetricsViewLastWeek means "Default view: Week"
	MetricsViewLastWeek = 2
	// MetricsViewLastMonth means "Default view: Month"
	MetricsViewLastMonth = 3

	// MetricsCalculationSum means "Calculation of Metrics: Sum"
	MetricsCalculationSum = 0
	// MetricsCalculationAverage means "Calculation of Metrics: Average"
	MetricsCalculationAverage = 1

	// MetricsVisibilityLoggedIn means "Visibility: Visible to authenticated users"
	MetricsVisibilityLoggedIn = 0
	// MetricsVisibilityPublic means "Visibility: Visible to everybody"
	MetricsVisibilityPublic = 1
	// MetricsVisibilityHidden means "Visibility: Always hidden"
	MetricsVisibilityHidden = 2

	// MetricsNoDisplayChart means to not display chart in Status Page
	MetricsNoDisplayChart = 0
	// MetricsDisplayChart means to display chart in Status Page
	MetricsDisplayChart = 1
)
View Source
const (
	// ScheduleUpcoming means "This scheduled event is going to happen somewhere in the future."
	ScheduleUpcoming = 0
	// ScheduleInProgress means "This scheduled event is happening at the moment."
	ScheduleInProgress = 1
	// ScheduleComplete means "This scheduled event has already finished."
	ScheduleComplete = 2
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range.

Types

type AuthenticationService

type AuthenticationService struct {
	// contains filtered or unexported fields
}

AuthenticationService contains contains Authentication related functions.

func (*AuthenticationService) HasAuth

func (s *AuthenticationService) HasAuth() bool

HasAuth checks if an auth type is used

func (*AuthenticationService) HasBasicAuth

func (s *AuthenticationService) HasBasicAuth() bool

HasBasicAuth checks if the auth type is HTTP Basic auth

func (*AuthenticationService) HasTokenAuth

func (s *AuthenticationService) HasTokenAuth() bool

HasTokenAuth checks we auth with an API token against the API

func (*AuthenticationService) SetBasicAuth

func (s *AuthenticationService) SetBasicAuth(username, password string)

SetBasicAuth sets basic parameters for HTTP Basic auth. Attention! Basic Auth is no longer supported by Cachet since ~v2.1. You can only use this if you running an older version. Checkout https://github.com/CachetHQ/Cachet/issues/1658

func (*AuthenticationService) SetTokenAuth

func (s *AuthenticationService) SetTokenAuth(token string)

SetTokenAuth sets the API token for "token auth"

type Client

type Client struct {

	// Cachet service for authentication
	Authentication *AuthenticationService

	// Services used for talking to different parts of the Cachet API.
	General         *GeneralService
	Components      *ComponentsService
	ComponentGroups *ComponentGroupsService
	Incidents       *IncidentsService
	IncidentUpdates *IncidentUpdatesService
	Metrics         *MetricsService
	Schedules       *SchedulesService
	Subscribers     *SubscribersService
	Subscriptions   *SubscriptionsService
	// contains filtered or unexported fields
}

A Client manages communication with the Cachet API.

func NewClient

func NewClient(instance string, httpClient *http.Client) (*Client, error)

NewClient returns a new Cachet API client. instance has to be the HTTP endpoint of the Cachet instance. If a nil httpClient is provided, http.DefaultClient will be used.

func (*Client) Call

func (c *Client) Call(method, u string, body interface{}, v interface{}) (*Response, error)

Call is a combine function for Client.NewRequest and Client.Do.

Most API methods are quite the same. Get the URL, apply options, make a request, and get the response. Without adding special headers or something. To avoid a big amount of code duplication you can Client.Call.

method is the HTTP method you want to call. u is the URL you want to call. body is the HTTP body. v is the HTTP response.

For more information read https://github.com/google/go-github/issues/234

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type Component

type Component struct {
	ID          int    `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Link        string `json:"link,omitempty"`
	Status      int    `json:"status,omitempty"`
	Order       int    `json:"order,omitempty"`
	Enabled     bool   `json:"enabled,omitempty"`
	GroupID     int    `json:"group_id,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
	DeletedAt   string `json:"deleted_at,omitempty"`
	StatusName  string `json:"status_name,omitempty"`
}

Component entity reflects one single component

type ComponentGroup

type ComponentGroup struct {
	ID                      int         `json:"id,omitempty"`
	Name                    string      `json:"name,omitempty"`
	Order                   int         `json:"order,omitempty"`
	Collapsed               int         `json:"collapsed,omitempty"`
	Visible                 int         `json:"visible,omitempty"`
	CreatedAt               string      `json:"created_at,omitempty"`
	UpdatedAt               string      `json:"updated_at,omitempty"`
	EnabledComponents       []Component `json:"enabled_components,omitempty"`
	EnabledComponentsLowest []Component `json:"enabled_components_lowest,omitempty"`
	LowestHumanStatus       string      `json:"lowest_human_status,omitempty"`
}

ComponentGroup entity reflects one single component group

type ComponentGroupResponse

type ComponentGroupResponse struct {
	Meta            Meta             `json:"meta,omitempty"`
	ComponentGroups []ComponentGroup `json:"data,omitempty"`
}

ComponentGroupResponse reflects the response of /components/groups call

type ComponentGroupsQueryParams

type ComponentGroupsQueryParams struct {
	ID        int    `url:"id,omitempty"`
	Name      string `url:"name,omitempty"`
	Order     int    `url:"order,omitempty"`
	Collapsed bool   `url:"collapsed,omitempty"`
	Visible   int    `url:"visible,omitempty"`
	QueryOptions
}

ComponentGroupsQueryParams contains fields to filter returned results

type ComponentGroupsService

type ComponentGroupsService struct {
	// contains filtered or unexported fields
}

ComponentGroupsService contains REST endpoints that belongs to cachet components.

func (*ComponentGroupsService) Create

Create creates a new component group.

Docs: https://docs.cachethq.io/reference#post-componentgroups

func (*ComponentGroupsService) Delete

func (s *ComponentGroupsService) Delete(id int) (*Response, error)

Delete deletes a component group.

Docs: https://docs.cachethq.io/reference#delete-component-group

func (*ComponentGroupsService) Get

Get return a single component group.

Docs: https://docs.cachethq.io/reference#get-a-component-group

func (*ComponentGroupsService) GetAll

GetAll return all component groups that have been created.

Docs: https://docs.cachethq.io/reference#get-componentgroups

func (*ComponentGroupsService) Update

Update updates a component group.

Docs: https://docs.cachethq.io/reference#put-component-group

type ComponentResponse

type ComponentResponse struct {
	Meta       Meta        `json:"meta,omitempty"`
	Components []Component `json:"data,omitempty"`
}

ComponentResponse reflects the response of /components call

type ComponentsQueryParams

type ComponentsQueryParams struct {
	ID      int    `url:"id,omitempty"`
	Name    string `url:"name,omitempty"`
	Status  int    `url:"status,omitempty"`
	Order   int    `url:"order,omitempty"`
	Enabled bool   `url:"enabled,omitempty"`
	GroupID int    `url:"group_id,omitempty"`
	QueryOptions
}

ComponentsQueryParams contains fields to filter returned results

type ComponentsService

type ComponentsService struct {
	// contains filtered or unexported fields
}

ComponentsService contains REST endpoints that belongs to cachet components.

func (*ComponentsService) Create

func (s *ComponentsService) Create(c *Component) (*Component, *Response, error)

Create a new component.

Docs: https://docs.cachethq.io/reference#components

func (*ComponentsService) Delete

func (s *ComponentsService) Delete(id int) (*Response, error)

Delete deletes a component.

Docs: https://docs.cachethq.io/docs/delete-a-component

func (*ComponentsService) Get

func (s *ComponentsService) Get(id int) (*Component, *Response, error)

Get return a single component.

Docs: https://docs.cachethq.io/reference#get-a-component

Example
package main

import (
	"fmt"

	"github.com/andygrunwald/cachet"
)

func main() {
	client, err := cachet.NewClient("https://dev.cachethq.io/", nil)
	if err != nil {
		panic(err)
	}

	comp, resp, err := client.Components.Get(1)
	if err != nil {
		panic(resp)
	}

	fmt.Printf("Result: %s (ID: %d)\n", comp.Name, comp.ID)
	fmt.Printf("Status: %s\n", resp.Status)

}
Output:

Result: API (ID: 1)
Status: 200 OK

func (*ComponentsService) GetAll

GetAll return all components that have been created.

Docs: https://docs.cachethq.io/reference#get-components

func (*ComponentsService) Update

func (s *ComponentsService) Update(id int, c *Component) (*Component, *Response, error)

Update updates a component.

Docs: https://docs.cachethq.io/docs/update-a-component

type GeneralService

type GeneralService struct {
	// contains filtered or unexported fields
}

GeneralService contains REST endpoints that belongs no specific service.

func (*GeneralService) Ping

func (s *GeneralService) Ping() (string, *Response, error)

Ping calls the API test endpoint.

Docs: https://docs.cachethq.io/reference#ping

Example
package main

import (
	"fmt"

	"github.com/andygrunwald/cachet"
)

func main() {
	client, err := cachet.NewClient("https://dev.cachethq.io/", nil)
	if err != nil {
		panic(err)
	}

	pong, resp, err := client.General.Ping()
	if err != nil {
		panic(err)
	}

	fmt.Printf("Result: %s\n", pong)
	fmt.Printf("Status: %s\n", resp.Status)

}
Output:

Result: Pong!
Status: 200 OK

func (*GeneralService) Status

func (s *GeneralService) Status() (*Status, *Response, error)

Status get Cachet status

Docs: <none>

func (*GeneralService) Version

func (s *GeneralService) Version() (*VersionResponse, *Response, error)

Version get Cachet version

Docs: https://docs.cachethq.io/reference#version

type Incident

type Incident struct {
	ID                int              `json:"id,omitempty"`
	Name              string           `json:"name,omitempty"`
	Status            int              `json:"status,omitempty"`
	Message           string           `json:"message,omitempty"`
	Visible           int              `json:"visible,omitempty"`
	ComponentID       int              `json:"component_id,omitempty"`
	ComponentStatus   int              `json:"component_status,omitempty"`
	Notify            bool             `json:"notify,omitempty"`
	Stickied          bool             `json:"stickied,omitempty"`
	OccurredAt        string           `json:"occurred_at,omitempty"`
	Template          string           `json:"template,omitempty"`
	Vars              []string         `json:"vars,omitempty"`
	CreatedAt         string           `json:"created_at,omitempty"`
	UpdatedAt         string           `json:"updated_at,omitempty"`
	DeletedAt         string           `json:"deleted_at,omitempty"`
	IsResolved        bool             `json:"is_resolved,omitempty"`
	Updates           []IncidentUpdate `json:"updates,omitempty"`
	HumanStatus       string           `json:"human_status,omitempty"`
	LatestUpdateID    int              `json:"latest_update_id,omitempty"`
	LatestStatus      int              `json:"latest_status,omitempty"`
	LatestHumanStatus string           `json:"latest_human_status,omitempty"`
	LatestIcon        string           `json:"latest_icon,omitempty"`
	Permalink         string           `json:"permalink,omitempty"`
	Duration          int              `json:"duration,omitempty"`
}

Incident entity reflects one single incident

type IncidentResponse

type IncidentResponse struct {
	Meta      Meta       `json:"meta,omitempty"`
	Incidents []Incident `json:"data,omitempty"`
}

IncidentResponse reflects the response of /incidents call

type IncidentUpdate

type IncidentUpdate struct {
	ID              int    `json:"id,omitempty"`
	IncidentID      int    `json:"incident_id,omitempty"`
	ComponentID     int    `json:"component_id,omitempty"`
	ComponentStatus int    `json:"component_status,omitempty"`
	Status          int    `json:"status,omitempty"`
	Message         string `json:"message,omitempty"`
	UserID          int    `json:"user_id,omitempty"`
	CreatedAt       string `json:"created_at,omitempty"`
	UpdatedAt       string `json:"updated_at,omitempty"`
	HumanStatus     string `json:"human_status,omitempty"`
	Permalink       string `json:"permalink,omitempty"`
}

IncidentUpdate entity reflects one single incident update

type IncidentUpdateResponse

type IncidentUpdateResponse struct {
	Meta            Meta             `json:"meta,omitempty"`
	IncidentUpdates []IncidentUpdate `json:"data,omitempty"`
}

IncidentUpdateResponse reflects the response of /incident updates call

type IncidentUpdatesService

type IncidentUpdatesService struct {
	// contains filtered or unexported fields
}

IncidentUpdatesService contains REST endpoints that belongs to cachet incidents.

func (*IncidentUpdatesService) Create

func (s *IncidentUpdatesService) Create(incidentID int, i *IncidentUpdate) (*IncidentUpdate, *Response, error)

Create creates a new incident update.

Docs: https://docs.cachethq.io/reference#incidentsincidentupdates

func (*IncidentUpdatesService) Delete

func (s *IncidentUpdatesService) Delete(incidentID int, updateID int) (*Response, error)

Delete deletes an incident update.

Docs: https://docs.cachethq.io/reference#incidentsincidentupdatesupdate

func (*IncidentUpdatesService) Get

func (s *IncidentUpdatesService) Get(incidentID int, updateID int) (*IncidentUpdate, *Response, error)

Get returns a single incident update.

Docs: https://docs.cachethq.io/reference#incidentsidupdatesid

func (*IncidentUpdatesService) GetAll

func (s *IncidentUpdatesService) GetAll(incidentID int) (*IncidentUpdateResponse, *Response, error)

GetAll return all updates by incident.

Docs: https://docs.cachethq.io/reference#incidentsidupdates

func (*IncidentUpdatesService) Update

func (s *IncidentUpdatesService) Update(incidentID int, updateID int, i *IncidentUpdate) (*IncidentUpdate, *Response, error)

Update updates an incident update.

Docs: https://docs.cachethq.io/reference#incidentsincidentupdatesupdate-1

type IncidentsQueryParams

type IncidentsQueryParams struct {
	ID          int    `url:"id,omitempty"`
	Name        string `url:"name,omitempty"`
	Status      int    `url:"status,omitempty"`
	Visible     int    `url:"visible,omitempty"`
	ComponentID int    `url:"component_id,omitempty"`
	Stickied    bool   `url:"stickied,omitempty"`
	QueryOptions
}

IncidentsQueryParams contains fields to filter returned results

type IncidentsService

type IncidentsService struct {
	// contains filtered or unexported fields
}

IncidentsService contains REST endpoints that belongs to cachet incidents.

func (*IncidentsService) Create

func (s *IncidentsService) Create(i *Incident) (*Incident, *Response, error)

Create a new incident.

Docs: https://docs.cachethq.io/reference#incidents

func (*IncidentsService) Delete

func (s *IncidentsService) Delete(id int) (*Response, error)

Delete delete an incident.

Docs: https://docs.cachethq.io/reference#delete-an-incident

func (*IncidentsService) Get

func (s *IncidentsService) Get(id int) (*Incident, *Response, error)

Get returns a single incident.

Docs: https://docs.cachethq.io/reference#get-an-incident

func (*IncidentsService) GetAll

GetAll return all incidents.

Docs: https://docs.cachethq.io/reference#get-incidents

func (*IncidentsService) Update

func (s *IncidentsService) Update(id int, i *Incident) (*Incident, *Response, error)

Update updates an incident.

Docs: https://docs.cachethq.io/reference#update-an-incident

type Latest

type Latest struct {
	TagName  string `json:"tag_name"`
	Prelease bool   `json:"prelease"`
	Draft    bool   `json:"draft"`
}

Latest ...

type Links struct {
	NextPage     string `json:"next_page"`
	PreviousPage string `json:"previous_page"`
}

Links will contain urls about the next and previous page.

Docs: https://docs.cachethq.io/docs/meta

type Meta

type Meta struct {
	Pagination Pagination `json:"pagination"`
}

Meta can contain extra information such as the current paging attributes or links to other pages. Some responses will contain a meta object.

Docs: https://docs.cachethq.io/docs/meta

type MetaVersion

type MetaVersion struct {
	OnLatest bool   `json:"on_latest"`
	Latest   Latest `json:"latest"`
}

MetaVersion ...

type Metric

type Metric struct {
	ID              int    `json:"id,omitempty"`
	Name            string `json:"name,omitempty"`
	Suffix          string `json:"suffix,omitempty"`
	Description     string `json:"description,omitempty"`
	DefaultValue    int    `json:"default_value"`
	CalcType        int    `json:"calc_type,omitempty"`
	DisplayChart    bool   `json:"display_chart,omitempty"`
	Places          int    `json:"places,omitempty"`
	DefaultView     int    `json:"default_view,omitempty"`
	Threshold       int    `json:"threshold,omitempty"`
	Order           int    `json:"order,omitempty"`
	Visible         int    `json:"visible,omitemtpy"`
	CreatedAt       string `json:"created_at,omitempty"`
	UpdatedAt       string `json:"updated_at,omitempty"`
	DefaultViewName string `json:"default_view_name,omitempty"`
}

Metric entity reflects one single metric

type MetricQueryParams

type MetricQueryParams struct {
	QueryOptions
}

MetricQueryParams contains fields to filter returned results

type MetricResponse

type MetricResponse struct {
	Meta    Meta     `json:"meta,omitempty"`
	Metrics []Metric `json:"data,omitempty"`
}

MetricResponse reflects the response of /metric call

type MetricsService

type MetricsService struct {
	// contains filtered or unexported fields
}

MetricsService contains REST endpoints that belongs to cachet metrics.

func (*MetricsService) AddPoint

func (s *MetricsService) AddPoint(id int, value int, timestamp string) (*Point, *Response, error)

AddPoint adds a metric point to a given metric.

Docs: https://docs.cachethq.io/reference#post-metric-points

func (*MetricsService) Create

func (s *MetricsService) Create(m *Metric) (*Metric, *Response, error)

Create a new metric.

Docs: https://docs.cachethq.io/reference#metrics

func (*MetricsService) Delete

func (s *MetricsService) Delete(id int) (*Response, error)

Delete a metric.

Docs: https://docs.cachethq.io/reference#delete-a-metric

func (*MetricsService) DeletePoint

func (s *MetricsService) DeletePoint(id, pointID int) (*Response, error)

DeletePoint deletes a metric point.

Docs: https://docs.cachethq.io/reference#delete-a-metric-point

func (*MetricsService) Get

func (s *MetricsService) Get(id int) (*Metric, *Response, error)

Get returns a single metric, without points.

Docs: https://docs.cachethq.io/reference#get-a-metric

func (*MetricsService) GetAll

GetAll returns all metrics that have been setup.

Docs: https://docs.cachethq.io/reference#get-metrics

func (*MetricsService) GetPoints

func (s *MetricsService) GetPoints(id int) (*[]Point, *Response, error)

GetPoints return a list of metric points.

Docs: https://docs.cachethq.io/reference#get-metric-points

type Pagination

type Pagination struct {
	Total       int   `json:"total"`
	Count       int   `json:"count"`
	PerPage     int   `json:"per_page"`
	CurrentPage int   `json:"current_page"`
	TotalPages  int   `json:"total_pages"`
	Links       Links `json:"links"`
}

Pagination will contain detail information about pages.

Docs: https://docs.cachethq.io/docs/meta

type PingResponse

type PingResponse struct {
	Data string `json:"data,omitempty"`
}

PingResponse entity contains the Response of a /ping call.

type Point

type Point struct {
	ID              int    `json:"id,omitempty"`
	MetricID        int    `json:"metric_id,omitempty"`
	Value           int    `json:"value,omitempty"`
	CreatedAt       string `json:"created_at,omitempty"`
	UpdatedAt       string `json:"updated_at,omitempty"`
	Counter         int    `json:"counter,omitempty"`
	CalculatedValue int    `json:"calculated_value,omitempty"`
}

Point is a single point in a Metric

type QueryOptions

type QueryOptions struct {
	Page      int    `url:"page,omitempty"`
	PerPage   int    `url:"per_page,omitempty"`
	SortField string `url:"sort,omitempty"`
	OrderType string `url:"order,omitempty"`
}

QueryOptions is a list of general params in each GET request.

type Response

type Response struct {
	*http.Response
}

Response is a Cachet API response. This wraps the standard http.Response returned from Cachet.

type Schedule

type Schedule struct {
	ID          int         `json:"id,omitempty"`
	Name        string      `json:"name,omitempty"`
	Message     string      `json:"message,omitempty"`
	Status      int         `json:"status,omitempty"`
	ScheduledAt string      `json:"scheduled_at,omitempty"`
	CompletedAt string      `json:"completed_at,omitempty"`
	CreatedAt   string      `json:"created_at,omitempty"`
	UpdatedAt   string      `json:"updated_at,omitempty"`
	Components  []Component `json:"components,omitempty"`
	HumanStatus string      `json:"human_status,omitempty"`
}

Schedule entity reflects one single schedule

type ScheduleResponse

type ScheduleResponse struct {
	Meta      Meta       `json:"meta,omitempty"`
	Schedules []Schedule `json:"data,omitempty"`
}

ScheduleResponse reflects the response of schedules call

type SchedulesQueryParams

type SchedulesQueryParams struct {
	ID     int    `url:"id,omitempty"`
	Name   string `url:"name,omitempty"`
	Status int    `url:"order,omitempty"`
	QueryOptions
}

SchedulesQueryParams contains fields to filter returned results

type SchedulesService

type SchedulesService struct {
	// contains filtered or unexported fields
}

SchedulesService contains REST endpoints that belongs to cachet schedules.

func (*SchedulesService) Create

func (s *SchedulesService) Create(i *Schedule) (*Schedule, *Response, error)

Create creates a new scheduled event.

Docs: https://docs.cachethq.io/reference#incidentsincidentupdates

func (*SchedulesService) Delete

func (s *SchedulesService) Delete(id int) (*Response, error)

Delete deletes a scheduled event.

Docs: https://docs.cachethq.io/reference#incidentsincidentupdatesupdate

func (*SchedulesService) Get

func (s *SchedulesService) Get(id int) (*Schedule, *Response, error)

Get returns a single scheduled event.

Docs: https://docs.cachethq.io/reference#incidentsidupdatesid

func (*SchedulesService) GetAll

GetAll return all scheduled events.

Docs: https://docs.cachethq.io/reference#incidentsidupdates

func (*SchedulesService) Update

func (s *SchedulesService) Update(id int, i *Schedule) (*Schedule, *Response, error)

Update updates a scheduled event.

Docs: https://docs.cachethq.io/reference#incidentsincidentupdatesupdate-1

type SortOrdering

type SortOrdering struct {
	Sort    string `json:"sort"`
	Order   string `json:"order"`
	PerPage int    `json:"per_page"`
}

SortOrdering ...

type Status

type Status struct {
	Status  string `json:"status,omitempty"`
	Message string `json:"message,omitempty"`
}

Status entity contains the contents of API Response of a /status call.

type StatusAPIResponse

type StatusAPIResponse struct {
	Data *Status `json:"data"`
}

StatusAPIResponse entity contains the Response of a /status call.

type Subscriber

type Subscriber struct {
	ID         int    `json:"id,omitempty"`
	Email      string `json:"email,omitempty"`
	VerifyCode string `json:"verify_code,omitempty"`
	VerifiedAt string `json:"verified_at,omitempty"`
	CreatedAt  string `json:"created_at,omitempty"`
	UpdatedAt  string `json:"updated_at,omitempty"`
}

Subscriber entity reflects one single subscriber

type SubscriberResponse

type SubscriberResponse struct {
	Meta        Meta         `json:"meta,omitempty"`
	Subscribers []Subscriber `json:"data,omitempty"`
}

SubscriberResponse reflects the response of /subscribers call

type SubscribersQueryParams

type SubscribersQueryParams struct {
	QueryOptions
}

SubscribersQueryParams contains fields to filter returned results

type SubscribersService

type SubscribersService struct {
	// contains filtered or unexported fields
}

SubscribersService contains REST endpoints that belongs to cachet subscribers.

func (*SubscribersService) Create

func (s *SubscribersService) Create(email string, verify int) (*Subscriber, *Response, error)

Create a new subscriber.

Docs: https://docs.cachethq.io/reference#subscribers

func (*SubscribersService) Delete

func (s *SubscribersService) Delete(id int) (*Response, error)

Delete a subscriber.

Docs: https://docs.cachethq.io/reference#delete-subscriber

func (*SubscribersService) GetAll

GetAll returns all subscribers.

Docs: https://docs.cachethq.io/reference#get-subscribers

type SubscriptionsService

type SubscriptionsService struct {
	// contains filtered or unexported fields
}

SubscriptionsService contains REST endpoints that belongs to cachet subscriptions.

func (*SubscriptionsService) Delete

func (s *SubscriptionsService) Delete(id int) (*Response, error)

Delete deletes a subscription.

Docs: https://docs.cachethq.io/reference#incidentsincidentupdatesupdate

type Tag

type Tag struct {
	Tag string `json:"tag,omitempty"`
}

Tag ...

type VersionResponse

type VersionResponse struct {
	Meta MetaVersion `json:"meta,omitempty"`
	Data string      `json:"data,omitempty"`
}

VersionResponse entity contains the Response of a /version call.

Jump to

Keyboard shortcuts

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