client

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2019 License: Apache-2.0 Imports: 12 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	NetworkDNS          network.DNSBackend
	NetworkLoadBalancer network.LoadBalancerBackend
	NetworkVIP          network.VIPBackend
	NetworkZone         network.ZoneBackend
	StorageBlockVolume  storage.BlockVolumeBackend

	StormConfig storm.ConfigBackend
	StormServer storm.ServerBackend
}

API is the structure that houses all of our various API clients that interact with various Storm resources.

func NewAPI

func NewAPI(username string, password string, url string, timeout int) (*API, error)

NewAPI is the API client for interacting with Storm.

type Client

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

Client provides the HTTP backend.

func NewClient

func NewClient(config *Config) *Client

NewClient returns a prepared API client.

func (*Client) Call

func (client *Client) Call(method string, params interface{}, into interface{}) error

Call takes a path, such as "network/zone/details" and a params structure. It is recommended that the params be a map[string]interface{}, but you can use anything that serializes to the right json structure. A `interface{}` and an error are returned, in typical go fasion.

Example:

args := map[string]interface{}{
	"uniq_id": "ABC123",
}
got, gotErr := apiClient.Call("bleed/asset/details", args)
if gotErr != nil {
	panic(gotErr)
}

func (*Client) CallRaw

func (client *Client) CallRaw(method string, params interface{}) ([]byte, error)

CallRaw is just like Call, except it returns the raw json as a byte slice. However, in contrast to Call, CallRaw does *not* check the API response for LiquidWeb specific exceptions as defined in the type LWAPIError. As such, if calling this function directly, you must check for LiquidWeb specific exceptions yourself.

Example:

args := map[string]interface{}{
	"uniq_id": "ABC123",
}
got, gotErr := apiClient.CallRaw("bleed/asset/details", args)
if gotErr != nil {
	panic(gotErr)
}
// Check got now for LiquidWeb specific exceptions, as described above.

type Config

type Config struct {
	Username  string
	Password  string
	URL       *url.URL
	Timeout   int
	SecureTLS bool
}

Config is the configuration for the API client.

func NewConfig

func NewConfig(username string, password string, apiURL string, timeout int, secureTLS bool) (*Config, error)

NewConfig builds a new Config.

Jump to

Keyboard shortcuts

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