Status: It is currently in beta.
This is a Go client library for Mondoo Platform API using GraphQL. Mondoo is a security, risk and compliance platform that provides continuous insight into your infrastructure. This library enables you to interact programmatically with Mondoo Platform to perform various tasks such as querying assets, setup integrations, and fetching vulnerability and policy reports.
- Easy-to-use API to query data from Mondoo
- Strongly typed GraphQL queries and mutations
- Support for GraphQL subscriptions
- Token-based authentication
Our libraries are compatible with at least the three most recent, major Go releases. They are currently compatible with:
- Go 1.21
- Go 1.20
- Go 1.19
In addition, a Mondoo account with API access is required to use this library.
To install the package, run:
go get go.mondoo.com/mondoo-go
Here is a quick example to fetch the details of an asset:
package main
import (
"context"
"fmt"
"log"
"os"
"go.mondoo.com/mondoo-go"
"go.mondoo.com/mondoo-go/option"
)
func main() {
// Initialize the client
client, err := mondoogql.NewClient(option.UseUSRegion(), option.WithAPIToken(os.Getenv("MONDOO_API_TOKEN")))
if err != nil {
log.Fatal(err)
}
// Fetch asset details
assetMrn := "//assets.api.mondoo.app/spaces/dreamy-ellis-859675/assets/2TwUNCJcoPG5vHfUJaMf2gRgIaY"
var q struct {
Report struct {
AssetReport struct {
Asset struct {
Name string
}
} `graphql:"... on AssetReport"`
} `graphql:"assetReport(input: { assetMrn: $assetMrn} )"`
}
variables := map[string]interface{}{
"assetMrn": mondoogql.ID(assetMrn),
}
err = client.Query(context.Background(), &q, variables)
if err != nil {
log.Fatalln(err)
}
fmt.Println(q.Report.AssetReport.Asset.Name)
}
Run all tests:
make test
For any requests, bug or comments, please open an issue or submit a pull request.
When developing new APIs locally, you can overwrite the API endpoint.
Specify MONDOO_API_ENDPOINT
environment variable for the generate
command, e.g.,:
MONDOO_API_ENDPOINT=http://127.0.0.1:8989 make generate
This implementation is heavily inspired by the GitHub GraphQL Go Client.