Documentation
¶
Overview ¶
Doze is a library that wraps the resty golang library to more closely focus its API for us in writing small and quick REST wrappers for use in terraform provider plugins. Additionally, it provides a test module to make testing the REST APIs you write easier when a given platform does *not* provide a sandbox API to test against
Usage ¶
The doze package is designed to be used with go modules enabled only.
import "occult.work/doze" import "occult.work/doze/test"
Examples:
Construct a Client, then get a Request object to perform requests with.
client := doze.NewClient(). SetTimeout(time.Duration(1 * time.Minute)). SetAuthScheme("Basic"). SetAuthToken(token). SetHostURL(BaseURL). SetError(&Error{}) request = client.Request(ctx, &ReturnType{})
Index ¶
- type Client
- func (client *Client) Request(ctx context.Context, result interface{}) *Request
- func (client *Client) SetAuthScheme(scheme string) *Client
- func (client *Client) SetAuthToken(token string) *Client
- func (client *Client) SetBaseURL(url string) *Client
- func (client *Client) SetDebug() *Client
- func (client *Client) SetError(error interface{}) *Client
- func (client *Client) SetUserAgent(agent string) *Client
- func (client *Client) ToResty() *resty.Client
- type Request
- func (r *Request) Context() context.Context
- func (request *Request) Delete(url string) (interface{}, error)
- func (request *Request) Get(url string) (interface{}, error)
- func (request *Request) Patch(url string) (interface{}, error)
- func (request *Request) Post(url string) (interface{}, error)
- func (request *Request) Put(url string) (interface{}, error)
- func (r *Request) SetBody(body interface{}) *Request
- func (r *Request) SetContentLength() *Request
- func (r *Request) SetHeader(header, value string) *Request
- func (r *Request) SetPathParameter(parameter, value string) *Request
- func (r *Request) SetQueryParameter(parameter, value string) *Request
- type Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client resty.Client
func (*Client) SetAuthScheme ¶
func (*Client) SetAuthToken ¶
func (*Client) SetBaseURL ¶
func (*Client) SetUserAgent ¶
type Request ¶
type Request resty.Request
func (*Request) SetContentLength ¶
func (*Request) SetPathParameter ¶
func (*Request) SetQueryParameter ¶
type Time ¶
Used to represent a time point
func (Time) MarshalJSON ¶
Serializes the time into a unix timestamp
func (*Time) UnmarshalJSON ¶
Deserializes an int64 a Time point
Click to show internal directories.
Click to hide internal directories.