Go(lang) client library for Cachet (open source status page system).
Go
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2a1ca51 Apr 5, 2018
Permalink
Failed to load latest commit information.
.gitignore Initial commit Oct 31, 2015
.travis.yml Removed goveralls of travis ci Oct 6, 2017
LICENSE Initial commit Oct 31, 2015
README.md Merged with upstream master Mar 21, 2018
authentication.go Switched example test, because Basic Auth is no longer supported. Mar 25, 2016
cachet.go Fixed workaround added to support specific and general query strings Mar 8, 2018
cachet_example_test.go Fixed tests - temporary disabled tags from components Apr 2, 2018
cachet_test.go Fixed tests (still missing new tests & improved structs by HTTP reque… Feb 10, 2018
component_groups.go Fixed workaround added to support specific and general query strings Mar 8, 2018
component_groups_test.go Added available query string fields in all GetAll functions Feb 23, 2018
components.go Fixed tests - temporary disabled tags from components Apr 2, 2018
components_test.go Added available query string fields in all GetAll functions Feb 23, 2018
doc.go Fixed typo: cached => cachet Nov 7, 2015
general.go Fixed tests (still missing new tests & improved structs by HTTP reque… Feb 10, 2018
general_test.go Added tests and fixed wrong struct in general endpoints Feb 10, 2018
incident_updates.go Fixed tests (still missing new tests & improved structs by HTTP reque… Feb 10, 2018
incident_updates_test.go Updating and adding test functions Feb 6, 2018
incidents.go Fixed workaround added to support specific and general query strings Mar 8, 2018
incidents_test.go Added testing in Schedule and general QueryStrings params Feb 24, 2018
meta.go Fixed tests (still missing new tests & improved structs by HTTP reque… Feb 10, 2018
metrics.go Merged with upstream master Mar 21, 2018
metrics_test.go Fixed tests - temporary disabled tags from components Apr 2, 2018
schedules.go Fixed workaround added to support specific and general query strings Mar 8, 2018
schedules_test.go Added testing in Schedule and general QueryStrings params Feb 24, 2018
subscribers.go Merged with upstream master Mar 21, 2018
subscribers_test.go Fixed errors from merge with upstream repo Mar 22, 2018
subscriptions.go Improved multiple existing functions and added functions to new featu… Feb 5, 2018
subscriptions_test.go Prepared to pull request to origin repo Mar 21, 2018

README.md

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).