• Stars
    star
    90
  • Rank 369,088 (Top 8 %)
  • Language
    Go
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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("[email protected]", "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("[email protected]", "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).

More Repositories

1

go-jira

Go client library for Atlassian Jira
Go
1,429
star
2

FOM-LaTeX-Template

A LaTeX template for term paper, bachelor or master thesis for "FOM University of Applied Sciences"
TeX
175
star
3

go-trending

Go library for accessing trending repositories and developers at Github.
Go
137
star
4

TrendingGithub

A twitter bot (@TrendingGithub) to tweet trending repositories and developers from GitHub
Go
112
star
5

go-gerrit

Go(lang) client/library for Gerrit Code Review
Go
93
star
6

DigitalKanban

A small digital Kanban board based on Symfony2. This application was developed during a small university project.
PHP
55
star
7

megos

Go(lang) client library for accessing information of an Apache Mesos cluster.
Go
54
star
8

jitic

The JIRA Ticket Checker - Checks the existence of one or more ticket in the JIRA issue tracker
Go
33
star
9

vdf

A Lexer and Parser for Valves Data Format (known as vdf) written in Go
Go
30
star
10

your-connection-deserves-a-name

Examples and code to assign a name to your MongoDB, MySQL, NATS, Oracle, PostgreSQL, RabbitMQ, and redis connection.
Go
26
star
11

things-with-buzzers-jeopardy

A Jeopardy! game frontend for things with buzzers with support for three buzzers πŸš€
JavaScript
24
star
12

simple-webserver

A small webserver for testing various technologies, techniques and concepts written in Go.
Go
23
star
13

things-with-buzzers-hardware

Everything you need to build hardware game show buzzers (and to do awesome things with it!) πŸš€
Python
12
star
14

Jacobine

A framework to analyze your software development cycle and the community around your software product to discover hidden information.
PHP
11
star
15

gotrap

A Gerrit <=> Github <=> TravisCI bridge written in Go
Go
11
star
16

Gerrie

A crawler for Googles code review system "Gerrit"
PHP
9
star
17

things-with-buzzers-websocket

A WebSocket server to publish messages when someone pushed a hardware game show buzzer πŸš€
Go
7
star
18

perseus

Local git mirror for your PHP (composer) project dependencies that works together with Satis.
Go
4
star
19

sico

A Sitemap Comparison that helps you to not fuck up your website migration.
Go
4
star
20

watson

A crawler for Googles code review system "Gerrit"
Go
4
star
21

go-incident

Go client library for accessing the Incident.io API
Go
4
star
22

Jacobine-Vagrant

Vagrant setup for a project to analyze different data sources of various open source projects (source code, ecosystem, community) to detect new information about your community and your contribution. See Jacobine.
Python
2
star
23

Jacobine-Web-Frontend

Website for a project to analyze different data sources of the open source project TYPO3. See TYPO3-Analytics
PHP
1
star
24

Vagrant-MetricsGrimoire

Vagrant setup to play with the MetricsGrimoire toolset
Python
1
star
25

dotfiles

My .files
Shell
1
star