api

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 9 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(_ 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).

func SetCustomImageGitHost added in v0.7.0

func SetCustomImageGitHost(host string) ClientOpt

SetCustomImageGitHost overrides the GitLab host used by custom image helpers when constructing repository clone URLs. Default is "gitlab-clients.sitehost.co.nz".

Directories

Path Synopsis
accounts
client
Package client wraps the /accounts/client API endpoints — currently just /accounts/client/list_sub_accounts.json, the paginated list of sub-accounts under the calling client_id (reseller / parent-account view).
Package client wraps the /accounts/client API endpoints — currently just /accounts/client/list_sub_accounts.json, the paginated list of sub-accounts under the calling client_id (reseller / parent-account view).
Package bandwidth represents the SiteHost `/bandwidth` API endpoint.
Package bandwidth represents the SiteHost `/bandwidth` API endpoint.
cloud
db
Package db provides access to the `/cloud/db` API endpoint.
Package db provides access to the `/cloud/db` API endpoint.
db/grant
Package grant is used for interacting with the SiteHost `/cloud/db/grant` API endpoint.
Package grant is used for interacting with the SiteHost `/cloud/db/grant` API endpoint.
db/user
Package user represents the SiteHost `/cloud/db/user` API endpoint.
Package user represents the SiteHost `/cloud/db/user` API endpoint.
image
Package image provides access to the `/cloud/image` API endpoint.
Package image provides access to the `/cloud/image` API endpoint.
image/version
Package version provides access to the /cloud/image/version endpoints — listing build history for a custom image, fetching build logs, and deleting individual versions.
Package version provides access to the /cloud/image/version endpoints — listing build history for a custom image, fetching build logs, and deleting individual versions.
server
Package server provides access to the `/cloud/stack/server` API endpoint.
Package server provides access to the `/cloud/stack/server` API endpoint.
ssh/user
Package user provides access to the `/cloud/ssh/user` API endpoint.
Package user provides access to the `/cloud/ssh/user` 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.
stack/image
Package image provides access to the `/cloud/stack/image` API endpoint.
Package image provides access to the `/cloud/stack/image` API endpoint.
stack/ssl/letsencrypt
Package letsencrypt wraps SiteHost's Cloud-Container Let's Encrypt endpoints under /cloud/stack/ssl/lets_encrypt.
Package letsencrypt wraps SiteHost's Cloud-Container Let's Encrypt endpoints under /cloud/stack/ssl/lets_encrypt.
volume
Package volume represents our SiteHost `/cloud/volume` API endpoint — persistent volumes that can be attached to cloud containers.
Package volume represents our SiteHost `/cloud/volume` API endpoint — persistent volumes that can be attached to cloud containers.
dns
Package dns represents our SiteHost `/dns` API endpoint.
Package dns represents our SiteHost `/dns` API endpoint.
template
Package template represents our SiteHost `/dns/domain_templates` API endpoint.
Package template represents our SiteHost `/dns/domain_templates` API endpoint.
Package info wraps SiteHost's /api/* endpoints.
Package info wraps SiteHost's /api/* endpoints.
Package job represents our SiteHost `/job` endpoint
Package job represents our SiteHost `/job` endpoint
Package mail represents our SiteHost `/mail` API endpoint — shared mail service inspection (server info, domains, accounts, aliases, forwarders).
Package mail represents our SiteHost `/mail` API endpoint — shared mail service inspection (server info, domains, accounts, aliases, forwarders).
Package redirect wraps the /redirect API endpoint — currently just /redirect/list_redirects.json, the per-account inventory of HTTP redirect rules grouped by domain.
Package redirect wraps the /redirect API endpoint — currently just /redirect/list_redirects.json, the per-account inventory of HTTP redirect rules grouped by domain.
Package server wraps the SiteHost /server API endpoints — the VPS / Cloud Container Server lifecycle: provision, get, list, upgrade, snapshot, etc.
Package server wraps the SiteHost /server API endpoints — the VPS / Cloud Container Server lifecycle: provision, get, list, upgrade, snapshot, etc.
firewall
Package firewall represents our SiteHost `/server/firewall` API endpoint.
Package firewall represents our SiteHost `/server/firewall` API endpoint.
firewall/securitygroups
Package securitygroups represents our SiteHost `/server/firewall/security_groups` API endpoint.
Package securitygroups represents our SiteHost `/server/firewall/security_groups` API endpoint.
snapshot
Package snapshot represents our SiteHost `/server/snapshot` API endpoint — server-level disk snapshot management (list, create, delete, restore, lifetime).
Package snapshot represents our SiteHost `/server/snapshot` API endpoint — server-level disk snapshot management (list, create, delete, restore, lifetime).
Package srs wraps the SiteHost /srs API — domain registration, transfer, contacts, and lifecycle ops via the Shared Registry System.
Package srs wraps the SiteHost /srs API — domain registration, transfer, contacts, and lifecycle ops via the Shared Registry System.
ssh
key
Package key represents our SiteHost `/ssh/key` API endpoint.
Package key represents our SiteHost `/ssh/key` API endpoint.
Package ssl represents our SiteHost `/ssl` API endpoint.
Package ssl represents our SiteHost `/ssl` API endpoint.

Jump to

Keyboard shortcuts

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