Giter Site home page Giter Site logo

go-pingdom's Introduction

pingdom-go

pingdom-go is a Go client library for the Pingdom API.

This currently supports working with basic HTTP (with specific details) and ping checks. It can also manage contacts who will be alerted in case of downtime.

Build Status: Build Status

Godoc: https://godoc.org/github.com/russellcardullo/go-pingdom/pingdom

Usage

Client

Pingdom handles single-user and multi-user accounts differently.

Construct a new single-user Pingdom client:

client := pingdom.NewClient("pingdom_username", "pingdom_password", "pingdom_api_key")

Construct a multi-user Pingdom client:

client := pingdom.NewMultiUserClient("pingdom_username", "pingdom_password", "pingdom_api_key", "pingdom_account_email")

The pingdom_account_email variable is the email address of the owner of the multi-user account. This is passed in the Account-Email header to the Pingdom API.

Using a Pingdom client, you can access supported services.

CheckService

This service manages pingdom Checks which are represented by the Check struct. When creating or updating Checks you must specify at a minimum the Name, Hostname and Resolution. Other fields are optional but if not set will be given the zero values for the underlying type.

More information on Checks from Pingdom: https://www.pingdom.com/features/api/documentation/#ResourceChecks

Get a list of all checks:

checks, err := client.Checks.List()
fmt.Println("Checks:", checks) // [{ID Name} ...]

Create a new HTTP check:

newCheck := pingdom.HttpCheck{BaseCheck: pingdom.BaseCheck{Name: "Test Check", Hostname: "example.com", Resolution: pingdom.OptInt(5}}}
check, err := client.Checks.Create(&newCheck)
fmt.Println("Created check:", check) // {ID, Name}

Create a new Ping check:

newCheck := pingdom.PingCheck{BaseCheck: pingdom.BaseCheck{Name: "Test Check", Hostname: "example.com", Resolution: pingdom.OptInt(5)}}
check, err := client.Checks.Create(&newCheck)
fmt.Println("Created check:", check) // {ID, Name}

Get details for a specific check:

checkDetails, err := client.Checks.Read(12345)

For checks with detailed information, check the specific details in the field Type (e.g. checkDetails.Type.HTTP).

Update a check:

updatedCheck := pingdom.HttpCheck{BaseCheck: pingdom.BaseCheck{Name: "Updated Check", Hostname: "example2.com", Resolution: pingdom.OptInt(5)}}
msg, err := client.Checks.Update(12345, &updatedCheck)

Delete a check:

msg, err := client.Checks.Delete(12345)

Create a notification contact:

newContact := pingdom.Contact{ Name: "John Doe", Email: "[email protected]", Defaultsmsprovider: "nexmo" }
contactResponse, err := client.Contacts.Create(&newContact)

go-pingdom's People

Contributors

fordodone avatar henrytk avatar jbrandstetter avatar keymon avatar radeksimko avatar russellcardullo avatar saliceti avatar shaunthium avatar svc-scm avatar xh3b4sd avatar ypaq avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.