api

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 8 Imported by: 3

Documentation

Overview

Package api provides the functions to work with SiteHost API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response, data []byte) error

CheckResponse checks the API response for errors, and returns them if present.

A response is considered an error if it has a status code outside the 200 range or if the Status is false.

Types

type Client

type Client struct {
	models.ClientBase
	// contains filtered or unexported fields
}

Client is a wrapper around the http client to manages communication with SiteHost API.

func New

func New(apiKey, clientID string, opts ...ClientOpt) (*Client, error)

New returns a new SiteHost API client instance.

func NewClient

func NewClient(apiKey, clientID string) *Client

NewClient factory to create new Client struct.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) error

Do sends an API Request and returns the response.

The API response is checked to see if it was a successful call. A successful call is then checked to see if we have a Status true.

func (*Client) NewRequest

func (c *Client) NewRequest(method, uri string, body string) (*http.Request, error)

NewRequest creates an SiteHost API Request.

type ClientOpt

type ClientOpt func(*Client) error

ClientOpt function parameters to configure a Client.

func SetBaseURL

func SetBaseURL(bu string) ClientOpt

SetBaseURL change the default BaseURL (Include the API version).

Directories

Path Synopsis
cloud
image
Package image provides access to the `/cloud/image` API endpoint.
Package image provides access to the `/cloud/image` API endpoint.
server
Package server provides access to the `/cloud/stack/server` API endpoint.
Package server provides access to the `/cloud/stack/server` API endpoint.
stack
Package stack represents a cloud stack operations under the `/cloud/stack` API endpoint.
Package stack represents a cloud stack operations under the `/cloud/stack` API endpoint.
stack/environment
Package environment represents a cloud stack environment operations under the `/cloud/stack/environment` API endpoint.
Package environment represents a cloud stack environment operations under the `/cloud/stack/environment` API endpoint.
Package dns represents our SiteHost `/dns` API endpoint.
Package dns represents our SiteHost `/dns` API endpoint.
Package info represents our SiteHost `/api` API endpoint.
Package info represents our SiteHost `/api` API endpoint.
Package job represents our SiteHost `/job` endpoint
Package job represents our SiteHost `/job` endpoint
Package server represents our SiteHost `/server` API endpoint.
Package server represents our SiteHost `/server` API endpoint.
ssh
key
Package key represents our SiteHost `/ssh/key` API endpoint.
Package key represents our SiteHost `/ssh/key` API endpoint.

Jump to

Keyboard shortcuts

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