cms

package
Version: v0.0.0-...-112a489 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_SEPERATER = "\n"
	ACS_PREFIX       = "x-acs"
)
View Source
const (
	DefaultEndpoint = "http://alert.aliyuncs.com"
	APIVersion      = "2015-08-15"
	METHOD_GET      = "GET"
	METHOD_POST     = "POST"
	METHOD_PUT      = "PUT"
	METHOD_DELETE   = "DELETE"
)

Variables

This section is empty.

Functions

func BodyMd5

func BodyMd5(jsonstring string) string

*

* 对json进行md5 base64

func GetRequestPath

func GetRequestPath(entity string, project string, id string) string

*

* 取得上下文请求路径

func InitBaseHeader

func InitBaseHeader(v *http.Request)

*

* 取得公共的头部参数,初始化的时候先将Content

Types

type ActionGroup

type ActionGroup struct {
	ContactGroups []string `json:"contactGroups"`
	Id            string   `json:"id"`
}

type ActionsModel

type ActionsModel struct {
	AlertActions []AlertActionsModel `json:"alertActions"`
	Effective    string              `json:"effective"`
	Failure      ActionGroup         `json:"failure"`
}

type AlertActionsModel

type AlertActionsModel struct {
	ContactGroups []string `json:"contactGroups"`
	Id            string   `json:"id"`
	Level         int      `json:"level"`
}

type AlertRequest

type AlertRequest struct {
	Name        string             `json:"name"`
	Status      int                `json:"status"`
	Actions     ActionsModel       `json:"actions"`
	Condition   ConditionModel     `json:"condition"`
	Enable      bool               `json:"enable"`
	Escalations []EscalationsModel `json:"escalations"`
}

alert请求结构

type Client

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

func NewClient

func NewClient(accessKeyId, accessKeySecret string) *Client

NewClient creates a new instance of ECS client

func (*Client) CreateAlert

func (c *Client) CreateAlert(projectName string, alertRequest AlertRequest) (result ResultModel, err error)

*

* 创建一个Alert
* @params
*   projectName
*   AlertRequest 创建模块的模型
* @return
*   result 创建返回的模型
*   error  错误,如果一切Ok,error为 nil

func (*Client) CreateAlert4Json

func (c *Client) CreateAlert4Json(projectName string, request string) (result ResultModel, err error)

func (*Client) CreateAlertDimension

func (c *Client) CreateAlertDimension(projectName string, request DimensionRequest) (result ResultModel, err error)

func (*Client) CreateProject

func (c *Client) CreateProject(projectName string, projectDesc string, projectOwner string) (result ResultModel, err error)

*

* 创建一个Project
* @params
*   ProjectModel 创建模块的模型
* @return
*   result 创建返回的模型
*   error  错误,如果一切Ok,error为 nil

func (*Client) DeleteAlert

func (c *Client) DeleteAlert(projectName string, alertName string) (result ResultModel, err error)

*

*

func (*Client) DeleteAlertDimension

func (c *Client) DeleteAlertDimension(projectName string, alertName string, dimensionId string) (result ResultModel, err error)

func (*Client) DeleteProject

func (c *Client) DeleteProject(projectName string) (result ResultModel, err error)

*

* 删除一个Project
* @params
*   projectName 创建模块的模型
* @return
*   result 返回的模型
*   error  错误,如果一切Ok,error为 nil

func (*Client) GetAccessKey

func (client *Client) GetAccessKey() string

func (*Client) GetAccessSecret

func (client *Client) GetAccessSecret() string

func (*Client) GetAlert

func (c *Client) GetAlert(projectName string, alertName string) (result GetProjectResult, err error)

* 取得一个alert

func (*Client) GetAlertList

func (c *Client) GetAlertList(page string, pageSize string, projectName string, alertName string) (result GetProjectResult, err error)

*

* 取得alertl列表

func (*Client) GetApiUri

func (client *Client) GetApiUri() string

func (*Client) GetDimensions

func (c *Client) GetDimensions(projectName string, alertName string) (result GetDimenstionResult, err error)

func (*Client) GetProject

func (c *Client) GetProject(projectName string) (result GetProjectResult, err error)

*

* 取得一个Project
* @params
*   projectName projectName不能为空
* @return
*   result 返回的模型
*   error  错误,如果一切Ok,error为 nil

func (*Client) GetProjectList

func (c *Client) GetProjectList(page string, pageSize string, projectOwner string) (result ProjectListResultModel, err error)

*

* 取得一个多个Project
* @params
*   page: 页码
*   pageSize: 每夜记录条数
*   projectOwner 所属用户
* @return
*   result 返回的模型
*   error  错误,如果一切Ok,error为 nil

func (*Client) GetResponseJson

func (c *Client) GetResponseJson(method string, requestUrl string, requestPath string, body string) (responseBody string, err error)

*

* 发送http请求,去的响应字符串

func (*Client) GetUrl

func (client *Client) GetUrl(entity string, project string, id string) string

*

* 去的要请求的url

func (*Client) PutMetrics

func (c *Client) PutMetrics(projectName string, request string) (result ResultModel, err error)

func (*Client) Sign

func (client *Client) Sign(method string, url string, req *http.Request, querys string)

*

*  这个方法是先POP签名,并写入到协议头中
* @params
*  method http方法,GET POST DELETE PUT 等
*  url 请求的url
*  header http请求头
*  querys GET请求参数,则需要设置querys参数
* POP签名

func (*Client) UpdateAlert

func (c *Client) UpdateAlert(projectName string, alertName string, alertRequest AlertRequest) (result ResultModel, err error)

*

* 更新Alert

func (*Client) UpdateProject

func (c *Client) UpdateProject(projectName string, project *ProjectModel) (result ResultModel, err error)

*

* 更新一个Project
* @params
*   projectName 创建模块的模型
*    project 修改的模型,这个只能修改projectDesc和ProjectOwer
* @return
*   result 返回的模型
*   error  错误,如果一切Ok,error为 nil

type ConditionModel

type ConditionModel struct {
	DimensionKeys    []string `json:"dimensionKeys"`
	Interval         int      `json:"interval"`
	MetricColumnName string   `json:"metricColumnName"`
	MetricName       string   `json:"metricName"`
	SourceType       string   `json:"sourceType"`
}

type DimensionDataPoint

type DimensionDataPoint struct {
	Id         string `json:"id"`
	Project    string `json:"project,omitempty"`
	AlertUuid  string `json:"alertUuid,omitempty"`
	Status     int    `json:"status,omitempty"`
	Dimensions string `json:"dimensions,omitempty"`
	AlertName  string `json:"alertName,omitempty"`
}

type DimensionRequest

type DimensionRequest struct {
	//ProjectName string `json:"projectName"`
	AlertName  string `json:"alertName"`
	Dimensions string `json:"dimensions"`
	UserId     string `json:"userId"`
}

type EscalationsModel

type EscalationsModel struct {
	Expression string `json:"expression"`
	Level      int    `json:"level"`
	Times      int    `json:"times"`
}

type Failure

type Failure struct {
	ContactGroups []string `json:"contactGroups"`
	Id            string   `json:"id"`
}

type GetDimenstionResult

type GetDimenstionResult struct {
	Code       string                `json:"code"`
	Success    bool                  `json:"success"`
	Message    string                `json:"comessagede,omitempty"`
	TraceId    string                `json:"traceId"`
	DataPoints []*DimensionDataPoint `json:"datapoints,omitempty"`
}

type GetProjectResult

type GetProjectResult struct {
	Result  ProjectResultModel `json:"result"`
	Code    string             `json:"code"`
	Success bool               `json:"success"`
}

返回的实体类型

type ListProjectRequestModel

type ListProjectRequestModel struct {
	Page     string `json:"page"`
	PageSize string `json:"pageSize"`
}

列表批量取得Project的请求参数

type ProjectListResultModel

type ProjectListResultModel struct {
	Total      int                  `json:"total"`
	Datapoints []ProjectResultModel `json:"datapoints"`
}

取得多个project的结构

type ProjectModel

type ProjectModel struct {
	ProjectName  string `json:"projectName"`
	ProjectDesc  string `json:"projectDesc"`
	ProjectOwner string `json:"projectOwner"`
}

project的实体类,主要用于发送请求,更新或者添加Project

type ProjectResultModel

type ProjectResultModel struct {
	ProjectModel
	Id          int64  `json:"id"`
	GmtModified int64  `json:"gmtModified"`
	GmtCreate   int64  `json:"gmtCreate"`
	Status      int    `json:"status"`
	Creator     string `json:"creator"`
}

project返回实体,继承于ProjectModel

type ResultModel

type ResultModel struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Success bool   `json:"success"`
}

调用接口返回的实体 新增加的结构首字母一定要大写,否则json编码或者解析编码会出现问题

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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