client

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const HTTPSScheme = "https"

HTTPSScheme is a scheme for HTTPS.

View Source
const HTTPScheme = "http"

HTTPScheme is a scheme for HTTP.

View Source
const TCPScheme = "tcp"

TCPScheme is a scheme for TCP.

View Source
const UnixScheme = "unix"

UnixScheme is a scheme for unix.

Variables

This section is empty.

Functions

func GenTLSConfig

func GenTLSConfig(key, cert, ca string) (*tls.Config, error)

GenTLSConfig returns a tls config object according to inputting parameters.

func NewHTTPClient

func NewHTTPClient(u *url.URL, tlsConfig *tls.Config, dialTimeout time.Duration) *http.Client

NewHTTPClient creates a http client using url and tlsconfig

func ParseHost

func ParseHost(host string) (*url.URL, string, string, error)

ParseHost inputs a host address string, and output four type: url.URL, basePath, address without scheme and an error.

Types

type APIClient

type APIClient struct {
	HTTPCli *http.Client
	// contains filtered or unexported fields
}

APIClient is a API client that performs all operations against a server

func (*APIClient) BaseURL

func (client *APIClient) BaseURL() string

BaseURL returns the base URL of APIClient

func (*APIClient) GetAPIPath

func (client *APIClient) GetAPIPath(path string, query url.Values) string

GetAPIPath returns the versioned request path to call the api. It appends the query parameters to the path if they are not empty.

func (*APIClient) PeerCreate

func (client *APIClient) PeerCreate(ctx context.Context, config *types.PeerCreateRequest) (*types.PeerCreateResponse, error)

PeerCreate creates a peer node in supernode.

func (*APIClient) PeerDelete

func (client *APIClient) PeerDelete(ctx context.Context, id string) error

PeerDelete deletes the specified peer in supernode.

func (*APIClient) PeerInfo

func (client *APIClient) PeerInfo(ctx context.Context, id string) (*types.PeerInfo, error)

PeerInfo gets detailed information of a peer in supernode.

func (*APIClient) PeerList

func (client *APIClient) PeerList(ctx context.Context, id string) ([]*types.PeerInfo, error)

PeerList lists detailed information of all peers in supernode.

func (*APIClient) Ping

func (client *APIClient) Ping(ctx context.Context) (string, error)

Ping sends a _ping request to supernode to see if it's working.

func (*APIClient) PreheatCreate

func (client *APIClient) PreheatCreate(ctx context.Context, config *types.PreheatCreateRequest) (*types.PreheatCreateResponse, error)

PreheatCreate creates a preheat task.

func (*APIClient) PreheatInfo

func (client *APIClient) PreheatInfo(ctx context.Context, id string) (*types.PreheatInfo, error)

PreheatInfo get detailed information of a preheat task.

func (*APIClient) PreheatList

func (client *APIClient) PreheatList(ctx context.Context, id string) ([]*types.PreheatInfo, error)

PreheatList lists detailed information of preheat tasks.

func (*APIClient) UpdateClientVersion

func (client *APIClient) UpdateClientVersion(v string)

UpdateClientVersion sets client version new value.

type CommonAPIClient

type CommonAPIClient interface {
	PreheatAPIClient
}

CommonAPIClient defines common methods of api client

func NewAPIClient

func NewAPIClient(host string, tls TLSConfig) (CommonAPIClient, error)

NewAPIClient initializes a new API client for the given host

type PreheatAPIClient

type PreheatAPIClient interface {
	PreheatCreate(ctx context.Context, config *types.PreheatCreateRequest) (*types.PreheatCreateResponse, error)
}

PreheatAPIClient defines methods of Container client.

type RespError

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

RespError defines the response error.

func (RespError) Code

func (e RespError) Code() int

Code returns the response code

func (RespError) Error

func (e RespError) Error() string

Error implements the error interface.

type Response

type Response struct {
	StatusCode int
	Status     string
	Body       io.ReadCloser
}

Response wraps the http.Response and other states.

type TLSConfig

type TLSConfig struct {
	CA               string `json:"tlscacert,omitempty"`
	Cert             string `json:"tlscert,omitempty"`
	Key              string `json:"tlskey,omitempty"`
	VerifyRemote     bool   `json:"tlsverify,omitempty"`
	ManagerWhiteList string `json:"manager-whitelist,omitempty"`
}

TLSConfig contains information of tls which users can specify

Jump to

Keyboard shortcuts

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