Snapd has a great REST API to monitor and configure a device. Currently, this is only available as HTTP over a unix socket. For many languages HTTP over unix sockets is built-in, so it’s fairly straightforward. I was asked to create an example of calling the API from Java… and it turns out that it’s not that straightforward.
I couldn’t find any examples of using HTTP over unix sockets, so I’ve created an example using the jnr-unixsocket
package, that adds a unix Protocol
class to a HTTP client:
The example code just has the system-info
call implemented, but it may be a useful start point if you are writing something more serious in Java.