Documentation
¶
Index ¶
- Constants
- Variables
- type AURBuild
- type AddJobRequest
- type AddJobResponse
- type Authorization
- type AuthorizationType
- type ContentType
- type CredentialsRequest
- type Endpoint
- type JobInfo
- type JobLogsRequest
- type JobRequest
- type JobState
- type JobType
- type LibRB
- func (librb LibRB) AddJob(jobType JobType, uploadType UploadType, args map[string]string, ...) (*AddJobResponse, error)
- func (librb LibRB) CancelJob(jobID uint) error
- func (librb LibRB) ClearCcache() (string, error)
- func (librb LibRB) JobInfo(jobID uint) (*JobInfo, error)
- func (librb LibRB) ListJobs(limit int) (*ListJobsResponse, error)
- func (librb LibRB) Login(username, password string) (*LoginResponse, error)
- func (librb LibRB) Logs(jobID uint, since time.Time) (*RestRequestResponse, error)
- func (Librb LibRB) NewAURBuild(packageName string) *AURBuild
- func (limdm *LibRB) NewRequest(endpoint Endpoint, payload interface{}) *Request
- func (librb LibRB) Ping() (*StringResponse, error)
- func (librb LibRB) QueryCcache() (StringResponse, error)
- func (librb LibRB) Register(username, password string) (*RestRequestResponse, error)
- func (libdm LibRB) Request(ep Endpoint, payload, response interface{}, authorized bool) (*RestRequestResponse, error)
- func (librb LibRB) SetJobState(jobID uint, state JobState) error
- type ListJobsRequest
- type ListJobsResponse
- type LoginResponse
- type Method
- type PingRequest
- type Request
- func (request *Request) BuildClient() *http.Client
- func (request Request) Do(retVar interface{}) (*RestRequestResponse, error)
- func (request *Request) DoHTTPRequest() (*http.Response, error)
- func (request *Request) WithAuth(a Authorization) *Request
- func (request *Request) WithAuthFromConfig() *Request
- func (request *Request) WithBenchCallback(c chan time.Time) *Request
- func (request *Request) WithContentType(ct ContentType) *Request
- func (request *Request) WithHeader(name string, value string) *Request
- func (request *Request) WithMethod(m Method) *Request
- func (request *Request) WithNoBodyClose() *Request
- func (request *Request) WithRequestType(rType RequestType) *Request
- type RequestConfig
- type RequestType
- type ResponseErr
- type ResponseStatus
- type RestRequestResponse
- type SortByJob
- type StringResponse
- type StringSliceResponse
- type UploadType
Constants ¶
const ( // DMToken session token for DManager DMToken = "DM_Token" // DMUser username for DManger DMUser = "DM_USER" // DMHost Dmanager host DMHost = "DM_HOST" // DMHost Dmanager host DMNamespace = "DM_NAMESPACE" )
DataManager Keys
const ( // Ping EPPing Endpoint = "/ping" // User EPUser Endpoint = "/user" EPLogin = EPUser + "/login" EPRegister = EPUser + "/register" // Jobs EPJob Endpoint = "/job" EPJobAdd = EPJob + "/create" EPJobLogs = EPJob + "/logs" EPJobCancel = EPJob + "/cancel" EPJobInfo = EPJob + "/info" EPJobs = EPJob + "s" EPJobState = EPJob + "/state" EPJobPause = EPJobState + "/pause" EPJobResume = EPJobState + "/resume" // Ccache EPCcache Endpoint = "/ccache" EPCcacheClear = EPCcache + "/clear" EPCcacheStats = EPCcache + "/stats" )
Remote endpoints
const ( // HeaderStatus headername for status in response HeaderStatus string = "X-Response-Status" // HeaderStatusMessage headername for status in response HeaderStatusMessage string = "X-Response-Message" // HeaderContentType contenttype of response HeaderContentType string = "Content-Type" // HeaderRequest request content HeaderRequest string = "Request" // HeaderContentLength request content length HeaderContentLength string = "ContentLength" )
const (
AURPackage = "REPO"
)
AUR keys
Variables ¶
var ( // ErrInvalidResponseHeaders error on missing or malformed response headers ErrInvalidResponseHeaders = errors.New("Invalid response headers") // ErrResponseError response returned an error ErrResponseError = errors.New("response returned an error") )
Functions ¶
This section is empty.
Types ¶
type AURBuild ¶
type AURBuild struct {
LibRB
UploadType UploadType
DisableCcache bool
// contains filtered or unexported fields
}
AURBuild build an AUR package
func (*AURBuild) CreateJob ¶
func (aurBuild *AURBuild) CreateJob() (*AddJobResponse, error)
CreateJob build AUR package
func (*AURBuild) WithDmanager ¶
WithDmanager use dmnager for uplaod
func (*AURBuild) WithoutCcache ¶
WithoutCcache disables ccache
type AddJobRequest ¶
type AddJobRequest struct {
Type JobType `json:"buildtype"`
Args map[string]string `json:"args"`
UploadType UploadType `json:"uploadtype"`
DisableCcache bool `json:"disableccache"`
}
AddJobRequest request for creating a new job
type AddJobResponse ¶
AddJobResponse response for adding a job
type Authorization ¶
type Authorization struct {
Type AuthorizationType
Palyoad string
}
Authorization the authorization params for a server request
type AuthorizationType ¶
type AuthorizationType string
AuthorizationType authorization type
const ( Bearer AuthorizationType = "Bearer" Basic AuthorizationType = "Basic" )
Authorizanion types
type ContentType ¶
type ContentType string
ContentType contenttype header of request
const (
JSONContentType ContentType = "application/json"
)
Content types
type CredentialsRequest ¶
type CredentialsRequest struct {
MachineID string `json:"mid,omitempty"`
Username string `json:"username"`
Password string `json:"pass"`
}
CredentialsRequest request containing credentials
type JobInfo ¶
type JobInfo struct {
ID uint `json:"id"`
Info string `json:"info"`
Position uint `json:"pos"`
BuildType JobType `json:"jobtype"`
UploadType UploadType `json:"uploadtype"`
Status JobState `json:"state"`
RunningSince time.Time `json:"rs,omitempty"`
Duration time.Duration `json:"dr"`
}
JobInfo info of job
type JobLogsRequest ¶
JobLogsRequest cancel a job
type LibRB ¶
type LibRB struct {
Config *RequestConfig
}
LibRB data required in all requests
func (LibRB) AddJob ¶
func (librb LibRB) AddJob(jobType JobType, uploadType UploadType, args map[string]string, disableCcache bool) (*AddJobResponse, error)
AddJob a job
func (LibRB) ClearCcache ¶
ClearCcache clear ccache on server
func (LibRB) ListJobs ¶
func (librb LibRB) ListJobs(limit int) (*ListJobsResponse, error)
ListJobs list running jobs
func (LibRB) Login ¶
func (librb LibRB) Login(username, password string) (*LoginResponse, error)
Login login into the server
func (LibRB) NewAURBuild ¶
NewAURBuild build an AUR package
func (*LibRB) NewRequest ¶
NewRequest creates a new post request
func (LibRB) Ping ¶
func (librb LibRB) Ping() (*StringResponse, error)
Ping pings a server the REST way to ensure it is reachable
func (LibRB) QueryCcache ¶
func (librb LibRB) QueryCcache() (StringResponse, error)
QueryCcache get ccache stats
func (LibRB) Register ¶
func (librb LibRB) Register(username, password string) (*RestRequestResponse, error)
Register create a new account. Return true on success
type ListJobsRequest ¶
type ListJobsRequest struct {
Limit int `json:"l"`
}
ListJobsRequest request for listing jobs
type ListJobsResponse ¶
type ListJobsResponse struct {
Jobs []JobInfo `json:"jobs"`
}
ListJobsResponse list of queued jobs
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
}
LoginResponse response for login
type Request ¶
type Request struct {
RequestType RequestType
Endpoint Endpoint
Payload interface{}
Config *RequestConfig
Method Method
ContentType ContentType
Authorization *Authorization
Headers map[string]string
BenchChan chan time.Time
CloseBody bool
}
Request a rest server request
func (*Request) BuildClient ¶
BuildClient return client
func (Request) Do ¶
func (request Request) Do(retVar interface{}) (*RestRequestResponse, error)
Do a better request method
func (*Request) DoHTTPRequest ¶
DoHTTPRequest do plain http request
func (*Request) WithAuth ¶
func (request *Request) WithAuth(a Authorization) *Request
WithAuth with authorization
func (*Request) WithAuthFromConfig ¶
WithAuthFromConfig with authorization
func (*Request) WithBenchCallback ¶
WithBenchCallback with bench
func (*Request) WithContentType ¶
func (request *Request) WithContentType(ct ContentType) *Request
WithContentType with contenttype
func (*Request) WithHeader ¶
WithHeader add header to request
func (*Request) WithMethod ¶
WithMethod use a different method
func (*Request) WithNoBodyClose ¶
WithNoBodyClose don't close body after request
func (*Request) WithRequestType ¶
func (request *Request) WithRequestType(rType RequestType) *Request
WithRequestType use different request type
type RequestConfig ¶
type RequestConfig struct {
IgnoreCert bool
URL string
MachineID string
Username string
SessionToken string
}
RequestConfig configurations for requests
func (RequestConfig) GetBearerAuth ¶
func (rc RequestConfig) GetBearerAuth() Authorization
GetBearerAuth returns bearer authorization from config
type RequestType ¶
type RequestType uint8
RequestType type of request
const ( JSONRequestType RequestType = iota RawRequestType )
Request types
type ResponseErr ¶
type ResponseErr struct {
Response *RestRequestResponse
Err error
}
ResponseErr response error
func NewErrorFromResponse ¶
func NewErrorFromResponse(r *RestRequestResponse, err ...error) *ResponseErr
NewErrorFromResponse return error from response
func (*ResponseErr) Error ¶
func (reserr *ResponseErr) Error() string
type ResponseStatus ¶
type ResponseStatus uint8
ResponseStatus the status of response
const ( // ResponseError if there was an error ResponseError ResponseStatus = 0 // ResponseSuccess if the response is successful ResponseSuccess ResponseStatus = 1 )
type RestRequestResponse ¶
type RestRequestResponse struct {
HTTPCode int
Status ResponseStatus
Message string
Headers *http.Header
Response *http.Response
}
RestRequestResponse the response of a rest call
type StringResponse ¶
type StringResponse struct {
String string `json:"content"`
}
StringResponse response containing only one string
type StringSliceResponse ¶
type StringSliceResponse struct {
Slice []string `json:"slice"`
}
StringSliceResponse response containing only one string slice
type UploadType ¶
type UploadType uint8
UploadType type of upload destination
const ( NoUploadType UploadType = iota DataManagerUploadType LocalStorage )
...
func ParseUploadType ¶
func ParseUploadType(s string) UploadType
ParseUploadType an uploadtype string
func (UploadType) String ¶
func (ut UploadType) String() string