doze

package module
v0.0.0-...-fb7eeee Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2023 License: MIT Imports: 5 Imported by: 2

README

Archived

Date Reason
2023-01-06 No longer using golang as primary language

Overview

Go Reference Build and Tests Code Coverage

go-doze is a wrapper around the resty golang library to more closely focus its API for use in writing small and quick REST wrappers to eventually be used in terraform provider plugins.

It also comes with a small wrapper test suite to make testing the REST APIs you write easier.

Installation

Simply call

$ go get occult.work/doze

from your shell of choice, and go modules will take care of the rest.

Development

go-doze uses task to run the most common operations. These tasks are then duplicated with extra flags within the GitHub Actions workflow.

Task has instructions on installation. Once installed, simply run task from the project directory.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client resty.Client

func NewClient

func NewClient() *Client

func (*Client) Request

func (client *Client) Request(ctx context.Context, result interface{}) *Request

func (*Client) SetAuthScheme

func (client *Client) SetAuthScheme(scheme string) *Client

func (*Client) SetAuthToken

func (client *Client) SetAuthToken(token string) *Client

func (*Client) SetBaseURL

func (client *Client) SetBaseURL(url string) *Client

func (*Client) SetDebug

func (client *Client) SetDebug() *Client

func (*Client) SetError

func (client *Client) SetError(error interface{}) *Client

func (*Client) SetUserAgent

func (client *Client) SetUserAgent(agent string) *Client

func (*Client) ToResty

func (client *Client) ToResty() *resty.Client

Casts the client to its original underlying type. This will eventually be removed once the general surface area that is actually needed for doze is known.

type Request

type Request resty.Request

func (*Request) Context

func (r *Request) Context() context.Context

func (*Request) Delete

func (request *Request) Delete(url string) (interface{}, error)

func (*Request) Get

func (request *Request) Get(url string) (interface{}, error)

func (*Request) Patch

func (request *Request) Patch(url string) (interface{}, error)

func (*Request) Post

func (request *Request) Post(url string) (interface{}, error)

func (*Request) Put

func (request *Request) Put(url string) (interface{}, error)

func (*Request) SetBody

func (r *Request) SetBody(body interface{}) *Request

func (*Request) SetContentLength

func (r *Request) SetContentLength() *Request

func (*Request) SetHeader

func (r *Request) SetHeader(header, value string) *Request

func (*Request) SetPathParameter

func (r *Request) SetPathParameter(parameter, value string) *Request

func (*Request) SetQueryParameter

func (r *Request) SetQueryParameter(parameter, value string) *Request

type Time

type Time time.Time

Used to represent a time point

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

Serializes the time into a unix timestamp

func (*Time) Unix

func (t *Time) Unix() int64

Returns the unix timestamp as an int64

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

Deserializes an int64 a Time point

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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