apiclient

package
v0.0.0-...-4d3a7dc Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoGetBytes

func DoGetBytes(c Client, baseURL, path string, queryParams ...string) ([]byte, error)

DoGetBytes is a convenience function that is equivalent to calling NewGet, executing the resulting request using http.DefaultClient.Do, checking the status code and then reading the response body, returning the resulting byte slice.

func DoGetUnmarshal

func DoGetUnmarshal(resultPtr interface{}, c Client, baseURL, path string, queryParams ...string) error

DoGetUnmarshal is a convenience function that is equivalent to calling DoGetBytes and then unmarshalling the resulting byte array into the passed pointer.

func DoPostBytes

func DoPostBytes(c Client, baseURL, path string, bodyPtr interface{}, queryParams ...string) ([]byte, error)

func DoPostUnmarshal

func DoPostUnmarshal(resultPtr interface{}, c Client, baseURL, path string, bodyPtr interface{}, queryParams ...string) error

func DoRespAsBytes

func DoRespAsBytes(c Client, req *http.Request, bodyPtr interface{}, queryParams ...string) ([]byte, error)

func DoRespAsUnmarshalled

func DoRespAsUnmarshalled(c Client, resultPtr interface{}, req *http.Request, bodyPtr interface{}, queryParams ...string) error

func NewGet

func NewGet(c Client, baseURL, path string, queryParams ...string) (*http.Request, error)

NewGet creates a new HTTP GET request to the set provider URL's endpoint, specified with path, using Basic Auth.

Query parameters are interleaved like ( "name_1", "value_1", "name_2", "value_2" ).

func NewPost

func NewPost(c Client, baseURL, path string, bodyPtr interface{}, queryParams ...string) (*http.Request, error)

NewPost creates a new HTTP POST request to the set provider URL's endpoint, specified with path, using Basic Auth.

Query parameters are interleaved like ( "name_1", "value_1", "name_2", "value_2" ).

Types

type BaseClient

type BaseClient struct {
	Context context.Context
	Token   string
}

func NewClient

func NewClient(ctx context.Context, token string) *BaseClient

func (*BaseClient) GetContext

func (c *BaseClient) GetContext() context.Context

func (*BaseClient) GetToken

func (c *BaseClient) GetToken() string

func (*BaseClient) SetContext

func (c *BaseClient) SetContext(ctx context.Context)

func (*BaseClient) SetToken

func (c *BaseClient) SetToken(token string)

type Client

type Client interface {
	// GetContext gets the context for the client.
	//
	// This method is implemented by the BaseClient type for convenience.
	GetContext() context.Context
	// GetToken gets the token that is used when sending requests to the API.
	//
	// This method is implemented by the BaseClient type for convenience.
	GetToken() string
	// SetContext sets the context to use for the connection.
	//
	// This method is implemented by the BaseClient type for convenience.
	SetContext(ctx context.Context)
	// SetToken sets the token that is used when sending requests to the remote provider.
	//
	// This method is implemented by the BaseClient type for convenience.
	SetToken(token string)
}

type WharfBranch

type WharfBranch = database.Branch

WharfBranch is an alias for wharf-api's database.Branch.

type WharfProject

type WharfProject struct {
	database.Project
	RemoteProjectID string
}

WharfProject is an alias for wharf-api's database.Project. Currently using a hack to pretend that the RemoteProjectID addition has been merged.

func RequireProject

func RequireProject(c *gin.Context) (WharfProject, bool)

Jump to

Keyboard shortcuts

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