This project implements a Go client library for the Hipchat API.

Hipchat

This project implements a Go client library for the Hipchat API (API version 2 is not supported).

Pull requests are welcome as the API is limited to only a few calls right now.

API documentation can be found on godoc.org.

Star this or get at me on the Twitters if you end up using this since this is pretty early stage and I may make breaking changes to the API. – @andybons

Installing

Run

go get github.com/andybons/hipchat

Example usage:

package main

import (
	"github.com/andybons/hipchat"
	"log"
)

func main() {
	c := hipchat.NewClient("<PUT YOUR AUTH TOKEN HERE>")
	req := hipchat.MessageRequest{
		RoomId:        "Rat Man's Den",
		From:          "GLaDOS",
		Message:       "Bad news: Combustible lemons failed.",
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}

	if err := c.PostMessage(req); err != nil {
		log.Printf("Expected no error, but got %q", err)
	}
}

Setting a custom HipChat Server:

c := hipchat.NewClient("<AUTH TOKEN>")
c.BaseURL = "https://your.host.name/v1"
...

Use customized proxy settings In case you need to use transport other than http.DefaultTransport:

c := hipchat.NewClient("<AUTH TOKEN>")

proxyURL, err := url.Parse("<PROXY_URL:PROXY_PORT>")
if err != nil {
	log.Fatalf("Expected no error, but got %q", err)
}
c.Transport = &http.Transport{Proxy: http.ProxyURL(proxyURL)}

Contributors

Owner
Comments
  • Change Client to take base URL as argument, add tests

    Change Client to take base URL as argument, add tests

    Change how callers construct Clients to make testing easier. Then add tests for:

    • [x] Posting
    • [x] Fetching room history
    • [x] Listing rooms

    This addresses part of (1) in andybons/hipchat#1. Since we're adding tests anyways, I also added a Travis config file and badge.

  • Version 2.0: export interface and add tests

    Version 2.0: export interface and add tests

    This is the re-worked, leaner, meaner version of #2. It makes a few breaking changes, so it's tucked away in /v2/. Changes:

    1. Client constructor takes a Config struct. This allows callers to specify just an auth token, but lets us alter the base URL in the test code.
    2. Client constructor returns an interface, not a concrete type. This enables the next item.
    3. Add a Mock that satisfies the Client interface. Callers can use the mock in their own test code.
    4. Add tests for all methods on the real client and the mock. Per the built-in coverage tools, test coverage is a little over 93%.
    5. Move the example into the test code, so it's compiler-verified and integrated into the docs.
  • Improve error handling

    Improve error handling

    • Return optionally structured errors with more information.
    if hcErr, ok := err.(hipchat.Error); ok {
        log.Printf("[%d] %q", hcErr.Code, hcErr.Message)
    }
    
    • Actually return the error if a message wasn't posted.

    This removes the human friendly error message being reported by https://github.com/andybons/hipchat/issues/8 and returns a standard Hipchat.Error instead.

  • x509: certificate signed by unknown authority

    x509: certificate signed by unknown authority

    I got this error when running your script from Debian 7 :

    go run hipchat.go 
    2015/10/22 09:22:41 Expected no error, but got "x509: certificate signed by unknown authority"
    

    Script :

    package main
    
    import (
        "github.com/andybons/hipchat"
        "log"
    )
    
    func main() {
        c := hipchat.NewClient("xxxx")
        req := hipchat.MessageRequest{
            RoomId:        "xxxx",
            From:          "GoLang",
            Message:       "Bad news: Combustible lemons failed.",
            Color:         hipchat.ColorPurple,
            MessageFormat: hipchat.FormatText,
            Notify:        true,
        }
    
        if err := c.PostMessage(req); err != nil {
            log.Printf("Expected no error, but got %q", err)
        }
    }
    
  • PostMessage: response 'status' field was not 'sent'.

    PostMessage: response 'status' field was not 'sent'.

    I keep getting the following when sending a message using the example:

    2014/11/17 10:47:38 Expected no error, but got "PostMessage: response 'status' field was not 'sent'."
    

    My example is as follows

    package main
    
    import (
        "github.com/andybons/hipchat"
        "log"
    )
    
    func main() {
        c := hipchat.Client{AuthToken: "xxxxxx"}
        req := hipchat.MessageRequest{
            RoomId:        "VCS Source",
            From:          "Aspect",
            Message:       "Bad news: Combustible lemons failed.",
            Color:         hipchat.ColorPurple,
            MessageFormat: hipchat.FormatText,
            Notify:        true,
        }
    
        if err := c.PostMessage(req); err != nil {
            log.Printf("Expected no error, but got %q", err)
        }
    }
    

    I have also tried an admin token, a room token, and a neither work

  • JIRA + GAE

    JIRA + GAE

    Hi Andy, let me know if you're interested in these changes. Keep in mind that this breaks the the PostMessage function. func (c *Client) PostMessage(m MessageRequest, h http.Client) error

    I'm flexible on a lot of this.

  • Open to a refactoring to support unit tests and a polling client?

    Open to a refactoring to support unit tests and a polling client?

    Hey @andybons,

    Thanks for this library! I'm using it for some internal tools, and it's been great. Two questions:

    1. Are you open to a refactoring to make testing easier? I'd like to add both tests for this code and a mock Client implementation that callers can use in their tests.
    2. I've written a polling client (runs in its own goroutine, polls for messages and pushes them onto a channel). I find it convenient - are you open to integrating it into this library as a second client type?
  • Add Custom Proxy settings for specialize environment

    Add Custom Proxy settings for specialize environment

    When hipchat-go client runs inside Private DC and need proxy settings to connect internet or particular development environment this settings are necessary

  • Add AuthTest support for messages

    Add AuthTest support for messages

    This will allow rooms/message API calls to use the 'auth_test' flag described here: https://www.hipchat.com/docs/api/auth

    The response type is different than a normal request. Catch the 'success' vs 'error' response and return the error if present (nil if successfully authenticated).

  • Can now set a Url endpoint different than base

    Can now set a Url endpoint different than base

    Added a feature that allows you to specify a different endpoint Url when creating a Client struct. The code will use it if it is not blank. If it is the code defaults to the baseUrl.

  • Add MIT license

    Add MIT license

    In the middle of working on the v2 code we discussed, I realized that this project isn't open-source. Mind adding a license?

    This PR adds the MIT license, but feel free to add whichever you'd like (or keep the code closed).

Clusterpedia-client - clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Jan 7, 2022
Client-go - Clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Dec 5, 2022
Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Mar 19, 2022
Godaddy - This package implements the libdns interfaces for the Godaddy API

Godaddy for libdns This package implements the libdns interfaces for the Godaddy

Nov 8, 2022
GoStorm is a Go library that implements the communications protocol required to write Storm spouts and Bolts in Go that communicate with the Storm shells.

gostorm godocs GoStorm is a Go library that implements the communications protocol required for non-Java languages to communicate as part of a storm t

Sep 27, 2022
This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event.

observer This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event. Usage go get githu

Nov 16, 2022
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Kinesumer is a Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Jan 5, 2023
Nutanix-client-go - Go client for the Nutanix Prism V3 API

nutanix-client-go This repository contains portions of the Nutanix API client code in nutanix/terraform-provider-nutanix. It has been extracted to red

Jan 6, 2022
Aoe4-client - Client library for aoe4 leaderboards etc

AOE4 Client Overview This is a go client used to query AOE4 data from either the

Jan 18, 2022
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Oct 6, 2022
An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Dec 30, 2022
A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

Nov 5, 2021
Go Client Library for Amazon Product Advertising API

go-amazon-product-advertising-api Go Client Library for Amazon Product Advertising API How to Use go get -u github.com/ngs/go-amazon-product-advertisi

Sep 27, 2022
A Go client library for the Twitter 1.1 API

Anaconda Anaconda is a simple, transparent Go package for accessing version 1.1 of the Twitter API. Successful API queries return native Go structs th

Jan 1, 2023
Go client library for interacting with Coinpaprika's API

Coinpaprika API Go Client Usage This library provides convenient way to use coinpaprika.com API in Go. Coinpaprika delivers full market data to the wo

Dec 8, 2022
Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://developer.github.com/v4/).

githubv4 Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). If you're looking for a client

Dec 26, 2022
Client library for UptimeRobot v2 API

uptimerobot uptimerobot is a Go library and command-line client for the Uptime Robot website monitoring service. It allows you to search for existing

Jan 8, 2023
May 25, 2021
NotionGo is a Go client library for accessing the Notion API v1.

NotionGo (WIP) NotionGo is a Go client library for accessing the Notion API v1. Installation NotionGo is compatible with modern Go releases in module

May 22, 2021