common

package
v0.0.0-...-f8f9ceb Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	HTTP_PROTOCOL  = "http"
	HTTPS_PROTOCOL = "https"
)
View Source
const (
	Hangzhou    = Region("cn-hangzhou")
	Qingdao     = Region("cn-qingdao")
	Beijing     = Region("cn-beijing")
	Hongkong    = Region("cn-hongkong")
	Shenzhen    = Region("cn-shenzhen")
	Shanghai    = Region("cn-shanghai")
	Zhangjiakou = Region("cn-zhangjiakou")

	APSouthEast1 = Region("ap-southeast-1")
	APNorthEast1 = Region("ap-northeast-1")
	APSouthEast2 = Region("ap-southeast-2")

	USWest1 = Region("us-west-1")
	USEast1 = Region("us-east-1")

	MEEast1 = Region("me-east-1")

	EUCentral1 = Region("eu-central-1")
)

Constants of region definition

View Source
const (
	SignatureVersion   = "1.0"
	SignatureMethod    = "HMAC-SHA1"
	JSONResponseFormat = "JSON"
	XMLResponseFormat  = "XML"
	ECSRequestMethod   = "GET"
)

Constants for Aliyun API requests

View Source
const (
	PayByBandwidth = InternetChargeType("PayByBandwidth")
	PayByTraffic   = InternetChargeType("PayByTraffic")
)
View Source
const (
	PrePaid  = InstanceChargeType("PrePaid")
	PostPaid = InstanceChargeType("PostPaid")
)
View Source
const (
	Internet = NetType("Internet")
	Intranet = NetType("Intranet")
)
View Source
const (
	Hour  = TimeType("Hour")
	Day   = TimeType("Day")
	Month = TimeType("Month")
	Year  = TimeType("Year")
)
View Source
const (
	Classic = NetworkType("Classic")
	VPC     = NetworkType("VPC")
)
View Source
const Version = "0.1"

Variables

Functions

func GetClientError

func GetClientError(err error) error

func GetClientErrorFromString

func GetClientErrorFromString(str string) error

Types

type BusinessInfo

type BusinessInfo struct {
	Pack       string `json:"pack,omitempty"`
	ActivityId string `json:"activityId,omitempty"`
}

type Client

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

A Client represents a client of ECS services

func NewLocationClient

func NewLocationClient(accessKeyId, accessKeySecret string) *Client

func (*Client) DescribeEndpoint

func (client *Client) DescribeEndpoint(args *DescribeEndpointArgs) (*DescribeEndpointResponse, error)

func (*Client) DescribeOpenAPIEndpoint

func (client *Client) DescribeOpenAPIEndpoint(region Region, serviceCode string) string

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 string)

NewClient creates a new instance of ECS client

func (*Client) Invoke

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

Invoke sends the raw HTTP request for ECS services

func (*Client) InvokeByAnyMethod

func (client *Client) InvokeByAnyMethod(method, action, path string, args interface{}, response interface{}) error

Invoke sends the raw HTTP request for ECS services 改进了一下上面那个方法,可以使用各种Http方法 2017.1.30 增加了一个path参数,用来拓展访问的地址

func (*Client) InvokeByFlattenMethod

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

Invoke sends the raw HTTP request for ECS services

func (*Client) NewInit

func (client *Client) NewInit(endpoint, version, accessKeyId, accessKeySecret, serviceCode string, regionID Region)

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) SetBusinessInfo

func (client *Client) SetBusinessInfo(businessInfo string)

SetBusinessInfo sets business info to log the request/response message

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) SetEndpointByLocation

func (client *Client) SetEndpointByLocation(region Region, serviceCode, accessKeyId, accessKeySecret string)

SetEndpointByLocation NewClient using location service

func (*Client) SetRegionID

func (client *Client) SetRegionID(regionID Region)

func (*Client) SetServiceCode

func (client *Client) SetServiceCode(serviceCode string)

SetServiceCode sets serviceCode

func (*Client) SetVersion

func (client *Client) SetVersion(version string)

SetEndpoint sets custom version

type DescribeEndpointArgs

type DescribeEndpointArgs struct {
	Id          Region
	ServiceCode string
	Type        string
}

type DescribeEndpointResponse

type DescribeEndpointResponse struct {
	Response
	EndpointItem
}

type Endpoint

type Endpoint struct {
	Name      string    `xml:"name,attr"`
	RegionIds RegionIds `xml:"RegionIds"`
	Products  Products  `xml:"Products"`
}

type EndpointItem

type EndpointItem struct {
	Protocols struct {
		Protocols []string
	}
	Type        string
	Namespace   string
	Id          Region
	SerivceCode string
	Endpoint    string
}

type Endpoints

type Endpoints struct {
	Endpoint []Endpoint `xml:"Endpoint"`
}

xml

type Error

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

An Error represents a custom error for Aliyun API failure response

func (*Error) Error

func (e *Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	Response
	HostId  string
	Code    string
	Message string
}

type FlattenArray

type FlattenArray []string

RemovalPolicy.N add index to array item RemovalPolicy=["a", "b"] => RemovalPolicy.1="a" RemovalPolicy.2="b"

type InstanceChargeType

type InstanceChargeType string

type InternetChargeType

type InternetChargeType string

type NetType

type NetType string

type NetworkType

type NetworkType 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 Product

type Product struct {
	ProductName string `xml:"ProductName"`
	DomainName  string `xml:"DomainName"`
}

type Products

type Products struct {
	Product []Product `xml:"Product"`
}

type Region

type Region string

Region represents ECS region

type RegionIds

type RegionIds struct {
	RegionId string `xml:"RegionId"`
}

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
}

type SyncMap

type SyncMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SyncMap wraps built-in map by using RWMutex for concurrent safe.

type TimeType

type TimeType string

type UnderlineString

type UnderlineString string

string contains underline which will be replaced with dot SystemDisk_Category => SystemDisk.Category

Jump to

Keyboard shortcuts

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