Documentation
¶
Index ¶
- func ProcessError(r *resty.Response, err error, errorString string) error
- type Client
- func (c *Client) CommandDeploy(deployRequest *DeployRequest) (*JobID, error)
- func (c *Client) CommandPlanRun(planRunRequest *PlanRunRequest) (*PlanRunJobID, error)
- func (c *Client) CommandScheduleTask(scheduleTaskRequest *ScheduleTaskRequest) (*ScheduledJobID, error)
- func (c *Client) CommandStop(stopRequest *StopRequest) (*StopJobID, error)
- func (c *Client) CommandTask(taskRequest *TaskRequest) (*JobID, error)
- func (c *Client) CommandTaskTarget(taskTargetRequest *TaskTargetRequest) (*TaskTargetJobID, error)
- func (c *Client) Inventory() ([]InventoryNode, error)
- func (c *Client) InventoryCheck(nodes []string) ([]InventoryNode, error)
- func (c *Client) InventoryNode(node string) (*InventoryNode, error)
- func (c *Client) Job(jobID string) (*Job, error)
- func (c *Client) JobNodes(jobID string) (*JobNodes, error)
- func (c *Client) JobReport(jobID string) (*JobReport, error)
- func (c *Client) Jobs() (*Jobs, error)
- func (c *Client) Plan(environment, module, planname string) (*Plan, error)
- func (c *Client) PlanByID(environment, planID string) (*Plan, error)
- func (c *Client) Plans(environment string) (*Plans, error)
- func (c *Client) Task(environment, module, taskname string) (*Task, error)
- func (c *Client) TaskByID(environment, taskID string) (*Task, error)
- func (c *Client) Tasks(environment string) (*Tasks, error)
- type DeployRequest
- type Environment
- type Events
- type HTTPError
- type Interval
- type InventoryNode
- type Job
- type JobEvent
- type JobID
- type JobNode
- type JobNodes
- type JobReport
- type Jobs
- type NextEvents
- type NodeStates
- type Nodes
- type OrchestratorError
- type Owner
- type Pagination
- type Plan
- type PlanRunJobID
- type PlanRunRequest
- type Plans
- type Report
- type ScheduleOptions
- type ScheduleTaskRequest
- type ScheduledJobID
- type Scope
- type Status
- type StopJobID
- type StopRequest
- type Task
- type TaskFile
- type TaskImplementation
- type TaskMetadata
- type TaskParam
- type TaskRequest
- type TaskTargetJobID
- type TaskTargetRequest
- type Tasks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessError ¶
ProcessError will process the response for RESTY and thow an error accordingly
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the Orchestrator API
func (*Client) CommandDeploy ¶
func (c *Client) CommandDeploy(deployRequest *DeployRequest) (*JobID, error)
CommandDeploy runs the orchestrator across all nodes in an environment (POST /command/deploy)
func (*Client) CommandPlanRun ¶
func (c *Client) CommandPlanRun(planRunRequest *PlanRunRequest) (*PlanRunJobID, error)
CommandPlanRun runs a plan via the plan executor (POST /command/plan_run)
func (*Client) CommandScheduleTask ¶
func (c *Client) CommandScheduleTask(scheduleTaskRequest *ScheduleTaskRequest) (*ScheduledJobID, error)
CommandScheduleTask schedules a task to run at a future date and time (POST /command/schedule_task)
func (*Client) CommandStop ¶
func (c *Client) CommandStop(stopRequest *StopRequest) (*StopJobID, error)
CommandStop stops a orchestrator job that is currently in progress (POST /command/stop)
func (*Client) CommandTask ¶
func (c *Client) CommandTask(taskRequest *TaskRequest) (*JobID, error)
CommandTask runs a permitted task job across a set of nodes (POST /command/task)
func (*Client) CommandTaskTarget ¶
func (c *Client) CommandTaskTarget(taskTargetRequest *TaskTargetRequest) (*TaskTargetJobID, error)
CommandTaskTarget creates a new task-target (POST /command/task_target)
func (*Client) Inventory ¶
func (c *Client) Inventory() ([]InventoryNode, error)
Inventory lists all nodes that are connected to the PCP broker (GET /inventory)
func (*Client) InventoryCheck ¶
func (c *Client) InventoryCheck(nodes []string) ([]InventoryNode, error)
InventoryCheck checks if the given list of nodes is connected to the PCP broker (POST /inventory)
func (*Client) InventoryNode ¶
func (c *Client) InventoryNode(node string) (*InventoryNode, error)
InventoryNode returns information about whether the requested node is connected to the PCP broker (GET /inventory/:node)
func (*Client) JobNodes ¶
JobNodes lists all of the nodes associated with a given job (GET /jobs/:job-id/nodes)
func (*Client) Plan ¶
Plan returns data about the specified plan, including metadata (GET /plans/:module/:planname)
func (*Client) PlanByID ¶
PlanByID extracts the module and planname from the supplied ID and calls Plan(...)
func (*Client) Task ¶
Task returns data about a specified task, including metadata and file information. For the default task in a module, taskname is init. (GET /tasks/:module/:taskname)
type DeployRequest ¶
type DeployRequest struct { Environment string `json:"environment"` Scope Scope `json:"scope,omitempty"` Description string `json:"description,omitempty"` Noop bool `json:"noop,omitempty"` NoNoop bool `json:"no_noop,omitempty"` Concurrency int `json:"concurrency,omitempty"` EnforceEnvironment bool `json:"enforce_environment"` Debug bool `json:"debug,omitempty"` Trace bool `json:"trace,omitempty"` Evaltrace bool `json:"evaltrace,omitempty"` Target string `json:"target,omitempty"` }
DeployRequest describes a deploy request
type Environment ¶
type Environment struct {
Name string `json:"name"`
}
Environment in the current job
type HTTPError ¶
HTTPError represents an error with the HTTP response code
func (*HTTPError) GetStatusCode ¶
GetStatusCode will return the HTTP status code.
type InventoryNode ¶
type InventoryNode struct { Name string `json:"name,omitempty"` Connected bool `json:"connected,omitempty"` Broker string `json:"broker,omitempty"` Timestamp string `json:"timestamp,omitempty"` }
InventoryNode contains data about a single node
type Job ¶
type Job struct { ID string `json:"id"` Name string `json:"name"` State string `json:"state"` Type string `json:"type"` Command string `json:"command"` Options map[string]interface{} `json:"options"` NodeCount int `json:"node_count"` NodeStates NodeStates `json:"node_states"` Owner map[string]interface{} `json:"owner"` Description string `json:"description"` Timestamp string `json:"timestamp"` Environment Environment `json:"environment"` Status []Status `json:"status"` Nodes Nodes `json:"nodes"` Events Events `json:"events"` Report Report `json:"report"` }
Job contains data about a single job
type JobEvent ¶
type JobEvent struct { ID string `json:"id"` Type string `json:"type"` Timestamp string `json:"timestamp"` Details struct { Node string `json:"node"` Detail struct { Noop bool `json:"noop"` } `json:"detail"` } `json:"details"` Message string `json:"message"` }
JobEvent contains a single event from a job
type JobNode ¶
type JobNode struct { Transport string `json:"transport"` FinishTimestamp string `json:"finish_timestamp"` TransactionUUID string `json:"transaction_uuid"` StartTimestamp string `json:"start_timestamp"` Name string `json:"name"` Duration float64 `json:"duration"` State string `json:"state"` Details map[string]interface{} `json:"details"` Result map[string]interface{} `json:"result"` LatestEventID int `json:"latest-event-id"` Timestamp string `json:"timestamp"` }
JobNode is a single node associated with a given job
type JobNodes ¶
type JobNodes struct { Items []JobNode `json:"items"` NextEvents NextEvents `json:"next-events"` }
JobNodes is a list of all nodes associated with a given job
type JobReport ¶
type JobReport struct { Items []struct { Node string `json:"node"` State string `json:"state"` Timestamp string `json:"timestamp"` Events []JobEvent `json:"events"` } `json:"items"` }
JobReport contains the report for a single job
type Jobs ¶
type Jobs struct { Items []Job `json:"items"` Pagination Pagination `json:"pagination"` }
Jobs contains data about all jobs
type NextEvents ¶
NextEvents section of the response
type NodeStates ¶
type NodeStates struct { Finished int `json:"finished"` Errored int `json:"errored"` Failed int `json:"failed"` Running int `json:"running"` }
NodeStates for the current job
type OrchestratorError ¶
OrchestratorError represents an error response from the Orchestrator API
func (*OrchestratorError) Error ¶
func (oe *OrchestratorError) Error() string
func (*OrchestratorError) GetStatusCode ¶
func (oe *OrchestratorError) GetStatusCode() int
GetStatusCode will return the status code.
type Pagination ¶
type Pagination struct { Limit int `json:"limit"` Offset int `json:"offset"` Total int `json:"total"` }
Pagination information about the current payload
type Plan ¶
type Plan struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Environment struct { Name string `json:"name,omitempty"` CodeID string `json:"code_id,omitempty" structs:"-"` } `json:"environment,omitempty"` Metadata TaskMetadata `json:"metadata,omitempty" structs:"-"` Permitted bool `json:"permitted,omitempty"` }
Plan contains information about a specific plan
type PlanRunJobID ¶
type PlanRunJobID struct {
Name string `json:"name"`
}
PlanRunJobID identifies a plan_run job
type PlanRunRequest ¶
type PlanRunRequest struct { Name string `json:"plan_name"` Params map[string]interface{} `json:"params"` Environment string `json:"environment,omitempty"` Description string `json:"description,omitempty"` }
PlanRunRequest describes a plan_run request
type Plans ¶
type Plans struct { Environment struct { Name string `json:"name,omitempty"` CodeID string `json:"code_id,omitempty" structs:"-"` } `json:"environment,omitempty"` Items []struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Permitted bool `json:"permitted,omitempty"` } `json:"items,omitempty"` }
Plans lists the known plans in a single environment
type ScheduleOptions ¶
type ScheduleOptions struct {
Interval Interval `json:"interval"`
}
ScheduleOptions represents the schedule options for a task
func NewScheduleTaskOptions ¶
func NewScheduleTaskOptions(interval time.Duration) *ScheduleOptions
NewScheduleTaskOptions will create task options based on time
type ScheduleTaskRequest ¶
type ScheduleTaskRequest struct { Environment string `json:"environment,omitempty"` Task string `json:"task"` Params map[string]interface{} `json:"params"` Scope Scope `json:"scope"` ScheduledTime string `json:"scheduled_time"` ScheduleOptions *ScheduleOptions `json:"schedule_options,omitempty"` }
ScheduleTaskRequest describes a scheduled task
type ScheduledJobID ¶
type ScheduledJobID struct { ScheduledJob struct { ID string `json:"id"` Name string `json:"name"` } `json:"scheduled_job"` }
ScheduledJobID identifies a single scheduled job
type Scope ¶
type Scope struct { Application string `json:"application,omitempty"` Nodes []string `json:"nodes,omitempty"` Query []interface{} `json:"query,omitempty"` NodeGroup string `json:"node_group,omitempty"` }
Scope represents the scope of a job. Only a single field can be specified.
type Status ¶
type Status struct { State string `json:"state"` EnterTime string `json:"enter_time"` ExitTime string `json:"exit_time"` }
Status of the current job
type StopJobID ¶
type StopJobID struct { Job struct { ID string `json:"id"` Name string `json:"name"` Nodes map[string]int `json:"nodes"` } `json:"job"` }
StopJobID describes jobs that were stopped successfully
type StopRequest ¶
type StopRequest struct {
Job string `json:"job"`
}
StopRequest describes a stop request
type Task ¶
type Task struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Environment struct { Name string `json:"name,omitempty"` CodeID string `json:"code_id,omitempty"` } `json:"environment,omitempty"` Metadata TaskMetadata `json:"metadata,omitempty"` Files []TaskFile `json:"files,omitempty"` }
Task contains data about a specified task, including metadata and file information
type TaskFile ¶
type TaskFile struct { Filename string `json:"filename,omitempty"` URI struct { Path string `json:"path,omitempty"` Params struct { Environment string `json:"environment,omitempty"` } `json:"params,omitempty"` } `json:"uri,omitempty"` Sha256 string `json:"sha256,omitempty"` SizeBytes int `json:"size_bytes,omitempty"` }
TaskFile ...
type TaskImplementation ¶
type TaskImplementation struct { Name string `json:"name"` Requirements []string `json:"requirements"` InputMethod string `json:"input_method"` }
TaskImplementation in the task metadata
type TaskMetadata ¶
type TaskMetadata struct { Description string `json:"description,omitempty"` Private bool `json:"private,omitempty"` SupportsNoop bool `json:"supports_noop,omitempty"` InputMethod string `json:"input_method,omitempty"` Parameters map[string]TaskParam `json:"parameters,omitempty"` Extensions map[string]interface{} `json:"extensions,omitempty"` Implementations []TaskImplementation `json:"implementations"` }
TaskMetadata ...
type TaskParam ¶
type TaskParam struct { Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` }
TaskParam in the task metadata
type TaskRequest ¶
type TaskRequest struct { Environment string `json:"environment,omitempty"` Task string `json:"task"` Params map[string]interface{} `json:"params"` Scope Scope `json:"scope"` Description string `json:"description"` Noop bool `json:"noop"` }
TaskRequest describes a task to be run Environment(string): The environment to load the task from. The default is production. Scope The PuppetDB query, list of nodes, or a node group ID. Application scopes are not allowed for task jobs. This key is required. Description A description of the job. Noop Whether to run the job in no-op mode. The default is false. Task The task to run on the targets. This key is required. Params The parameters to pass to the task. This key is required, but can be an empty object. Targets A collection of target objects used for running the task on nodes through SSH or WinRM via Bolt server. Userdata An object of arbitrary key/value data supplied to the job. REF: https://puppet.com/docs/pe/2019.8/orchestrator_api_commands_endpoint.html#orchestrator_api_post_command_task
type TaskTargetJobID ¶
type TaskTargetJobID struct { TaskTargetJob struct { ID string `json:"id"` Name string `json:"name"` } `json:"task_target"` }
TaskTargetJobID identifies a task_target job
type TaskTargetRequest ¶
type TaskTargetRequest struct { DisplayName string `json:"display_name"` Tasks []string `json:"tasks,omitempty"` AllTasks bool `json:"all_tasks,omitempty"` Nodes []string `json:"nodes"` NodeGroups []string `json:"node_groups"` PQLQuery string `json:"pql_query,omitempty"` }
TaskTargetRequest is a collection of tasks, nodes and node groups that define a permission group
type Tasks ¶
type Tasks struct { Environment struct { Name string `json:"name,omitempty"` CodeID string `json:"code_id,omitempty"` } `json:"environment,omitempty"` Items []struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` } `json:"items,omitempty"` }
Tasks is a list all tasks in a single environment