Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Environments() ([]Environment, error)
- func (c *Client) FactContents(query string, pagination *Pagination, orderBy *OrderBy) ([]Fact, error)
- func (c *Client) FactNames(pagination *Pagination, orderBy *OrderBy) ([]string, error)
- func (c *Client) FactPaths(query string, pagination *Pagination, orderBy *OrderBy) ([]FactPath, error)
- func (c *Client) Facts(query string, pagination *Pagination, orderBy *OrderBy) ([]Fact, error)
- func (c *Client) Inventory(query string, pagination *Pagination, orderBy *OrderBy) ([]Inventory, error)
- func (c *Client) InventoryMap(query string, pagination *Pagination, orderBy *OrderBy) ([]map[string]interface{}, error)
- func (c *Client) Node(certname string) (*Node, error)
- func (c *Client) Nodes(query string, pagination *Pagination, orderBy *OrderBy) ([]Node, error)
- func (c *Client) PDbStatus() (*PDbStatus, error)
- func (c *Client) PaginatedFacts(query string, pagination *Pagination, orderBy *OrderBy) (*FactsCursor, error)
- func (c *Client) PaginatedNodes(query string, pagination *Pagination, orderBy *OrderBy) (*NodesCursor, error)
- func (c *Client) PaginatedRootQuery(query string, pagination *Pagination, orderBy *OrderBy) (*RootQueryCursor, error)
- func (c *Client) Reports(query string, pagination *Pagination, orderBy *OrderBy) ([]Report, error)
- func (c *Client) SetTransport(tripper http.RoundTripper)
- type Environment
- type Event
- type Fact
- type FactPath
- type FactsCursor
- type Inventory
- type Logs
- type Metrics
- type Node
- type NodesCursor
- type OrderBy
- type PDbStatus
- type Pagination
- type Report
- type ResourceEvents
- type Resources
- type RootQueryCursor
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNonTransientResponse is returned if the downstream puppetdb api // returns an error response that most likely means a retry of the request // will fail. A caller receiving this error should not attempt a retry. ErrNonTransientResponse = errors.New("puppetdb: the api response indicates an error that cannot be recovered from") // ErrTransientResponse is returned if the downstream puppetdb api returns // an error that is transient in nature and a retry of the request is // likely to succeed. An example of these could be a gateway timeout error // or some kind of temporary reverse proxy issue. ErrTransientResponse = errors.New("puppetdb: the api response indicates a recoverable error") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the Orchestrator API
func NewClient ¶
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 ¶
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) Nodes ¶
Nodes will return all nodes matching the given query. Deactivated and expired nodes aren’t included in the response.
func (*Client) PDbStatus ¶
PDbStatus will return the status of the pdb server, specifically the service version.
func (*Client) PaginatedFacts ¶ added in v1.4.0
func (c *Client) PaginatedFacts(query string, pagination *Pagination, orderBy *OrderBy) (*FactsCursor, error)
func (*Client) PaginatedNodes ¶ added in v1.4.0
func (c *Client) PaginatedNodes(query string, pagination *Pagination, orderBy *OrderBy) (*NodesCursor, error)
PaginatedNodes works just like Nodes, but returns a NodesCursor that provides methods for iterating over N pages of nodes and calculates page information for tracking progress. If pagination is nil, then a default configuration with a limit of 100 is used instead.
func (*Client) PaginatedRootQuery ¶ added in v1.5.0
func (c *Client) PaginatedRootQuery(query string, pagination *Pagination, orderBy *OrderBy) (*RootQueryCursor, error)
func (*Client) Reports ¶
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 FactsCursor ¶ added in v1.4.0
type FactsCursor struct {
// contains filtered or unexported fields
}
func (FactsCursor) CurrentPage ¶ added in v1.4.0
func (pc FactsCursor) CurrentPage() int
CurrentPage returns the current page number the cursor is at.
func (FactsCursor) Next ¶ added in v1.4.0
func (fc FactsCursor) Next() ([]Fact, error)
func (FactsCursor) TotalPages ¶ added in v1.4.0
func (pc FactsCursor) TotalPages() int
TotalPages returns the total number of pages that can returns nodes.
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 NodesCursor ¶ added in v1.4.0
type NodesCursor struct {
// contains filtered or unexported fields
}
NodesCursor is a pagination cursor that provides convenience methods for stepping through pages of nodes.
func (NodesCursor) CurrentPage ¶ added in v1.4.0
func (pc NodesCursor) CurrentPage() int
CurrentPage returns the current page number the cursor is at.
func (*NodesCursor) Next ¶ added in v1.4.0
func (nc *NodesCursor) Next() ([]Node, error)
Next returns a page of nodes and iterates the pagination cursor by the offset. If there are no more results left, the error will be io.EOF.
func (NodesCursor) TotalPages ¶ added in v1.4.0
func (pc NodesCursor) TotalPages() int
TotalPages returns the total number of pages that can returns nodes.
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 ¶
Pagination is a filter to be used when paginating
func NewDefaultPagination ¶ added in v1.4.0
func NewDefaultPagination() *Pagination
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 ...
type RootQueryCursor ¶ added in v1.5.0
type RootQueryCursor struct {
// contains filtered or unexported fields
}
func (RootQueryCursor) CurrentPage ¶ added in v1.5.0
func (pc RootQueryCursor) CurrentPage() int
CurrentPage returns the current page number the cursor is at.
func (*RootQueryCursor) NextInto ¶ added in v1.5.0
func (rqc *RootQueryCursor) NextInto(target any) error
func (RootQueryCursor) TotalPages ¶ added in v1.5.0
func (pc RootQueryCursor) TotalPages() int
TotalPages returns the total number of pages that can returns nodes.