cpanelgo

package module
v0.0.0-...-ba27fde Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 6 Imported by: 0

README

cPanel api in Go

GoDoc

About

This is a simple cPanel api written in go.

Currently four intefaces are implemented,

  • CGI cPanel LiveApi - Designed for use in plugins, this interface will work through the preauthenticated CGI LiveApi environment as documented here (UAPI/API2/API1)
  • Authenticated JSON cPanel API (UAPI/API2/API1)
  • WHM (WHMAPI1)
  • WHM Impersonation to call cPanel API (UAPI/API2/API1)

Example

A simple command line example is provided in the example folder.

About

This API forms part of the Let's Encrypt for cPanel plugin which allows cPanel/WHM hosters to provide free Let's Encrypt certificates for their clients.

Documentation

Index

Constants

View Source
const (
	ResponseSizeLimit = (5 * megabyte) + 1337
	ErrorUnknown      = "Unknown"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API2Result

type API2Result struct {
	BaseResult
	Result json.RawMessage `json:"cpanelresult"`
}

type Api

type Api struct {
	Gateway ApiGateway
}

func NewApi

func NewApi(gw ApiGateway) Api

func (Api) Close

func (a Api) Close() error

type ApiGateway

type ApiGateway interface {
	UAPI(module, function string, arguments Args, out interface{}) error
	API2(module, function string, arguments Args, out interface{}) error
	API1(module, function string, arguments []string, out interface{}) error
	Close() error
}

type Args

type Args map[string]interface{}

func (Args) Values

func (a Args) Values(apiVersion string) url.Values

type BaseAPI1Response

type BaseAPI1Response struct {
	// other stuff here "apiversion":"1","type":"event","module":"Serverinfo","func":"servicestatus","source":"module"
	Data struct {
		Result string `json:"result"`
	} `json:"data"`
	ErrorString string `json:"error"`
	// "event":{"result":1,"reason":"blah blah"}}
	Event struct {
		Result int    `json:"result"`
		Reason string `json:"reason"`
	} `json:"event"`
}

func (BaseAPI1Response) Error

func (r BaseAPI1Response) Error() error

type BaseAPI2Response

type BaseAPI2Response struct {
	BaseResult
	Event struct {
		Result int    `json:"result"`
		Reason string `json:"reason"`
	} `json:"event"`
}

func (BaseAPI2Response) Error

func (r BaseAPI2Response) Error() error

type BaseResult

type BaseResult struct {
	ErrorString string `json:"error"`
}

func (BaseResult) Error

func (r BaseResult) Error() error

type BaseUAPIResponse

type BaseUAPIResponse struct {
	BaseResult
	StatusCode int      `json:"status"`
	Errors     []string `json:"errors"`
	Messages   []string `json:"messages"`
}

func (BaseUAPIResponse) Error

func (r BaseUAPIResponse) Error() error

func (BaseUAPIResponse) Message

func (r BaseUAPIResponse) Message() string

type MaybeInt64

type MaybeInt64 int64

func (*MaybeInt64) MarshalJSON

func (m *MaybeInt64) MarshalJSON() ([]byte, error)

func (*MaybeInt64) UnmarshalJSON

func (m *MaybeInt64) UnmarshalJSON(buf []byte) error

type UAPIResult

type UAPIResult struct {
	BaseResult
	Result json.RawMessage `json:"result"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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