Skip to content

paskal/go-prisma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Palo Alto Prisma Cloud library Build Status Go Report CardCoverage StatusGoDoc

Tiny library for Prisma Cloud API access.

It takes care of authorization and token renewal, and let you concentrate on issuing requests.

How to install

go get github.com/paskal/go-prisma

Usage example

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)
}