Commits


Store last Host check result and time Includes tests and simplified unmarshal test.


Simplify service JSON marshalling We don't need to have a MarshalJSON method just so that it can be created ok. It's clearer to do stuff necessart for object creation at the time of object creation, not way earlier in some unrelated bit of the code. While here simplify the tests to actually test what we're worried about.


Use default MarshalJSON method There's no point doing so much manual work and testing just to keep fields under a "attrs" key when marshalling to JSON. When creating the object we can just: 1. Marshal the object to JSON 2. Put it all under a "attrs" key. Now it's easier to imagine the mapping of the structs to JSON, since they follow the same rules as everything else in Go.


Revert "Create a new client interface" This reverts commit bd3b8a33c54037e66233db80fd1120eb0b6215f1. It's a bad idea. I'm writing a fake server instead so that we can use the real client code.


Create a new client interface So that testing the client doesn't involve making real HTTP requests.


Correctly return ErrNoMatch The check was incorrect before. The HTTP status on responses is still 200 OK, but with empty results if there are no matches to the filter.


Support cascading delete of objects


Support Icinga2 hostgroups Tests of hostgroup operations are done in TestFilter


doc: correct doc comment about type


Generate CRUD code using go generate Explanation for use is in the README


Merge Hosts and FilterHosts Getting all Hosts is the same as calling FilterHosts with an empty filter anyway.


Merge get and getFilter methods Doing a GET without a query is the same as doing a GET with an empty query, so there's no point having 2 separate methods.


Merge filter and all objects methods Getting all objects is the same as getting objects with a zero filter.


Deduplicate case conditions Encoding a Host, Service and User as JSON is the same so there's no point having different statements.


I learned how to do some generic programming New type "object" is an interface to represent an Icinga2 object. I added heaps of other stuff! On our way to 1000 lines of code!