Documentation
¶
Index ¶
- Variables
- type BasicAuth
- type QueryInterface
- type RESTClient
- func (c *RESTClient) Delete() *Request
- func (c *RESTClient) Get() *Request
- func (c *RESTClient) GetHeaders() map[string]string
- func (c *RESTClient) GetToken() string
- func (c *RESTClient) Patch() *Request
- func (c *RESTClient) Post() *Request
- func (c *RESTClient) Put() *Request
- func (c *RESTClient) SetToken(token string)
- type Request
- func (r *Request) APIPrefix(apiPrefix string) *Request
- func (r *Request) APIVersion(APIVersion string) *Request
- func (r *Request) Body(obj interface{}) *Request
- func (r *Request) Do() *Response
- func (r *Request) Name(name string) *Request
- func (r *Request) Project(project string) *Request
- func (r *Request) Query(query QueryInterface) *Request
- func (r *Request) Resource(resource string) *Request
- type RequestError
- type Response
- type RestConfigClient
Constants ¶
This section is empty.
Variables ¶
var ( RequestInternalError = &RequestError{Message: "internal server error", StatusCode: http.StatusInternalServerError} RequestNotFoundError = &RequestError{Message: "document not found", StatusCode: http.StatusNotFound} )
Functions ¶
This section is empty.
Types ¶
type BasicAuth ¶
type QueryInterface ¶
QueryInterface defines the query interface that you can set in the Request
type RESTClient ¶
type RESTClient struct {
// base is the root URL for all invocations of the client
BaseURL *url.URL
// Set specific behavior of the client. If not set http.DefaultClient will be used.
Client *http.Client
// contains filtered or unexported fields
}
RESTClient defines an HTTP client designed for the HTTP request to a REST API.
func NewFromConfig ¶
func NewFromConfig(config RestConfigClient) (*RESTClient, error)
NewFromConfig create an instance of RESTClient using the config passed as parameter
func (*RESTClient) Delete ¶
func (c *RESTClient) Delete() *Request
Delete begins a Delete request. Short for c.newRequest("DELETE")
func (*RESTClient) Get ¶
func (c *RESTClient) Get() *Request
Get begins a GET request. Short for c.newRequest("GET")
func (*RESTClient) GetHeaders ¶
func (c *RESTClient) GetHeaders() map[string]string
GetHeaders gets the headers
func (*RESTClient) Patch ¶
func (c *RESTClient) Patch() *Request
Patch begins a Patch request. Short for c.newRequest("PATCH")
func (*RESTClient) Post ¶
func (c *RESTClient) Post() *Request
Post begins a Post request. Short for c.newRequest("POST")
func (*RESTClient) Put ¶
func (c *RESTClient) Put() *Request
Put begins a Put request. Short for c.newRequest("PUT")
func (*RESTClient) SetToken ¶
func (c *RESTClient) SetToken(token string)
SetToken set the token (thread safe)
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request allows for building up a request to a server in a chained fashion. Any errors are stored until the end of your call, so you only have to check once.
func NewRequest ¶
func NewRequest(client *http.Client, method string, baseURL *url.URL, token string, basicAuth *BasicAuth, headers map[string]string) *Request
NewRequest creates a new request helper object for accessing resource on a the API
func (*Request) APIVersion ¶
APIVersion set the api version to used (default v1)
func (*Request) Do ¶
Do build the query and execute it. The error and/or the response from the server are set in the object Response
func (*Request) Project ¶
Project set the project where the resource must be defined. It cannot be used at the same time with Request.Area
func (*Request) Query ¶
func (r *Request) Query(query QueryInterface) *Request
Query set all queryParameter contains in the query passed as a parameter
type RequestError ¶
RequestError is a format struct to defines the error the results of calling #Request.Do()
func (*RequestError) Error ¶
func (re *RequestError) Error() string
func (*RequestError) Unwrap ¶
func (re *RequestError) Unwrap() error
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response contains the result of calling #Request.Do()
type RestConfigClient ¶
type RestConfigClient struct {
URL string `json:"url" yaml:"url"`
InsecureTLS bool `json:"insecure_tls,omitempty" yaml:"insecure_tls,omitempty"`
Token string `json:"token,omitempty" yaml:"token,omitempty"`
BasicAuth *BasicAuth `json:"basic_auth,omitempty" yaml:"basic_auth,omitempty"`
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
}
RestConfigClient defines all parameter that can be set to customize the RESTClient