prismacloud

package module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2024 License: MPL-2.0 Imports: 13 Imported by: 1

README

prisma-cloud-go

GoDoc Build

Prisma Cloud SDK in Go

Documentation

Overview

Package prismacloud is an SDK meant to assist in interacting with the Palo Alto Networks Prisma Cloud API.

To connect, create a client connetion with the desired params and then initialize the connection:

package main

import (
    "log"
    "github.com/paloaltonetworks/prisma-cloud-go"
    "github.com/paloaltonetworks/prisma-cloud-go/compliance/standard"
)

func main() {
    client := &prismacloud.Client{}
    if err := c.Initialize("creds.json"); err != nil {
        log.Fatalf("Failed to connect: %s", err)
    }

    listing, err := standard.List(client)
    if err != nil {
        log.Fatalf("Failed to get compliance standards: %s", err)
    }

    log.Printf("Compliance standards:")
    for _, elm := range listing {
        log.Printf("* (%s) %s", elm.Id, elm.Name)
    }
}

In most cases the struct and types match what the Prisma Cloud API specifies, so you may find it useful to refer to the Prisma Cloud API for further information: https://api.docs.prismacloud.io/reference

Index

Constants

View Source
const (
	LogQuiet   = "quiet"
	LogAction  = "action"
	LogPath    = "path"
	LogSend    = "send"
	LogReceive = "receive"
)

Control what is echoed to the user.

Variables

View Source
var AccountGroupNotFoundError = errors.New("account_group_not_found") //account_group_not_found
View Source
var AlreadyExistsError = errors.New("object already exists")
View Source
var CollectionNotFoundError = errors.New("invalid_collection_id") //collection
View Source
var InternalError = errors.New("internal_error") //compliance standard requirement
View Source
var InvalidCredentialsError = errors.New("invalid credentials")
View Source
var InvalidPermissionGroupIdError = errors.New("invalid_permission_group_id") //permission group
View Source
var ObjectNotFoundError = errors.New("object not found")
View Source
var OverlappingCIDRError = errors.New("overlapping_cidr")
View Source
var ResourceListNotFoundError = errors.New("non_existing_resource_list_id") //resource list
View Source
var SensitiveKeys = []string{"password", "private_key", "external_id"}

These are the hidden fields blanked out during send and receive logging.

Functions

This section is empty.

Types

type AuthCustomer

type AuthCustomer struct {
	Name        string `json:"customerName"`
	TosAccepted bool   `json:"tosAccepted"`
}

type AuthResponse

type AuthResponse struct {
	Token     string         `json:"token"`
	Message   string         `json:"message"`
	Customers []AuthCustomer `json:"customerNames"`
}

type Client

type Client struct {
	// Properties.
	Url                     string          `json:"url"`
	Username                string          `json:"username"`
	Password                string          `json:"password"`
	CustomerName            string          `json:"customer_name"`
	Protocol                string          `json:"protocol"`
	Port                    int             `json:"port"`
	Timeout                 int             `json:"timeout"`
	SkipSslCertVerification bool            `json:"skip_ssl_cert_verification"`
	Logging                 map[string]bool `json:"logging"`
	DisableReconnect        bool            `json:"disable_reconnect"`
	MaxRetries              int             `json:"max_retries"`
	RetryMaxDelay           int             `json:"retry_max_delay"`
	Retries                 int             `json:"retries"`

	// Advanced user config.
	Transport *http.Transport `json:"-"`

	// Set at runtime.
	JsonWebToken string `json:"json_web_token"`
	// contains filtered or unexported fields
}

Client is a client connection to Prisma Cloud.

func (*Client) Authenticate

func (c *Client) Authenticate() error

Authenticate retrieves and saves a JSON web token from Prisma Cloud.

func (*Client) Communicate

func (c *Client) Communicate(method string, suffix []string, query, data interface{}, ans interface{}) ([]byte, error)

Communicate handles basic communication with Prisma Cloud.

If a non-nil interface is given as the "ans" variable, then this function will unmarshal the returned JSON into it, and you can safely discard the slice of bytes returned.

func (*Client) Initialize

func (c *Client) Initialize(filename string) error

Initialize prepares the client connection and attempts a login.

This function can be passed a credentials file to read in settings that will act as defaults if the given variables are currently unset.

func (*Client) Log

func (c *Client) Log(flag, msg string, i ...interface{})

Log logs a message to the user if the appropriate style is enabled.

type PrismaCloudClient

type PrismaCloudClient interface {
	Initialize(string) error
	Authenticate() error
	Communicate(string, []string, interface{}, interface{}, interface{}) ([]byte, error)
	Log(string, string, ...interface{})
}

type PrismaCloudError

type PrismaCloudError struct {
	Message  string `json:"i18nKey"`
	Severity string `json:"severity"`
	Subject  string `json:"subject"`
}

func (PrismaCloudError) AccountGroupNotFoundError added in v0.6.1

func (e PrismaCloudError) AccountGroupNotFoundError() bool

func (PrismaCloudError) AlreadyExists

func (e PrismaCloudError) AlreadyExists() bool

func (PrismaCloudError) CollectionNotFoundError added in v0.7.8

func (e PrismaCloudError) CollectionNotFoundError() bool

func (PrismaCloudError) Error

func (e PrismaCloudError) Error() string

func (PrismaCloudError) InternalError added in v0.6.1

func (e PrismaCloudError) InternalError() bool

func (PrismaCloudError) InvalidPermissionGroupIdError added in v0.6.1

func (e PrismaCloudError) InvalidPermissionGroupIdError() bool

func (PrismaCloudError) ObjectNotFound

func (e PrismaCloudError) ObjectNotFound() bool

func (PrismaCloudError) OverlappingCIDRError added in v0.6.5

func (e PrismaCloudError) OverlappingCIDRError() bool

func (PrismaCloudError) ResourceListNotFoundError added in v0.7.5

func (e PrismaCloudError) ResourceListNotFoundError() bool

type PrismaCloudErrorList

type PrismaCloudErrorList struct {
	Errors     []PrismaCloudError
	Method     string
	StatusCode int
	Path       string
}

func (PrismaCloudErrorList) Error

func (e PrismaCloudErrorList) Error() string

func (PrismaCloudErrorList) GenericError

func (e PrismaCloudErrorList) GenericError() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL