cloudatcost

package
v0.0.0-...-8eb34df Latest Latest
Warning

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

Go to latest
Published: May 8, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LibraryVersion = "0.1"
)

const

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

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

Types

type Client

type Client struct {
	Option *Option

	BaseURL                *url.URL
	UserAgent              string
	ServersService         *ServersService
	ListTemplatesService   *ListTemplatesService
	ListTasksService       *ListTasksService
	PowerOperationsService *PowerOperationsService
	ConsoleService         *ConsoleService
	DnsService             *DnsService
	CloudProService        *CloudProService
	RunModeService         *RunModeService
	// contains filtered or unexported fields
}

A Client manages communication with the CloudAtCost API.

func NewClient

func NewClient(option *Option) (*Client, error)

NewClient returns a new CloudAtCost API client.

func (*Client) Do

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

Do sends an API request and returns the API response.

func (*Client) NewFormRequest

func (c *Client) NewFormRequest(method, urlStr string, values url.Values) (*http.Request, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request.

type CloudProResourcesData

type CloudProResourcesData struct {
	Total CloudProResourcesTotalResponse `json:"total"`
	Used  CloudProResourcesUsedResponse  `json:"used"`
}

type CloudProResourcesResponse

type CloudProResourcesResponse struct {
	Status string                `json:"status"`
	Time   int                   `json:"time"`
	API    string                `json:"api"`
	Action string                `json:"action"`
	Data   CloudProResourcesData `json:"data"`
}

type CloudProResourcesTotalResponse

type CloudProResourcesTotalResponse struct {
	CPU     string `json:"cpu_total"`
	Ram     string `json:"ram_total"`
	Storage string `json:"storage_total"`
}

type CloudProResourcesUsedResponse

type CloudProResourcesUsedResponse struct {
	CPU     string `json:"cpu_used"`
	Ram     string `json:"ram_used"`
	Storage string `json:"storage_used"`
}

type CloudProServerResponse

type CloudProServerResponse struct {
	Status string `json:"status"`
	Time   int    `json:"time"`
	API    string `json:"api"`
	Action string `json:"action"`
	Taskid int    `json:"taskid"`
	Result string `json:"result"`
}

type CloudProService

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

func (*CloudProService) Create

func (*CloudProService) Delete

func (*CloudProService) Resources

type ConsoleResponse

type ConsoleResponse struct {
	Status   string `json:"status"`
	Time     int    `json:"time"`
	API      string `json:"api"`
	Serverid string `json:"serverid"`
	Console  string `json:"console"`
}

type ConsoleService

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

func (*ConsoleService) Console

func (s *ConsoleService) Console(serverId string) (*ConsoleResponse, *http.Response, error)

type CreateServerOptions

type CreateServerOptions struct {
	Cpu        string `json:"cpu"`
	Ram        string `json:"ram"`
	Storage    string `json:"storage"`
	OS         string `json:"os"`
	Datacenter string `json:"datacenter"`
}

type DnsService

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

func (*DnsService) ModifyReverseDns

func (s *DnsService) ModifyReverseDns(serverId, hostname string) (*StandardResponse, *http.Response, error)

type ErrorResponse

type ErrorResponse struct {
	Response    *http.Response
	ErrorStatus ErrorStatus
}

An ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type ErrorStatus

type ErrorStatus struct {
	Status           string `json:"status,omitempty"`
	Time             string `json:"time,omitempty"`
	Error            string `json:"error,omitempty"`
	ErrorDescription string `json:"error_description,omitempty"`
}

ErrorStatus https://github.com/cloudatcost/api Error:

type ListServer

type ListServer struct {
	Sid        string      `json:"sid"`
	ID         string      `json:"id"`
	Packageid  string      `json:"packageid"`
	Servername string      `json:"servername"`
	Lable      interface{} `json:"lable"`
	Vmname     string      `json:"vmname"`
	IP         string      `json:"ip"`
	Netmask    string      `json:"netmask"`
	Gateway    string      `json:"gateway"`
	Portgroup  string      `json:"portgroup"`
	Hostname   string      `json:"hostname"`
	Rootpass   string      `json:"rootpass"`
	Vncport    string      `json:"vncport"`
	Vncpass    string      `json:"vncpass"`
	Servertype string      `json:"servertype"`
	Template   string      `json:"template"`
	CPU        string      `json:"cpu"`
	Cpuusage   string      `json:"cpuusage"`
	RAM        string      `json:"ram"`
	Ramusage   string      `json:"ramusage"`
	Storage    string      `json:"storage"`
	Hdusage    string      `json:"hdusage"`
	Sdate      string      `json:"sdate"`
	Status     string      `json:"status"`
	PanelNote  string      `json:"panel_note"`
	Mode       string      `json:"mode"`
	UID        string      `json:"uid"`
}

type ListServersResponse

type ListServersResponse struct {
	Status string       `json:"status"`
	Time   int          `json:"time"`
	API    string       `json:"api"`
	Action string       `json:"action"`
	Data   []ListServer `json:"data"`
}

type ListTask

type ListTask struct {
	Cid        string `json:"cid"`
	Idf        string `json:"idf"`
	Serverid   string `json:"serverid"`
	Action     string `json:"action"`
	Status     string `json:"status"`
	Starttime  string `json:"starttime"`
	Finishtime string `json:"finishtime"`
}

type ListTasksResponse

type ListTasksResponse struct {
	Status string     `json:"status"`
	Time   int        `json:"time"`
	API    string     `json:"api"`
	Cid    string     `json:"cid"`
	Action string     `json:"action"`
	Data   []ListTask `json:"data"`
}

type ListTasksService

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

func (*ListTasksService) ListTasks

func (s *ListTasksService) ListTasks() ([]ListTask, *http.Response, error)

type ListTemplate

type ListTemplate struct {
	Ce_id string `json:"ce_id"`
	Name  string `json:"name"`
}

type ListTemplatesResponse

type ListTemplatesResponse struct {
	Status string         `json:"status"`
	Time   int            `json:"time"`
	API    string         `json:"api"`
	Action string         `json:"action"`
	Data   []ListTemplate `json:"data"`
}

type ListTemplatesService

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

func (*ListTemplatesService) ListTemplates

func (s *ListTemplatesService) ListTemplates() ([]ListTemplate, *http.Response, error)

type MockClient

type MockClient struct {
	Mux         *http.ServeMux
	Client      *Client
	Server      *httptest.Server
	FixturesDir string
}

A MockClient manages communication with the CloudatCost API mock.

func NewMockClient

func NewMockClient() *MockClient

NewMockClient returns a new DCloudatCost API client mock.

func (*MockClient) Close

func (r *MockClient) Close()

Close Close Mocl

func (*MockClient) ReadJSON

func (r *MockClient) ReadJSON(filename string) string

ReadJSON Read json from file

type Option

type Option struct {
	Login string
	Key   string
}

Option Optional parameters

type PowerOperationResponse

type PowerOperationResponse struct {
	Status   string `json:"status"`
	Time     int    `json:"time"`
	API      string `json:"api"`
	Action   string `json:"action"`
	Serverid string `json:"serverid"`
	Taskid   int64  `json:"taskid"`
	Result   string `json:"result"`
}

type PowerOperationsService

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

func (*PowerOperationsService) Action

func (s *PowerOperationsService) Action(serverId, action string) (*PowerOperationResponse, *http.Response, error)

func (*PowerOperationsService) PowerOff

func (*PowerOperationsService) PowerOn

func (*PowerOperationsService) Reset

type RunModeResponse

type RunModeResponse struct {
	Status   string `json:"status"`
	Time     int    `json:"time"`
	API      string `json:"api"`
	Serverid string `json:"serverid"`
	Result   string `json:"result"`
}

type RunModeService

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

func (*RunModeService) Mode

func (s *RunModeService) Mode(serverId, action string) (*RunModeResponse, *http.Response, error)

func (*RunModeService) Normal

func (s *RunModeService) Normal(serverId string) (*RunModeResponse, *http.Response, error)

func (*RunModeService) Safe

func (s *RunModeService) Safe(serverId string) (*RunModeResponse, *http.Response, error)

type ServersService

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

func (*ServersService) List

func (s *ServersService) List() ([]ListServer, *http.Response, error)

func (*ServersService) Rename

func (s *ServersService) Rename(serverId, name string) (*StandardResponse, *http.Response, error)

type StandardResponse

type StandardResponse struct {
	Status   string `json:"status"`
	Time     int    `json:"time"`
	API      string `json:"api"`
	Serverid string `json:"serverid"`
	Result   string `json:"result"`
}

Jump to

Keyboard shortcuts

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