Tiny library for Prisma Cloud API access.
It takes care of authorization and token renewal, and let you concentrate on issuing requests.
go get github.com/paskal/go-prisma
package main
import (
"log"
"os"
"github.com/jessevdk/go-flags"
"github.com/paskal/go-prisma"
)
func main() {
var opts struct {
PrismAPIUrl string `long:"prisma_api_url" default:"https://api.eu.prismacloud.io" description:"Prisma API URL"`
PrismAPIKey string `long:"prisma_api_key" required:"true" description:"Prisma API key"`
PrismAPIPassword string `long:"prisma_api_password" required:"true" description:"Prisma API password"`
}
if _, err := flags.Parse(&opts); err != nil {
os.Exit(1)
}
log.SetFlags(log.Ldate | log.Ltime)
log.Printf("[INFO] Initialising Prisma connection with API key %s", opts.PrismAPIKey)
p := prisma.NewClient(opts.PrismAPIKey, opts.PrismAPIPassword, opts.PrismAPIUrl)
healthCheckResult, err := p.Call("GET", "/check", nil)
if err != nil {
log.Printf("[ERROR] Can't check Prisma health, %s", err)
return
}
log.Printf("[INFO] Prisma /check endpoint answer: %s", healthCheckResult)
}