Documentation ¶
Overview ¶
Package rundeck provides a client for interacting with a Rundeck instance via its HTTP API.
Instantiate a Client with the NewClient function to get started.
At present this package uses Rundeck API version 13.
Index ¶
- type About
- type Boolean
- type Client
- func (c *Client) CreateJob(job *JobDetail) (*JobSummary, error)
- func (c *Client) CreateOrUpdateJob(job *JobDetail) (*JobSummary, error)
- func (c *Client) CreatePassword(path string, content string) error
- func (c *Client) CreatePrivateKey(path string, content string) error
- func (c *Client) CreateProject(project *Project) (*Project, error)
- func (c *Client) CreatePublicKey(path string, content string) error
- func (c *Client) DeleteJob(id string) error
- func (c *Client) DeleteKey(path string) error
- func (c *Client) DeleteProject(name string) error
- func (c *Client) GetAllProjects() ([]ProjectSummary, error)
- func (c *Client) GetJob(id string) (*JobDetail, error)
- func (c *Client) GetJobForcast(id string) (*JobForecast, error)
- func (c *Client) GetJobSummariesForProject(projectName string) ([]JobSummary, error)
- func (c *Client) GetJobsForProject(projectName string) ([]JobDetail, error)
- func (c *Client) GetKeyContent(path string) (string, error)
- func (c *Client) GetKeyMeta(path string) (*KeyMeta, error)
- func (c *Client) GetKeysInDirMeta(path string) ([]KeyMeta, error)
- func (c *Client) GetProject(name string) (*Project, error)
- func (c *Client) GetSystemInfo() (*SystemInfo, error)
- func (c *Client) ReplacePassword(path string, content string) error
- func (c *Client) ReplacePrivateKey(path string, content string) error
- func (c *Client) ReplacePublicKey(path string, content string) error
- func (c *Client) SetProjectConfig(projectName string, config ProjectConfig) error
- type ClientConfig
- type EmailNotification
- type Error
- type JobCommand
- type JobCommandJobRef
- type JobCommandJobRefArguments
- type JobCommandScriptInterpreter
- type JobCommandSequence
- type JobDetail
- type JobDispatch
- type JobForecast
- type JobNodeFilter
- type JobNotification
- type JobOption
- type JobOptions
- type JobPlugin
- type JobPluginConfig
- type JobSchedule
- type JobScheduleDayOfMonth
- type JobScheduleMonth
- type JobScheduleTime
- type JobScheduleWeekDay
- type JobScheduleYear
- type JobSummary
- type JobValueChoices
- type KeyMeta
- type NotFoundError
- type Notification
- type NotificationEmails
- type NotificationUrls
- type Project
- type ProjectConfig
- type ProjectSummary
- type SystemCPUStats
- type SystemInfo
- type SystemJVM
- type SystemMemoryUsage
- type SystemOS
- type SystemSchedulerStats
- type SystemStats
- type SystemThreadStats
- type SystemTimestamp
- type SystemUptime
- type WebHookNotification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type About ¶
type About struct { XMLName xml.Name `xml:"rundeck"` Version string `xml:"version"` APIVersion int64 `xml:"apiversion"` Build string `xml:"build"` Node string `xml:"node"` BaseDir string `xml:"base"` ServerUUID string `xml:"serverUUID,omitempty"` }
About describes the Rundeck server itself.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Rundeck API client interface.
func NewClient ¶
func NewClient(config *ClientConfig) (*Client, error)
NewClient returns a configured Rundeck client.
func NewClientWithVersion ¶ added in v0.0.6
func NewClientWithVersion(config *ClientConfig, version string) (*Client, error)
NewClient returns a configured Rundeck client.
func (*Client) CreateJob ¶
func (c *Client) CreateJob(job *JobDetail) (*JobSummary, error)
CreateJob creates a new job based on the provided structure.
func (*Client) CreateOrUpdateJob ¶
func (c *Client) CreateOrUpdateJob(job *JobDetail) (*JobSummary, error)
CreateOrUpdateJob takes a job detail structure which has its ID set and either updates an existing job with the same id or creates a new job with that id.
func (*Client) CreatePrivateKey ¶
func (*Client) CreateProject ¶
CreateProject creates a new, empty project.
func (*Client) CreatePublicKey ¶
func (*Client) DeleteProject ¶
DeleteProject deletes a project and all of its jobs.
func (*Client) GetAllProjects ¶
func (c *Client) GetAllProjects() ([]ProjectSummary, error)
GetAllProjects retrieves and returns all of the projects defined in the Rundeck server.
func (*Client) GetJobForcast ¶ added in v0.0.4
func (c *Client) GetJobForcast(id string) (*JobForecast, error)
get job forcast to get next set of executions
func (*Client) GetJobSummariesForProject ¶
func (c *Client) GetJobSummariesForProject(projectName string) ([]JobSummary, error)
GetJobSummariesForProject returns summaries of the jobs belonging to the named project.
func (*Client) GetJobsForProject ¶
GetJobsForProject returns the full job details of the jobs belonging to the named project.
func (*Client) GetKeyContent ¶
GetKeyContent retrieves and returns the content of the key at the given keystore path. Private keys are write-only, so they cannot be retrieved via this interface.
func (*Client) GetKeyMeta ¶
GetKeyMeta returns the metadata for the key at the given keystore path.
func (*Client) GetKeysInDirMeta ¶
GetKeysInDirMeta returns the metadata for the keys and subdirectories within the directory at the given keystore path.
func (*Client) GetProject ¶
GetProject retrieves and returns the named project.
func (*Client) GetSystemInfo ¶
func (c *Client) GetSystemInfo() (*SystemInfo, error)
GetSystemInfo retrieves and returns miscellaneous system information about the Rundeck server and the machine it's running on.
func (*Client) ReplacePassword ¶
func (*Client) ReplacePrivateKey ¶
func (*Client) ReplacePublicKey ¶
func (*Client) SetProjectConfig ¶
func (c *Client) SetProjectConfig(projectName string, config ProjectConfig) error
SetProjectConfig replaces the configuration of the named project.
type ClientConfig ¶
type ClientConfig struct { // The base URL of the Rundeck instance. BaseURL string // The API auth token generated from user settings in the Rundeck UI. AuthToken string // Don't fail if the server uses SSL with an un-verifiable certificate. // This is not recommended except during development/debugging. AllowUnverifiedSSL bool }
ClientConfig is used with NewClient to specify initialization settings.
type EmailNotification ¶
type EmailNotification struct { AttachLog bool `xml:"attachLog,attr,omitempty"` Recipients NotificationEmails `xml:"recipients,attr"` Subject string `xml:"subject,attr"` }
type Error ¶
type Error struct { XMLName xml.Name `xml:"result"` IsError bool `xml:"error,attr"` Message string `xml:"error>message"` }
Error implements the error interface for a Rundeck API error that was returned from the server as XML.
type JobCommand ¶
type JobCommand struct { XMLName xml.Name // If the Workflow keepgoing is false, this allows the Workflow to continue when the Error Handler is successful. ContinueOnError bool `xml:"keepgoingOnSuccess,attr,omitempty"` // Description Description string `xml:"description,omitempty"` // On error: ErrorHandler *JobCommand `xml:"errorhandler,omitempty"` // A literal shell command to run. ShellCommand string `xml:"exec,omitempty"` // Add extension to the temporary filename. FileExtension string `xml:"fileExtension,omitempty"` // An inline program to run. This will be written to disk and executed, so if it is // a shell script it should have an appropriate #! line. Script string `xml:"script,omitempty"` // A pre-existing file (on the target nodes) that will be executed. ScriptFile string `xml:"scriptfile,omitempty"` // When ScriptFile is set, the arguments to provide to the script when executing it. ScriptFileArgs string `xml:"scriptargs,omitempty"` // ScriptInterpreter is used to execute (Script)File with. ScriptInterpreter *JobCommandScriptInterpreter `xml:"scriptinterpreter,omitempty"` // A reference to another job to run as this command. Job *JobCommandJobRef `xml:"jobref"` // Configuration for a step plugin to run as this command. StepPlugin *JobPlugin `xml:"step-plugin"` // Configuration for a node step plugin to run as this command. NodeStepPlugin *JobPlugin `xml:"node-step-plugin"` }
JobCommand describes a particular command to run within the sequence of commands on a job. The members of this struct are mutually-exclusive except for the pair of ScriptFile and ScriptFileArgs.
type JobCommandJobRef ¶
type JobCommandJobRef struct { XMLName xml.Name `xml:"jobref"` Name string `xml:"name,attr"` GroupName string `xml:"group,attr"` RunForEachNode bool `xml:"nodeStep,attr"` Dispatch *JobDispatch `xml:"dispatch,omitempty"` NodeFilter *JobNodeFilter `xml:"nodefilters,omitempty"` Arguments JobCommandJobRefArguments `xml:"arg"` }
JobCommandJobRef is a reference to another job that will run as one of the commands of a job.
type JobCommandJobRefArguments ¶
type JobCommandJobRefArguments string
JobCommandJobRefArguments is a string representing the arguments in a JobCommandJobRef.
func (JobCommandJobRefArguments) MarshalXML ¶
func (a JobCommandJobRefArguments) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*JobCommandJobRefArguments) UnmarshalXML ¶
func (a *JobCommandJobRefArguments) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type JobCommandScriptInterpreter ¶
type JobCommandScriptInterpreter struct { XMLName xml.Name `xml:"scriptinterpreter"` InvocationString string `xml:",chardata"` ArgsQuoted bool `xml:"argsquoted,attr,omitempty"` }
(Inline) Script interpreter
type JobCommandSequence ¶
type JobCommandSequence struct { XMLName xml.Name `xml:"sequence"` // If set, Rundeck will continue with subsequent commands after a command fails. ContinueOnError bool `xml:"keepgoing,attr"` // Chooses the strategy by which Rundeck will execute commands. Can either be "node-first" or // "step-first". OrderingStrategy string `xml:"strategy,attr,omitempty"` // Sequence of commands to run in the sequence. Commands []JobCommand `xml:"command"` // Description Description string `xml:"description,omitempty"` }
JobCommandSequence describes the sequence of operations that a job will perform.
type JobDetail ¶
type JobDetail struct { XMLName xml.Name `xml:"job"` ID string `xml:"uuid,omitempty"` Name string `xml:"name"` GroupName string `xml:"group,omitempty"` ProjectName string `xml:"context>project,omitempty"` OptionsConfig *JobOptions `xml:"context>options,omitempty"` Description string `xml:"description"` ExecutionEnabled bool `xml:"executionEnabled"` LogLevel string `xml:"loglevel,omitempty"` AllowConcurrentExecutions bool `xml:"multipleExecutions,omitempty"` Dispatch *JobDispatch `xml:"dispatch,omitempty"` CommandSequence *JobCommandSequence `xml:"sequence,omitempty"` Notification *JobNotification `xml:"notification,omitempty"` Timeout string `xml:"timeout,omitempty"` Retry string `xml:"retry,omitempty"` NodeFilter *JobNodeFilter `xml:"nodefilters,omitempty"` TimeZone string `xml:"timeZone,omitempty"` /* If Dispatch is enabled, nodesSelectedByDefault is always present with true/false. * by this reason omitempty cannot be present. * This has to be handle by the user. */ NodesSelectedByDefault *Boolean `xml:"nodesSelectedByDefault"` Schedule *JobSchedule `xml:"schedule,omitempty"` ScheduleEnabled bool `xml:"scheduleEnabled"` }
JobDetail is a comprehensive description of a job, including its entire definition.
type JobDispatch ¶
type JobForecast ¶ added in v0.0.4
type JobForecast struct { Href string `json:"href"` ID string `json:"id"` ScheduleEnabled bool `json:"scheduleEnabled"` Scheduled bool `json:"scheduled"` Enabled bool `json:"enabled"` Permalink string `json:"permalink"` Group interface{} `json:"group"` FutureScheduledExecutions []time.Time `json:"futureScheduledExecutions"` Description string `json:"description"` Project string `json:"project"` Name string `json:"name"` }
type JobNodeFilter ¶
type JobNodeFilter struct {
Query string `xml:"filter,omitempty"`
}
JobNodeFilter describes which nodes from the project's resource list will run the configured commands.
type JobNotification ¶
type JobNotification struct { OnFailure *Notification `xml:"onfailure,omitempty"` OnStart *Notification `xml:"onstart,omitempty"` OnSuccess *Notification `xml:"onsuccess,omitempty"` }
type JobOption ¶
type JobOption struct { XMLName xml.Name `xml:"option"` // If AllowsMultipleChoices is set, the string that will be used to delimit the multiple // chosen options. MultiValueDelimiter string `xml:"delimiter,attr,omitempty"` // If set, Rundeck will reject values that are not in the set of predefined choices. RequirePredefinedChoice bool `xml:"enforcedvalues,attr,omitempty"` // When either ValueChoices or ValueChoicesURL is set, controls whether more than one // choice may be selected as the value. AllowsMultipleValues bool `xml:"multivalued,attr,omitempty"` // The name of the option, which can be used to interpolate its value // into job commands. Name string `xml:"name,attr,omitempty"` // Regular expression to be used to validate the option value. ValidationRegex string `xml:"regex,attr,omitempty"` // If set, Rundeck requires a value to be set for this option. IsRequired bool `xml:"required,attr,omitempty"` // If set, the input for this field will be obscured in the UI. Useful for passwords // and other secrets. ObscureInput bool `xml:"secure,attr,omitempty"` // If ObscureInput is set, StoragePath can be used to point out credentials. StoragePath string `xml:"storagePath,attr,omitempty"` // The default value of the option. DefaultValue string `xml:"value,attr,omitempty"` // If set, the value can be accessed from scripts. ValueIsExposedToScripts bool `xml:"valueExposed,attr,omitempty"` // A sequence of predefined choices for this option. Mutually exclusive with ValueChoicesURL. ValueChoices JobValueChoices `xml:"values,attr"` // A URL from which the predefined choices for this option will be retrieved. // Mutually exclusive with ValueChoices ValueChoicesURL string `xml:"valuesUrl,attr,omitempty"` // Description of the value to be shown in the Rundeck UI. Description string `xml:"description,omitempty"` }
JobOption represents a single option on a job.
type JobOptions ¶
type JobOptions struct { PreserveOrder bool `xml:"preserveOrder,attr,omitempty"` Options []JobOption `xml:"option"` }
JobOptions represents the set of options on a job, if any.
type JobPlugin ¶
type JobPlugin struct { XMLName xml.Name Type string `xml:"type,attr"` Config JobPluginConfig `xml:"configuration"` }
Plugin is a configuration for a plugin to run within a job or notification.
type JobPluginConfig ¶
JobPluginConfig is a specialization of map[string]string for job plugin configuration.
func (JobPluginConfig) MarshalXML ¶
func (c JobPluginConfig) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*JobPluginConfig) UnmarshalXML ¶
func (c *JobPluginConfig) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type JobSchedule ¶
type JobSchedule struct { XMLName xml.Name `xml:"schedule"` DayOfMonth *JobScheduleDayOfMonth `xml:"dayofmonth,omitempty"` Time JobScheduleTime `xml:"time"` Month JobScheduleMonth `xml:"month"` WeekDay *JobScheduleWeekDay `xml:"weekday,omitempty"` Year JobScheduleYear `xml:"year"` }
type JobScheduleDayOfMonth ¶
type JobScheduleMonth ¶
type JobScheduleTime ¶
type JobScheduleWeekDay ¶
type JobScheduleYear ¶
type JobSummary ¶
type JobSummary struct { XMLName xml.Name `xml:"job"` ID string `xml:"id,attr"` Name string `xml:"name"` GroupName string `xml:"group"` ProjectName string `xml:"project"` Description string `xml:"description,omitempty"` }
JobSummary is an abbreviated description of a job that includes only its basic descriptive information and identifiers.
type JobValueChoices ¶
type JobValueChoices []string
JobValueChoices is a specialization of []string representing a sequence of predefined values for a job option.
func (JobValueChoices) MarshalXMLAttr ¶
func (*JobValueChoices) UnmarshalXMLAttr ¶
func (c *JobValueChoices) UnmarshalXMLAttr(attr xml.Attr) error
type KeyMeta ¶
type KeyMeta struct { XMLName string `xml:"resource"` Name string `xml:"name,attr,omitempty"` Path string `xml:"path,attr,omitempty"` ResourceType string `xml:"type,attr,omitempty"` URL string `xml:"url,attr,omitempty"` ContentType string `xml:"resource-meta>Rundeck-content-type"` ContentSize string `xml:"resource-meta>Rundeck-content-size"` ContentMask string `xml:"resource-meta>Rundeck-content-mask"` KeyType string `xml:"resource-meta>Rundeck-key-type"` LastModifiedByUserName string `xml:"resource-meta>Rundeck-auth-modified-username"` CreatedByUserName string `xml:"resource-meta>Rundeck-auth-created-username"` CreatedTimestamp string `xml:"resource-meta>Rundeck-content-creation-time"` LastModifiedTimestamp string `xml:"resource-meta>Rundeck-content-modify-time"` }
KeyMeta is the metadata associated with a resource in the Rundeck key store.
type NotFoundError ¶
type NotFoundError struct{}
func (NotFoundError) Error ¶
func (err NotFoundError) Error() string
type Notification ¶
type Notification struct { Email *EmailNotification `xml:"email,omitempty"` WebHook *WebHookNotification `xml:"webhook,omitempty"` Plugin *JobPlugin `xml:"plugin"` }
type NotificationEmails ¶
type NotificationEmails []string
func (NotificationEmails) MarshalXMLAttr ¶
func (*NotificationEmails) UnmarshalXMLAttr ¶
func (c *NotificationEmails) UnmarshalXMLAttr(attr xml.Attr) error
type NotificationUrls ¶
type NotificationUrls []string
func (NotificationUrls) MarshalXMLAttr ¶
func (*NotificationUrls) UnmarshalXMLAttr ¶
func (c *NotificationUrls) UnmarshalXMLAttr(attr xml.Attr) error
type Project ¶
type Project struct { Name string `xml:"name"` Description string `xml:"description,omitempty"` // Config is the project configuration. // // When making requests, Config and RawConfigItems are combined to produce // a single set of configuration settings. Thus it isn't necessary and // doesn't make sense to duplicate the same properties in both properties. Config ProjectConfig `xml:"config"` // URL is used only to represent server responses. It is ignored when // making requests. URL string `xml:"url,attr"` // XMLName is used only in XML unmarshalling and doesn't need to // be set when creating a Project to send to the server. XMLName xml.Name `xml:"project"` }
Project represents a project within Rundeck.
type ProjectConfig ¶
ProjectConfig is a specialized map[string]string representing Rundeck project configuration
func (ProjectConfig) MarshalXML ¶
func (c ProjectConfig) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*ProjectConfig) UnmarshalXML ¶
func (c *ProjectConfig) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type ProjectSummary ¶
type ProjectSummary struct { Name string `xml:"name"` Description string `xml:"description,omitempty"` URL string `xml:"url,attr"` }
ProjectSummary provides the basic identifying information for a project within Rundeck.
type SystemCPUStats ¶
type SystemCPUStats struct { XMLName xml.Name `xml:"cpu"` LoadAverage struct { Unit string `xml:"unit,attr"` Value float64 `xml:",chardata"` } `xml:"loadAverage"` ProcessorCount int64 `xml:"processors"` }
SystemCPUStats describes the available processors and the system load average of the machine on which the Rundeck server is running.
type SystemInfo ¶
type SystemInfo struct { XMLName xml.Name `xml:"system"` ServerTime SystemTimestamp `xml:"timestamp"` Rundeck About `xml:"rundeck"` OS SystemOS `xml:"os"` JVM SystemJVM `xml:"jvm"` Stats SystemStats `xml:"stats"` }
SystemInfo represents a set of miscellaneous system information properties about the Rundeck server.
type SystemJVM ¶
type SystemJVM struct { Name string `xml:"name"` Vendor string `xml:"vendor"` Version string `xml:"version"` ImplementationVersion string `xml:"implementationVersion"` }
SystemJVM describes the Java Virtual Machine that the Rundeck server is running in.
type SystemMemoryUsage ¶
type SystemMemoryUsage struct { XMLName xml.Name `xml:"memory"` Unit string `xml:"unit,attr"` Max int64 `xml:"max"` Free int64 `xml:"free"` Total int64 `xml:"total"` }
SystemMemoryUsage describes how much memory is available and used on the machine on which the Rundeck server is running.
type SystemOS ¶
type SystemOS struct { Architecture string `xml:"arch"` Name string `xml:"name"` Version string `xml:"version"` }
SystemOS describes the operating system of the Rundeck server.
type SystemSchedulerStats ¶
type SystemSchedulerStats struct {
RunningJobCount int64 `xml:"running"`
}
SystemSchedulerStats provides statistics about the Rundeck scheduler.
type SystemStats ¶
type SystemStats struct { XMLName xml.Name `xml:"stats"` Uptime SystemUptime `xml:"uptime"` CPU SystemCPUStats `xml:"cpu"` Memory SystemMemoryUsage `xml:"memory"` Scheduler SystemSchedulerStats `xml:"scheduler"` Threads SystemThreadStats `xml:"threads"` }
SystemStats provides some basic system statistics about the server that Rundeck is running on.
type SystemThreadStats ¶
type SystemThreadStats struct {
ActiveThreadCount int64 `xml:"active"`
}
SystemThreadStats provides statistics about the thread usage of the Rundeck server.
type SystemTimestamp ¶
type SystemTimestamp struct { Epoch string `xml:"epoch,attr"` EpochUnit string `xml:"unit,attr"` DateTimeStr string `xml:"datetime"` }
SystemTimestamp gives a timestamp from the Rundeck server.
func (*SystemTimestamp) DateTime ¶
func (ts *SystemTimestamp) DateTime() time.Time
DateTime produces a time.Time object from a SystemTimestamp object.
type SystemUptime ¶
type SystemUptime struct { XMLName xml.Name `xml:"uptime"` Duration string `xml:"duration,attr"` DurationUnit string `xml:"unit,attr"` BootTimestamp SystemTimestamp `xml:"since"` }
SystemUptime describes how long Rundeck's host machine has been running.
type WebHookNotification ¶
type WebHookNotification struct {
Urls NotificationUrls `xml:"urls,attr"`
}