Documentation ¶
Index ¶
- Constants
- func WithClient(httpc *http.Client) func(*Client)
- type Client
- func (c *Client) CreateJob(j DetailedJob) (int, error)
- func (c *Client) DeleteJob(id int) error
- func (c *Client) GetHistoryDetails(jobID int, historyID int) (HistoryItem, error)
- func (c *Client) GetJob(id int) (DetailedJob, error)
- func (c *Client) GetJobHistory(id int) (JobHistory, error)
- func (c *Client) ListJobs() ([]Job, error)
- func (c *Client) NewRequest(method string, body io.Reader, pathParts ...interface{}) (*http.Request, error)
- func (c *Client) UpdateJob(id int, j DetailedJob) error
- type DetailedJob
- type HistoryItem
- type HistoryItemStats
- type Job
- type JobAuth
- type JobExtendedData
- type JobHistory
- type JobNotificationSettings
- type JobStatus
- type JobType
- type Microseconds
- type Milliseconds
- type RequestMethod
- type Schedule
- type Seconds
Constants ¶
const ( // Unknown / not executed yet JobStatusUnknown = iota // OK JobStatusOK // Failed (DNS error) JobStatusFailedDNS // Failed (could not connect to host) JobStatusFailedCouldNotConnect // Failed (HTTP error) JobStatusFailedHTTPError // Failed (timeout) JobStatusFailedTimeout // Failed (too much response data) JobStatusFailedTooMuchResponse // Failed (invalid URL) JobStatusFailedInvalidURL // Failed (internal errors) JobStatusFailedInternalError // Failed (unknown reason) JobStatusFailedUknown )
const ( // Default job JobTypeDefault = iota // Monitoring job (used in a status monitor) JobTypeMonitoring )
const ( RequestMethodGet = iota RequestMethodPost RequestMethodOptions RequestMethodHead RequestMethodPut RequestMethodDelete RequestMethodTrace RequestMethodConnect RequestMethodPatch )
const APIURL = "https://api.cron-job.org"
Variables ¶
This section is empty.
Functions ¶
func WithClient ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a cron-job.org client
func (*Client) CreateJob ¶
func (c *Client) CreateJob(j DetailedJob) (int, error)
CreateJob https://docs.cron-job.org/rest-api.html#creating-a-cron-job
func (*Client) DeleteJob ¶
DeleteJob https://docs.cron-job.org/rest-api.html#deleting-a-cron-job
func (*Client) GetHistoryDetails ¶
func (c *Client) GetHistoryDetails(jobID int, historyID int) (HistoryItem, error)
GetHistoryDetails https://docs.cron-job.org/rest-api.html#retrieving-job-execution-history-item-details
func (*Client) GetJob ¶
func (c *Client) GetJob(id int) (DetailedJob, error)
GetJob https://docs.cron-job.org/rest-api.html#retrieving-cron-job-details
func (*Client) GetJobHistory ¶
func (c *Client) GetJobHistory(id int) (JobHistory, error)
GetJobHistory https://docs.cron-job.org/rest-api.html#retrieving-the-job-execution-history
func (*Client) ListJobs ¶
ListJobs https://docs.cron-job.org/rest-api.html#listing-cron-jobs
func (*Client) NewRequest ¶
func (*Client) UpdateJob ¶
func (c *Client) UpdateJob(id int, j DetailedJob) error
UpdateJob https://docs.cron-job.org/rest-api.html#updating-a-cron-job
type DetailedJob ¶
type DetailedJob struct { Job // HTTP authentication settings Auth JobAuth `json:"auth"` // Notification settings Notification JobNotificationSettings `json:"notification"` // Extended request data ExtendedData JobExtendedData `json:"extendedData"` }
DetailedJob https://docs.cron-job.org/rest-api.html#jobauth
type HistoryItem ¶
type HistoryItem struct { // Identifier of the associated cron job JobID int `json:"jobId"` // Identifier of the history item Identifier string `json:"identifier"` // Unix timestamp (in seconds) of the actual execution Date Seconds `json:"date"` // Unix timestamp (in seconds) of the planned/ideal execution DatePlanned Seconds `json:"datePlanned"` // Scheduling jitter in milliseconds Jitter Milliseconds `json:"jitter"` // Job URL at time of execution URL string `json:"url"` // Actual job duration in milliseconds Duration Milliseconds `json:"duration"` // Status of execution Status JobStatus `json:"status"` // Detailed job status Description StatusText string `json:"statusText"` // HTTP status code returned by the host, if any HTTPStatus int `json:"httpStatus"` // Raw response headers returned by the host (null if unavailable) Headers string `json:"headers,omitempty"` // Raw response body returned by the host (null if unavailable) Body string `json:"body"` // Additional timing information for this request Stats HistoryItemStats `json:"stats"` }
HistoryItem https://docs.cron-job.org/rest-api.html#historyitem
type HistoryItemStats ¶
type HistoryItemStats struct { // Time from transfer start until name lookups completed (in microseconds) NameLookup Microseconds `json:"nameLookup"` // Time from transfer start until socket connect completed (in microseconds) Connect Microseconds `json:"connect"` // Time from transfer start until SSL handshake completed (n microseconds) - 0 if not using SSL AppConnect Microseconds `json:"appConnect"` // Time from transfer start until beginning of data transfer (in microseconds) PreTransfer Microseconds `json:"preTransfer"` // Time from transfer start until the first response byte is received (in microseconds) StartTransfer Microseconds `json:"startTransfer"` // Total transfer time (in microseconds) Total Microseconds `json:"total"` }
HistoryItemStats https://docs.cron-job.org/rest-api.html#historyitemstats
type Job ¶
type Job struct { // Job identifier JobID int `json:"jobId"` // Whether the job is enabled (i.e. being executed) or not Enabled bool `json:"enabled"` // Job title Title string `json:"title"` // Whether to save job response header/body or not SaveResponses bool `json:"saveResponses"` // Job URL URL string `json:"url"` // Last execution status LastStatus JobStatus `json:"lastStatus"` // Last execution duration in milliseconds LastDuration Milliseconds `json:"lastDuration"` // Unix timestamp of last execution (in seconds) LastExecution Seconds `json:"lastExecution"` // Unix timestamp of predicted next execution (in seconds), null if no prediction available NextExecution Seconds `json:"nextExecution"` // Job type Type JobType `json:"type"` // Job timeout in seconds RequestTimeout Seconds `json:"requestTimeout"` // Job schedule Schedule Schedule `json:"schedule"` // HTTP request method RequestMethod RequestMethod `json:"requestMethod"` }
type JobAuth ¶
type JobExtendedData ¶
type JobExtendedData struct { // Request headers (key-value dictionary) Headers map[string]string `json:"headers"` // Request body data Body string `json:"body"` }
JobExtendedData https://docs.cron-job.org/rest-api.html#jobextendeddata
type JobHistory ¶
type JobHistory struct { History HistoryItem `json:"history"` Predictions []Seconds `json:"predictions"` }
JobHistory is a cron-job.org job history
type JobNotificationSettings ¶
type JobNotificationSettings struct { // Whether to send a notification on job failure or not. OnFailure bool `json:"onFailure"` // Whether to send a notification when the job succeeds after a prior failure or not. OnSuccess bool `json:"onSuccess"` // Whether to send a notification when the job has been disabled automatically or not. OnDisable bool `json:"onDisable"` }
JobNotificationSettings https://docs.cron-job.org/rest-api.html#job
type Microseconds ¶
type Microseconds int64
Microseconds represents a time.Time in microseconds
func (Microseconds) Time ¶
func (m Microseconds) Time() time.Time
Time returns a time.Time from the Microseconds
type Milliseconds ¶
type Milliseconds int64
Milliseconds represents a time.Time in milliseconds
func (Milliseconds) Time ¶
func (m Milliseconds) Time() time.Time
type RequestMethod ¶
type RequestMethod int
RequestMethod https://docs.cron-job.org/rest-api.html#requestmethod
type Schedule ¶
type Schedule struct { // Schedule time zone (see here for a list of supported values) Timezone string `json:"timezone"` // Hours in which to execute the job (0-23; [-1] = every hour) Hours []int `json:"hours"` // Days of month in which to execute the job (1-31; [-1] = every day of month) Mdays []int `json:"mdays"` // Minutes in which to execute the job (0-59; [-1] = every minute) Minutes []int `json:"minutes"` // Months in which to execute the job (1-12; [-1] = every month) Month []int `json:"months"` // Days of week in which to execute the job (0-6; [-1] = every day of week) WDays []int `json:"wdays"` }
Schedule https://docs.cron-job.org/rest-api.html#jobschedule
func (Schedule) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface