Documentation ¶
Index ¶
- func RemoveAllProjTokens(p *config.Profile) error
- type AuthToken
- type Client
- type Request
- func (r *Request) BasicAuth(username string, password string) *Request
- func (r *Request) Body(content interface{}) *Request
- func (r *Request) BodyStream(stream io.Reader) *Request
- func (r *Request) DumpRequest(dumpFlag bool) *Request
- func (r *Request) DumpResponse(dumpFlag bool) *Request
- func (r *Request) Execute() (*Response, error)
- func (r *Request) Expect(statusCode int) *Request
- func (r *Request) Param(name, value string) *Request
- func (r *Request) ParamBool(name string, value bool) *Request
- func (r *Request) ParamInt(name string, value int) *Request
- func (r *Request) ParamInt64(name string, value int64) *Request
- func (r *Request) ParamUint(name string, value uint) *Request
- func (r *Request) ParamUint64(name string, value uint64) *Request
- func (r *Request) ProjectToken(p *config.Profile, id uint64) *Request
- func (r *Request) ResponseBody(content interface{}) *Request
- func (r *Request) ResponseBodyHandler(handler ResponseBodyHandler) *Request
- func (r *Request) ResponseHeader(headerPtr **http.Header) *Request
- func (r *Request) UserToken(p *config.Profile) *Request
- type Response
- type ResponseBodyHandler
- type ResponseBodyReader
- type RestError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveAllProjTokens ¶ added in v0.7.4
Types ¶
type AuthToken ¶
type AuthToken struct { Token string Expires string UserId uint64 `json:"user_id,omitempty"` ProjectId uint64 `json:"project_id,omitempty"` Read bool `json:",omitempty"` Write bool `json:",omitempty"` Admin bool `json:",omitempty"` }
AuthToken is a representation of both user and project tokens. It contains for all tokens the actual token string and when it expires. For user tokens it also contains the userID it pertains to. For project tokens it contains the projectID it pertains to, as well as its permissions.
func ReadProjToken ¶
ReadProjToken fetches the project token for a particular id from the disk, if it exists.
func ReadUserToken ¶
ReadUserToken fetches the user token that is stored on disk, if it exists.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a http.Client that will be used to talk to a server running the iobeam API.
func NewClient ¶
NewClient returns a new HTTP client capable of communicating with a server running the iobeam API. The server address is passed via target.
func (*Client) Delete ¶
Delete returns a new Request with HTTP method of Delete for the supplied resource.
func (*Client) Patch ¶
Patch returns a new Request with HTTP method of Patch for the supplied resource.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is an API HTTP request to the iobeam backend.
func NewRequest ¶
NewRequest creates a new API request to iobeam. It takes a *Client that handles the actual execution, a string for the HTTP method, and a string for the API path.
func (*Request) BasicAuth ¶
BasicAuth sets the username and password to use in case of Basic authentication on the API endpoint. It returns the *Request so it can be chained.
func (*Request) Body ¶
Body sets the HTTP body of the *Request. It assumes the content can be serialized to JSON. It returns the *Request so it can be chained.
func (*Request) BodyStream ¶ added in v0.7.0
BodyStream sets the stream to use for HTTP body of the *Request. Content is assumed to be an octet-stream. It returns the *Request so it can be chained.
func (*Request) DumpRequest ¶ added in v0.8.0
DumpRequest sets whether the request should be dumped to stdout. It returns the *Request so it can be chained.
func (*Request) DumpResponse ¶ added in v0.8.0
DumpResponse sets whether the response should be dumped to stdout. It returns the *Request so it can be chained.
func (*Request) Execute ¶
Execute causes the API request to be carried out, returning a *Response and possibly an error.
func (*Request) Expect ¶
Expect sets the HTTP status code value that the executed r should expect. It returns the *Request so it can be chained.
func (*Request) Param ¶
Param adds a query parameter to the *Request whose value is a string. It returns the *Request so it can be chained.
func (*Request) ParamBool ¶
ParamBool adds a query parameter to the *Request whose value is a bool. It returns the *Request so it can be chained.
func (*Request) ParamInt ¶
ParamInt adds a query parameter to the *Request whose value is an int. It returns the *Request so it can be chained.
func (*Request) ParamInt64 ¶
ParamInt64 adds a query parameter to the *Request whose value is an int64. It returns the *Request so it can be chained.
func (*Request) ParamUint ¶
ParamUint adds a query parameter to the *Request whose value is a uint. It returns the *Request so it can be chained.
func (*Request) ParamUint64 ¶
ParamUint64 adds a query parameter to the *Request whose value is a uint64. It returns the *Request so it can be chained.
func (*Request) ProjectToken ¶
ProjectToken returns a Request with the project token set. If the token is expired, an attempt to refresh the token is made. It returns the *Request so it can be chained.
func (*Request) ResponseBody ¶
ResponseBody sets the object where the *Request's response should be stored. It returns the *Request so it can be chained.
func (*Request) ResponseBodyHandler ¶
func (r *Request) ResponseBodyHandler(handler ResponseBodyHandler) *Request
ResponseBodyHandler sets the ResponseBodyHandler to use when the request returns. It returns the *Request so it can be chained.
func (*Request) ResponseHeader ¶ added in v0.8.0
ResponseHeader sets a pointer that will be directed to the response header. It returns the *Request so it can be chained.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func NewResponse ¶
type ResponseBodyHandler ¶
type ResponseBodyHandler func(responseBody interface{}) error
ResponseBodyHandler is a function called when an API request returns. The function takes an interface{} (usually converted to JSON) and returns an error.