Blob


1 package icinga
3 import (
4 "fmt"
5 "net/http"
6 )
8 type Client struct {
9 host string
10 username string
11 password string
12 *http.Client
13 }
15 func Dial(host, username, password string, client *http.Client) (*Client, error) {
16 c := &Client{host, username, password, client}
17 if _, err := c.Status(); err != nil {
18 return nil, err
19 }
20 return c, nil
21 }
23 func (c *Client) Status() (*http.Response, error) {
24 resp, err := c.get("/status")
25 if err != nil {
26 return nil, err
27 }
28 if resp.StatusCode != http.StatusOK {
29 return resp, fmt.Errorf("status %s", resp.Status)
30 }
31 return resp, nil
32 }