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
- Variables
- type AuthCustomer
- type AuthResponse
- type Client
- type PrismaCloudClient
- type PrismaCloudError
- func (e PrismaCloudError) AccountGroupNotFoundError() bool
- func (e PrismaCloudError) AlreadyExists() bool
- func (e PrismaCloudError) CollectionNotFoundError() bool
- func (e PrismaCloudError) Error() string
- func (e PrismaCloudError) InternalError() bool
- func (e PrismaCloudError) InvalidPermissionGroupIdError() bool
- func (e PrismaCloudError) ObjectNotFound() bool
- func (e PrismaCloudError) OverlappingCIDRError() bool
- func (e PrismaCloudError) ResourceListNotFoundError() bool
- type PrismaCloudErrorList
Constants ¶
const ( LogQuiet = "quiet" LogAction = "action" LogPath = "path" LogSend = "send" LogReceive = "receive" )
Control what is echoed to the user.
Variables ¶
var AccountGroupNotFoundError = errors.New("account_group_not_found") //account_group_not_found
var AlreadyExistsError = errors.New("object already exists")
var CollectionNotFoundError = errors.New("invalid_collection_id") //collection
var InternalError = errors.New("internal_error") //compliance standard requirement
var InvalidCredentialsError = errors.New("invalid credentials")
var InvalidPermissionGroupIdError = errors.New("invalid_permission_group_id") //permission group
var ObjectNotFoundError = errors.New("object not found")
var OverlappingCIDRError = errors.New("overlapping_cidr")
var ResourceListNotFoundError = errors.New("non_existing_resource_list_id") //resource list
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 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 sync.Map `json:"retries"` RetryType string `json:"retry_type"` // 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 ¶
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 ¶
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.
type PrismaCloudClient ¶
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