client

package
v0.0.0-...-c1abbfc Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: LGPL-2.1 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBearerAuthRoundTrippers

func NewBearerAuthRoundTrippers(username string, pass string, nextRT http.RoundTripper) http.RoundTripper

NewBearerAuthRoundTrippers applies a Authorization header to a request with value set as bearer token formed using given username and password. It wraps a http Roundtripper

func NewTLSConfig

func NewTLSConfig(opts *TLSOptions) (*tls.Config, error)

NewTLSConfig returns TLS configuration meant to be used by Gluster-Block rest client

Types

type Client

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

Client is concrete instance implementing the GlusterBlockClient interface

func NewClientWithOpts

func NewClientWithOpts(baseURL string, optFuncs ...OptFuncs) (*Client, error)

NewClientWithOpts initializes a default GlusterBlockClient with host addr set as provided baseURL. It takes functors to modify its members while creating.

func (*Client) APIVersion

func (c *Client) APIVersion(ver string) *Client

APIVersion sets api version for a request

func (*Client) BlockVolumeInfo

func (c *Client) BlockVolumeInfo(hostvolume, blockname string) (*api.BlockVolumeInfoResponse, error)

BlockVolumeInfo gives info about a given block volume

func (*Client) CreateBlockVolume

func (c *Client) CreateBlockVolume(hostvolume, blockname string, req *api.BlockVolumeCreateReq) (*api.BlockVolumeCreateResp, error)

CreateBlockVolume creates a block volume

func (*Client) DeleteBlockVolume

func (c *Client) DeleteBlockVolume(hostvolume, blockname string, req *api.BlockVolumeDeleteReq) error

DeleteBlockVolume deletes a block volume

func (*Client) Do

func (c *Client) Do(reqBody interface{}, successV interface{}) error

Do sends an HTTP request and decode the response in successV if status code lies in [200,400). An error is returned if server responds with error or status code does not lies in [200,400)

func (*Client) ListBlockVolumes

func (c *Client) ListBlockVolumes(hostvolume string) (*api.BlockVolumeListResponse, error)

ListBlockVolumes will list all block volumes present in given hosting volume

func (*Client) Path

func (c *Client) Path(path string) *Client

Path sets http path for a request

func (*Client) Verb

func (c *Client) Verb(method string) *Client

Verb will set http Method for a request

type ErrorResponse

type ErrorResponse struct {
	*api.ErrorResp
	HTTPStatusCode int `json:"http_status_code"`
}

ErrorResponse embeds server error response schema with returned http status code It implements `error` interface

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Error returns json representation of ErrorResponse

type GlusterBlockClient

type GlusterBlockClient interface {
	CreateBlockVolume(hostvolume string, blockname string, req *api.BlockVolumeCreateReq) (*api.BlockVolumeCreateResp, error)
	DeleteBlockVolume(hostvolume string, blockname string, req *api.BlockVolumeDeleteReq) error
	ListBlockVolumes(hostvolume string) (*api.BlockVolumeListResponse, error)
	BlockVolumeInfo(hostvolume string, blockname string) (*api.BlockVolumeInfoResponse, error)
}

GlusterBlockClient is an interface for all block operations method

type OptFuncs

type OptFuncs func(*Client) error

OptFuncs receives a Client and overrides its members It will set the optional parameter of Client while creating

func WithAuth

func WithAuth(username string, password string) OptFuncs

WithAuth set username and password in client to be used for rest authentication

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) OptFuncs

WithHTTPClient overrides http Client with specified one.

func WithTLSConfig

func WithTLSConfig(tlsOpts *TLSOptions) OptFuncs

WithTLSConfig applies tls config to underlying http.Client Transport

func WithTimeOut

func WithTimeOut(timeout time.Duration) OptFuncs

WithTimeOut overrides Client timeout with specified one

type TLSOptions

type TLSOptions struct {
	CaCertFile         string
	InsecureSkipVerify bool
}

TLSOptions holds the TLS configurations information needed to create Gluster-Block rest client .

Jump to

Keyboard shortcuts

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