Version: v0.0.0-...-124f71e Latest Latest

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

Go to latest
Published: Oct 9, 2017 License: Apache-2.0 Imports: 17 Imported by: 0




View Source
const (
	SignatureVersion   = "1.0"
	SignatureMethod    = "AWS4-HMAC-SHA256"
	JSONResponseFormat = "JSON"
	XMLResponseFormat  = "XML"
	RequestMethod      = "GET"

Constants for Ksyun API requests

View Source
const (
	PayByBandwidth = "PayByBandwidth"
	PayByTraffic   = "PayByTraffic"

	PrePaid  = "PrePaid"
	PostPaid = "PostPaid"
View Source
const Version = "0.1"


View Source
var Regions = []Region{
	{"cn-beijing-6", "北京6区"},
	{"cn-shanghai-2", "上海2区"},
	{"cn-hongkong-2", "香港2区"},

Regions 金山云支持的机房


func GetClientError

func GetClientError(err error) error

func GetClientErrorFromString

func GetClientErrorFromString(str string) error


type Client

type Client struct {
	AccessKeyId     string //Access Key Id
	AccessKeySecret string //Access Key Secret
	Region          string
	Service         string
	// contains filtered or unexported fields

A Client represents a client of kec services

func (*Client) GenerateClientToken

func (client *Client) GenerateClientToken() string

GenerateClientToken generates the Client Token with random string

func (*Client) Init

func (client *Client) Init(endpoint, version, accessKeyId, accessKeySecret, region, service string)

Init creates a new instance of client

func (*Client) Invoke

func (client *Client) Invoke(action string, args interface{}, response interface{}) error

Invoke sends the raw HTTP request for ksyun services

func (*Client) SetAccessKeyId

func (client *Client) SetAccessKeyId(id string)

SetAccessKeyId sets new AccessKeyId

func (*Client) SetAccessKeySecret

func (client *Client) SetAccessKeySecret(secret string)

SetAccessKeySecret sets new AccessKeySecret

func (*Client) SetDebug

func (client *Client) SetDebug(debug bool)

SetDebug sets debug mode to log the request/response message

func (*Client) SetEndpoint

func (client *Client) SetEndpoint(endpoint string)

SetEndpoint sets custom endpoint

func (*Client) SetVersion

func (client *Client) SetVersion(version string)

SetEndpoint sets custom version

type Credentials

type Credentials struct {
	AccessKeyID     string
	SecretAccessKey string
	SecurityToken   string `json:"Token"`
	Expiration      time.Time

Credentials stores the information necessary to authorize with AWS and it is from this information that requests are signed.

type Error

type Error struct {
	StatusCode int //Status Code of HTTP Response

An Error represents a custom error for Ksyun API failure response

func (*Error) Error

func (e *Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	HostId  string
	Code    string
	Message string

type Pagination

type Pagination struct {
	PageNumber int
	PageSize   int

func (*Pagination) SetPageSize

func (p *Pagination) SetPageSize(size int)

func (*Pagination) Validate

func (p *Pagination) Validate()

type PaginationResult

type PaginationResult struct {
	TotalCount int
	PageNumber int
	PageSize   int

A PaginationResponse represents a response with pagination information

func (*PaginationResult) NextPage

func (r *PaginationResult) NextPage() *Pagination

NextPage gets the next page of the result set

type Region

type Region struct {
	ID   string
	Name string

Region Ksyun region

type Request

type Request struct {
	Format               string
	Version              string
	AccessKeyId          string
	Signature            string
	SignatureMethod      string
	Timestamp            util.ISO6801Time
	SignatureVersion     string
	SignatureNonce       string
	ResourceOwnerAccount string
	Action               string

type Response

type Response struct {
	RequestId string

Jump to

Keyboard shortcuts

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