puppetdb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for the Orchestrator API

func NewClient

func NewClient(hostURL, token string, tlsConfig *tls.Config, timeout time.Duration) *Client

NewClient access the orchestrator API via TLS. N.B. The timeout is the resty http client timeout so is all encompassing and will incorporate connect, TLS handshake, http/s header receipt and general data transfer. The value used for this in ER is 5 seconds which seems reasonable.

func (*Client) Environments

func (c *Client) Environments() ([]Environment, error)

Environments returns a list of all known environments

func (*Client) FactContents

func (c *Client) FactContents(query string, pagination *Pagination, orderBy *OrderBy) ([]Fact, error)

FactContents will return all facts matching the given query on the fact-contents endpoint. Facts for deactivated nodes are not included in the response. - https://puppet.com/docs/puppetdb/latest/api/query/v4/fact-contents.html

func (*Client) FactNames

func (c *Client) FactNames(pagination *Pagination, orderBy *OrderBy) ([]string, error)

FactNames will return an alphabetical list of all known fact names, including those which are known only for deactivated nodes.

func (*Client) FactPaths

func (c *Client) FactPaths(query string, pagination *Pagination, orderBy *OrderBy) ([]FactPath, error)

FactPaths will return a set of all known fact paths for all known nodes, and is intended as a counterpart to the fact-names endpoint.

func (*Client) Facts

func (c *Client) Facts(query string, pagination *Pagination, orderBy *OrderBy) ([]Fact, error)

Facts will return all facts matching the given query. Facts for deactivated nodes are not included in the response.

func (*Client) Inventory

func (c *Client) Inventory(query string, pagination *Pagination, orderBy *OrderBy) ([]Inventory, error)

Inventory enables an alternative query syntax for digging into structured facts, and can be used instead of the facts, fact-contents, and factsets endpoints for most fact-related queries.

func (*Client) InventoryMap

func (c *Client) InventoryMap(query string, pagination *Pagination, orderBy *OrderBy) ([]map[string]interface{}, error)

InventoryMap an alternative to Inventory which returns an Array of Maps which will allow for fields that do not fit into the Inventory struct, i.e. dot notation fields.

func (*Client) Node

func (c *Client) Node(certname string) (*Node, error)

Node will return a single node by certname

func (*Client) Nodes

func (c *Client) Nodes(query string, pagination *Pagination, orderBy *OrderBy) ([]Node, error)

Nodes will return all nodes matching the given query. Deactivated and expired nodes aren’t included in the response.

func (*Client) PDbStatus

func (c *Client) PDbStatus() (*PDbStatus, error)

PDbStatus will return the status of the pdb server, specifically the service version.

func (*Client) Reports

func (c *Client) Reports(query string, pagination *Pagination, orderBy *OrderBy) ([]Report, error)

Reports retrieve the reports that Puppet agent nodes submit after their runs. The Puppet master forwards these to PuppetDB. Each report includes: Data about the entire run Metadata about the report Many events, describing what happened during the run

func (*Client) SetTransport

func (c *Client) SetTransport(tripper http.RoundTripper)

SetTransport lets the caller overwrite the default transport used by the client. This is useful when injecting mock transports for testing purposes.

type Environment

type Environment struct {
	Name string `json:"name"`
}

Environment represents a PuppetDB environment

type Event

type Event struct {
	Timestamp time.Time   `json:"timestamp"`
	Property  string      `json:"property"`
	Name      string      `json:"name"`
	NewValue  interface{} `json:"new_value"`
	OldValue  interface{} `json:"old_value"`
	Message   string      `json:"message"`
	Status    string      `json:"status"`
}

Event ...

type Fact

type Fact struct {
	Name        string        `json:"name"`
	Value       interface{}   `json:"value"`
	Certname    string        `json:"certname"`
	Environment string        `json:"environment"`
	Count       int           `json:"count"`
	Path        []interface{} `json:"path,omitempty"`
}

Fact represents a fact returned by the Facts or FactContents endpoint. Name (string): the name of the fact. Value (string, numeric, Boolean): the value of the fact. Certname (string): the node associated with the fact. Environment (string): the environment associated with the fact. Path ([]interface{}): an array of the parts that make up the path. (string or int array index)

type FactPath

type FactPath struct {
	Name  string        `json:"name"`
	Path  []interface{} `json:"path"`
	Type  string        `json:"type"`
	Count int           `json:"count"`
}

FactPath represents a fact-path returned by the facts-paths endpoint. Path ([]interface{}): an array of the parts that make up the path. (string or int array index) Type (string): the type of the fact, string, integer etc

type Inventory

type Inventory struct {
	Certname    string                 `json:"certname"`
	Timestamp   string                 `json:"timestamp"`
	Environment string                 `json:"environment"`
	Facts       map[string]interface{} `json:"facts"`
	Trusted     map[string]interface{} `json:"trusted"`
	Count       int                    `json:"count"`
}

Inventory is a PuppetDB node with facts and trusted facts

type Logs

type Logs struct {
	Href string
	Data []struct {
		File    string    `json:"file"`
		Line    int       `json:"line"`
		Level   string    `json:"level"`
		Message string    `json:"message"`
		Source  string    `json:"source"`
		Tags    []string  `json:"tags"`
		Time    time.Time `json:"time"`
	}
}

Logs returns a single log line per data entry. File and line may each be null if the log does not concern a resource.

type Metrics

type Metrics struct {
	Href string
	Data []struct {
		Category string  `json:"category"`
		Name     string  `json:"name"`
		Value    float32 `json:"value"`
	}
}

Metrics ...

type Node

type Node struct {
	Deactivated                  interface{} `json:"deactivated"`
	LatestReportHash             string      `json:"latest_report_hash"`
	FactsEnvironment             string      `json:"facts_environment"`
	CachedCatalogStatus          string      `json:"cached_catalog_status"`
	ReportEnvironment            string      `json:"report_environment"`
	LatestReportCorrectiveChange bool        `json:"latest_report_corrective_change"`
	CatalogEnvironment           string      `json:"catalog_environment"`
	FactsTimestamp               string      `json:"facts_timestamp"`
	LatestReportNoop             bool        `json:"latest_report_noop"`
	Expired                      interface{} `json:"expired"`
	LatestReportNoopPending      bool        `json:"latest_report_noop_pending"`
	ReportTimestamp              string      `json:"report_timestamp"`
	Certname                     string      `json:"certname"`
	CatalogTimestamp             string      `json:"catalog_timestamp"`
	LatestReportJobID            string      `json:"latest_report_job_id"`
	LatestReportStatus           string      `json:"latest_report_status"`
	Count                        int         `json:"count"`
}

Node is a PuppetDB node

type OrderBy

type OrderBy struct {
	Field string
	Order string
}

OrderBy is used to determine a responses ordering

type PDbStatus

type PDbStatus struct {
	ServiceVersion string `json:"service_version,omitempty"`
}

PDbStatus represents the puppet db status returned from the endpoint. ServiceVersion (string): the service version of the pe server the endpoint calls out to

type Pagination

type Pagination struct {
	Limit        int
	Offset       int
	IncludeTotal bool
	Total        int
}

Pagination is a filter to be used when paginating

type Report

type Report struct {
	Hash                 string         `json:"hash"`
	PuppetVersion        string         `json:"puppet_version"`
	ReceiveTime          time.Time      `json:"receive_time"`
	ReportFormat         int            `json:"report_format"`
	StartTime            time.Time      `json:"start_time"`
	EndTime              time.Time      `json:"end_time"`
	ProducerTimestamp    time.Time      `json:"producer_timestamp"`
	Producer             string         `json:"producer"`
	TransactionUUID      string         `json:"transaction_uuid"`
	Status               string         `json:"status"`
	Noop                 bool           `json:"noop"`
	NoopPending          bool           `json:"noop_pending"`
	Environment          string         `json:"environment"`
	ConfigurationVersion string         `json:"configuration_version"`
	Certname             string         `json:"certname"`
	CodeID               string         `json:"code_id"`
	CatalogUUID          string         `json:"catalog_uuid"`
	CachedCatalogStatus  string         `json:"cached_catalog_status"`
	ResourceEvents       ResourceEvents `json:"resource_events"`
	Resources            Resources      `json:"resources"`
	Metrics              Metrics        `json:"metrics"`
	Logs                 Logs           `json:"logs"`
	Count                int            `json:"count"`
	CorrectiveChange     bool           `json:"corrective_change"`
}

Report summaries for all event reports that matched the input parameters.

type ResourceEvents

type ResourceEvents struct {
	Href string
	Data []struct {
		Status          string      `json:"status"`
		Timestamp       time.Time   `json:"timestamp"`
		ResourceType    string      `json:"resource_type"`
		ResourceTitle   string      `json:"resource_title"`
		Property        string      `json:"property"`
		Name            string      `json:"name"`
		NewValue        interface{} `json:"new_value"`
		OldValue        interface{} `json:"old_value"`
		Message         string      `json:"message"`
		File            string      `json:"file"`
		Line            int         `json:"line"`
		ContainmentPath []string    `json:"containment_path"`
	}
}

ResourceEvents ...

type Resources

type Resources struct {
	Href string
	Data []struct {
		Timestamp       time.Time `json:"timestamp"`
		ResourceType    string    `json:"resource_type"`
		ResourceTitle   string    `json:"resource_title"`
		ContainmentPath []string  `json:"containment_path"`
		Skipped         bool      `json:"skipped"`
		Events          []Event   `json:"events"`
	}
}

Resources ...

Jump to

Keyboard shortcuts

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