client

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const RedactedFillin = "[REDACTED]"

RedactedFillin used as a replacement string in debug logs for sensitive data

Variables

View Source
var ErrAuthenticationRequired = errors.New("Authentication token required")

ErrAuthenticationRequired is returned if a request is made before an authentication token has been provided to the client

Functions

This section is empty.

Types

type BodyProvider

type BodyProvider interface {
	ContentType() string
	Body() (io.Reader, error)
}

BodyProvider declares an interface that describes an HTTP body, for both request and response

type Operation

type Operation struct {
	Name        string
	Method      string
	PathPattern string
}

Operation defines the API operation to be invoked

type Params

type Params map[string]string

Params ...

func (Params) Copy

func (p Params) Copy() Params

Copy performs a shallow copy of a Params object

type Request

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

Request defines the properties of an API request. It can then be invoked to call the underlying API specified by the supplied operation

func (*Request) AddQueryValue

func (r *Request) AddQueryValue(key, value string) *Request

AddQueryValue ...

func (*Request) Invoke

func (r *Request) Invoke() (*http.Response, error)

Invoke performs the request, and populates the response or error as appropriate

func (*Request) JSONBody

func (r *Request) JSONBody(p interface{}) *Request

JSONBody converts the supplied argument to JSON to use as the body of a request

func (*Request) JSONError

func (r *Request) JSONError(receiver error) *Request

JSONError configures the error to populate in the event of an unsuccessful (non-2xx) response

func (*Request) JSONSuccess

func (r *Request) JSONSuccess(receiver interface{}) *Request

JSONSuccess configures the receiver to use to process a JSON response for a successful (2xx) response

func (*Request) MultipartFileBody

func (r *Request) MultipartFileBody(name string, contents io.Reader) *Request

MultipartFileBody configures the POST payload to be sent in multi-part format. The content is read from the supplied Reader.

func (*Request) PathParameter

func (r *Request) PathParameter(name, value string) *Request

PathParameter sets a path parameter to be resolved on invocation of a request

func (*Request) URL

func (r *Request) URL() string

URL constructs the full URL for a request

type ResponseConsumer

type ResponseConsumer interface {
	Consume(io.Reader) error
	Receiver() interface{}
}

ResponseConsumer ...

type SessionClient

type SessionClient interface {
	NewRequest(operation *Operation) *Request
	WithDebug(writer io.Writer) SessionClient
	WithAuthToken(authToken string) SessionClient
	WithPathParameter(name, value string) SessionClient
	WithQueryValue(name, value string) SessionClient
}

SessionClient provides an interface for a REST API client go:generate counterfeiter -o fakes/client.go --fake-name SessionClient . SessionClient

func New

func New(ctx context.Context, baseURL string, httpClient *http.Client, contextID string, APIVersion string) SessionClient

New creates a new instance of a SessionClient

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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