client

package
Version: v0.0.0-...-35ad754 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package client provides a generic client to be used by all services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config         *bluemix.Config
	DefaultHeader  gohttp.Header
	ServiceName    bluemix.ServiceName
	TokenRefresher TokenProvider
	// contains filtered or unexported fields
}

Client is the base client for all service api client

func New

func New(c *bluemix.Config, serviceName bluemix.ServiceName, refresher TokenProvider) *Client

New ...

func (*Client) Delete

func (c *Client) Delete(path string, extraHeader ...interface{}) (*gohttp.Response, error)

Delete ...

func (*Client) DeleteWithBody

func (c *Client) DeleteWithBody(path string, data interface{}, extraHeader ...interface{}) (*gohttp.Response, error)

DeleteWithBody ...

func (*Client) DeleteWithResp

func (c *Client) DeleteWithResp(path string, respV interface{}, extraHeader ...interface{}) (*gohttp.Response, error)

DeleteWithResp ...

func (*Client) Get

func (c *Client) Get(path string, respV interface{}, extraHeader ...interface{}) (*gohttp.Response, error)

Get ...

func (*Client) GetPaginated

func (c *Client) GetPaginated(path string, paginated PaginatedResourcesHandler, cb func(interface{}) bool) (resp *gohttp.Response, err error)

func (*Client) MakeRequest

func (c *Client) MakeRequest(r *rest.Request, respV interface{}) (*gohttp.Response, error)

MakeRequest ...

func (*Client) Patch

func (c *Client) Patch(path string, data interface{}, respV interface{}, extraHeader ...interface{}) (*gohttp.Response, error)

Patch ...

func (*Client) Post

func (c *Client) Post(path string, data interface{}, respV interface{}, extraHeader ...interface{}) (*gohttp.Response, error)

Post ...

func (*Client) PostWithForm

func (c *Client) PostWithForm(path string, form interface{}, respV interface{}, extraHeader ...interface{}) (*gohttp.Response, error)

PostWithForm ...

func (*Client) Put

func (c *Client) Put(path string, data interface{}, respV interface{}, extraHeader ...interface{}) (*gohttp.Response, error)

Put ...

func (*Client) SendRequest

func (c *Client) SendRequest(r *rest.Request, respV interface{}) (*gohttp.Response, error)

SendRequest ...

func (*Client) URL

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

URL ...

type Config

type Config struct {
	Config   *bluemix.Config
	Endpoint string
}

Config stores any generic service client configurations

type PaginatedResourcesHandler

type PaginatedResourcesHandler interface {
	Resources(rawResponse []byte, curPath string) (resources []interface{}, nextPath string, err error)
}

type TokenProvider

type TokenProvider interface {
	RefreshToken() (string, error)
	GetPasscode() (string, error)
	AuthenticatePassword(string, string) error
	AuthenticateAPIKey(string) error
}

TokenProvider ...

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL