jobs

package
v0.0.0-...-2e63bfb Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJobsInto

func ExtractJobsInto(r pagination.Page, v interface{}) error

func List

List returns a Pager which allows you to iterate over a collection of jobs. It accepts a ListOpts struct, which allows you to filter the returned collection for greater efficiency.

Types

type CreateOpts

type CreateOpts struct {
	// To represents the AgentID
	To string `json:"to" required:"true"`
	// 1-86400
	Timeout int `json:"timeout" required:"true"`
	// agent can be: chef (zero), execute (script, tarball)
	Agent string `json:"agent" required:"true"`
	// action can be: script, zero, tarball
	Action  string `json:"action" required:"true"`
	Payload string `json:"payload" required:"true"`
}

CreateOpts represents the attributes used when creating a new job.

func (CreateOpts) ToJobCreateMap

func (opts CreateOpts) ToJobCreateMap() (map[string]interface{}, error)

ToJobCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToJobCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

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

InitResult represents the result of a create operation. Call its Extract method to interpret it as a Job.

func Create

Create accepts a CreateOpts struct and creates a new job using the values provided.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Job, error)

Extract is a function that accepts a result and extracts a job resource.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

type GetLogHeader

type GetLogHeader struct {
	ContentType string `json:"Content-Type"`
}

GetLogHeader represents the headers returned in the response from a GetLog request.

type GetLogResult

type GetLogResult struct {
	gophercloud.HeaderResult
	Body io.ReadCloser
}

InitResult represents the result of a get job log operation. Call its ExtractHeaders method to interpret it as an job log response headers or ExtractContent method to interpret it as a response content.

func GetLog

func GetLog(c *gophercloud.ServiceClient, id string) (r GetLogResult)

GetLog retrieves a log for a Job ID.

func (*GetLogResult) ExtractContent

func (r *GetLogResult) ExtractContent() ([]byte, error)

ExtractContent is a function that takes a GetLogResult's io.Reader body and reads all available data into a slice of bytes. Please be aware that due the nature of io.Reader is forward-only - meaning that it can only be read once and not rewound. You can recreate a reader from the output of this function by using bytes.NewReader(initBytes)

func (GetLogResult) ExtractHeaders

func (r GetLogResult) ExtractHeaders() (*GetLogHeader, error)

Extract will return a struct of headers returned from a call to GetLog.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Job.

func Get

func Get(c *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific job based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Job, error)

Extract is a function that accepts a result and extracts a job resource.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type Job

type Job struct {
	Version int    `json:"version"`
	Sender  string `json:"sender"`
	// RequestID represents the JobID
	RequestID string `json:"request_id"`
	// To represents the AgentID
	To      string `json:"to"`
	Timeout int    `json:"timeout"`
	// agent can be: chef (zero), execute (script, tarball)
	Agent string `json:"agent"`
	// action can be: script, zero, tarball
	Action  string `json:"action"`
	Payload string `json:"payload"`
	// Status can be: queued, executing, failed, complete
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
	Project   string    `json:"project"`
	User      User      `json:"user"`
}

Job represents an Arc Job.

func ExtractJobs

func ExtractJobs(r pagination.Page) ([]Job, error)

ExtractJobs accepts a Page struct, specifically a JobPage struct, and extracts the elements into a slice of Job structs. In other words, a generic collection is mapped into a relevant slice.

func (*Job) MarshalJSON

func (r *Job) MarshalJSON() ([]byte, error)

func (*Job) UnmarshalJSON

func (r *Job) UnmarshalJSON(b []byte) error

type JobPage

type JobPage struct {
	pagination.MarkerPageBase
}

JobPage is the page returned by a pager when traversing over a collection of jobs.

func (JobPage) IsEmpty

func (r JobPage) IsEmpty() (bool, error)

IsEmpty checks whether a JobPage struct is empty.

func (JobPage) LastMarker

func (r JobPage) LastMarker() (string, error)

LastMarker returns the next page in a ListResult.

func (JobPage) NextPageURL

func (r JobPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of jobs has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type ListOpts

type ListOpts struct {
	Page    int    `q:"page"`
	PerPage int    `q:"per_page"`
	AgentID string `q:"agent_id"`
}

ListOpts allows the filtering of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the job attributes you want to see returned. Page and PerPage are used for pagination.

func (ListOpts) ToJobListQuery

func (opts ListOpts) ToJobListQuery() (string, error)

ToJobListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToJobListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type User

type User struct {
	ID         string   `json:"id"`
	Name       string   `json:"name"`
	DomainID   string   `json:"domain_id"`
	DomainName string   `json:"domain_name"`
	Roles      []string `json:"roles"`
}

User represents an Arc Job User.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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