aicura
is a client library for Sonatype Nexus Manager v3 API written in GoLang.
The most straightforward way to use this library is creating a new Client
and make calls to the API through services:
import "github.com/m88i/aicura/nexus"
(...)
// New client with default credentials
client := nexus.NewClient("http://localhost:8081").WithCredentials("admin", "admin123").Build()
user, err := client.UserService.GetUserByID("admin")
if err != nil {
return err
}
print(user.Name)
To use this library in your unit tests, create an instance of a "fake" Client
instead:
import "github.com/m88i/aicura/nexus"
(...)
client := nexus.NewFakeClient()
// all interfaces remain the same
user, err := client.UserService.GetUserByID("admin")
if err != nil {
return err
}
print(user.Name) //will print nothing since there's no user in the cache, call client.UserService.Add(user) first :)
The fake Client
is backed up by hash maps, so all write and read operations will work like in real scenarios.
To run a local Nexus Server 3.x container with Podman:
$ podman run --rm -it -p 8081:8081 -e INSTALL4J_ADD_VM_PARAMS="-Dnexus.security.randompassword=false" docker.io/sonatype/nexus3
Use Postman or even the web browser to play around with the Nexus REST API at http://localhost:8081 endpoint. The default credentials are admin
/admin123
.