api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthHTTPClient

func AuthHTTPClient(hostname string) *http.Client

AuthHTTPClient returns an authenticated HTTP client

func CurrentUserID

func CurrentUserID(client *Client, hostname string) (string, error)

func CurrentUserOrganizationID

func CurrentUserOrganizationID(client *Client, hostname string) (string, error)

CurrentUserOrganizationID returns the identifier of the default organization for the current logged in user

func CurrentUsername

func CurrentUsername(client *Client, hostname string) (string, error)

func HandleHTTPError

func HandleHTTPError(resp *http.Response) error

func NewHTTPClient

func NewHTTPClient(opts ...ClientOption) *http.Client

NewHTTPClient initializes an http.Client with a default timeout

func UnsecureHTTPClient

func UnsecureHTTPClient(hostname string) *http.Client

UnsecureHTTPClient returns a non-authenticated HTTP client

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client facilitates making HTTP requests to the Reliably API

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient initializes a Client

func NewClientFromHTTP

func NewClientFromHTTP(httpClient *http.Client) *Client

NewClientFromHTTP takes in an http.Client instance

func (Client) REST

func (c Client) REST(hostname string, method string, p string, body io.Reader, data interface{}) error

REST performs a REST request and parses the response.

type ClientOption

type ClientOption = func(http.RoundTripper) http.RoundTripper

ClientOption represents an argument to NewClient

func AddHeader

func AddHeader(name, value string) ClientOption

AddHeader turns a RoundTripper into one that adds a request header

func AddHeaderFunc

func AddHeaderFunc(name string, getValue func(*http.Request) (string, error)) ClientOption

AddHeaderFunc is an AddHeader that gets the string value from a function

type HTTPError

type HTTPError struct {
	StatusCode int
	RequestURL *url.URL
	Message    string
}

HTTPError is an error returned by a failed API call

func (HTTPError) Error

func (err HTTPError) Error() string

type Organization

type Organization struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	CreatedBy string `json:"created_by"`
}

Organization represents an Organization under Reliably

func CurrentUserOrganization

func CurrentUserOrganization(client *Client, hostname string) (*Organization, error)

CurrentUserOrganization returns the default organization of the current logged in user

func ListOrganizations

func ListOrganizations(client *Client, hostname string) ([]Organization, error)

ListOrganizations list all organizations to which the current logged in user is a member of

type UserInfo

type UserInfo struct {
	ID        string    `json:"id"`
	Username  string    `json:"username"`
	FullName  string    `json:"fullname"`
	Email     string    `json:"email"`
	LastLogin time.Time `json:"last_login"`
}

func CurrentUser

func CurrentUser(client *Client, hostname string) (*UserInfo, error)

Jump to

Keyboard shortcuts

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