commit 7aa5b0553214edbb1a6e71187215972e1e4877c6 from: Oliver Lowe date: Thu Jan 13 00:41:43 2022 UTC doc: Keep the getting started tutorial in 1 place commit - 2ad5e459c8480946f8762ea1617512d6bfd489bf commit + 7aa5b0553214edbb1a6e71187215972e1e4877c6 blob - 822b9d7fb5f1d5d5b0e799e3ff6f401e026582bc blob + 08c3bb298903b6e7ed660a9dd370003d345bbc95 --- README.md +++ README.md @@ -5,50 +5,10 @@ package icinga provides a client to the Icinga2 HTTP A Send patches, questions or a friendly "hello" to the mailing list: [~otl/icinga@lists.sr.ht](mailto:~otl/icinga@lists.sr.ht) 🙂 Or, read [the archives][list]. -[list]: https://lists.sr.ht/~otl/icinga - ## Quick Start -A Client manages interaction with an Icinga2 server. -It is created using Dial. Provide the address, in `host:port` form, API username and password, and a `http.Client`: +See the [package overview godoc][godocs] for getting started examples. - client, err := icinga.Dial("icinga.example.com:5665", "icinga", "secret", http.DefaultClient) - if err != nil { - // handle error - } - -Icinga2 servers in the wild often serve self-signed certificates which -fail verification by Go's tls client. To ignore the errors, Dial the server -with a modified `http.Client`: - - t := http.DefaultTransport.(*http.Transport) - t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - c := http.DefaultClient - c.Transport = t - client, err := icinga.Dial(addr, user, pass, c) - if err != nil { - // handle error - } - -Methods on `Client` provide API actions like looking up users and creating hosts: - - user, err := client.LookupUser("oliver") - if err != nil { - // handle error - } - host := Host{ - Name: "myserver.example.com", - CheckCommand: "hostalive" - Address: "192.0.2.1" - Address6: "2001:db8::1" - } - if err := client.CreateHost(host); err != nil { - // handle error - } - -Not all functionality of the Icinga2 API is implemented. -For more detail, see the [godocs][godocs]. - [godocs]: https://godocs.io/olowe.co/icinga ## Development @@ -65,8 +25,11 @@ Please send any patches to the [mailing list](https:// git send-email --to="~otl/icinga@lists.sr.ht" HEAD^ -Thanks! +For those unfamiliar with this workflow, see [git-send-email.io][sendemail]. +[list]: https://lists.sr.ht/~otl/icinga +[sendemail]: https://git-send-email.io + ### Tests Some tests dial an instance of Icinga2 running on the loopback address blob - 3e46109beb4e68f5866bb6e6edfe76e495207a58 blob + abf172361df21abb4d49a34ecdc7152bed0c610c --- icinga.go +++ icinga.go @@ -7,11 +7,37 @@ // if err != nil { // // handle error // } -// host, err := client.LookupHost("myserver.example.com") +// +// Icinga2 servers in the wild often serve self-signed certificates which fail +// verification by Go's tls client. To ignore the errors, Dial the server with a +// modified http.Client: +// +// t := http.DefaultTransport.(*http.Transport) +// t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} +// c := http.DefaultClient +// c.Transport = t +// client, err := icinga.Dial(addr, user, pass, c) // if err != nil { // // handle error // } // +// Methods on Client provide API actions like looking up users and creating +// hosts: +// +// user, err := client.LookupUser("oliver") +// if err != nil { +// // handle error +// } +// host := Host{ +// Name: "myserver.example.com", +// CheckCommand: "hostalive" +// Address: "192.0.2.1" +// Address6: "2001:db8::1" +// } +// if err := client.CreateHost(host); err != nil { +// // handle error +// } +// // Since Client wraps http.Client, exported methods of http.Client such // as Get and PostForm can be used to implement any extra functionality // not provided by this package. For example: @@ -30,7 +56,7 @@ import ( // A Client represents a client connection to the Icinga2 HTTP API. // It should be created using Dial. -// Since Client wraps http.Client, standard methods such as Get and +// Since Client wraps http.Client, exported methods such as Get and // PostForm can be used to implement any functionality not provided by // methods of Client. type Client struct {