Esempio n. 1
0
func loadGet(client *ec2.Client, values Values, i interface{}) error {
	rsp, e := client.DoSignedRequest("GET", endpoint(client.Client), values.Encode(), nil)
	if e != nil {
		return e
	}
	return xml.Unmarshal(rsp.Content, i)
}
Esempio n. 2
0
func (action *ListMetrics) Execute(client *ec2.Client) (*ListMetricsResponse, error) {
	rsp, e := client.DoSignedRequest("GET", endpoint(client.Client), action.query(), nil)
	if e != nil {
		return nil, e
	}
	o := &ListMetricsResponse{}
	e = xml.Unmarshal(rsp.Content, o)
	return o, e
}
Esempio n. 3
0
func (action *GetMetricStatistics) Execute(client *ec2.Client) (*GetMetricStatisticsResponse, error) {
	if action.StartTime.IsZero() {
		return nil, fmt.Errorf("StartTime must not be zero")
	}
	if action.EndTime.IsZero() {
		return nil, fmt.Errorf("EndTime must not be zero")
	}
	if action.Period == 0 {
		action.Period = 60
	}
	values := Values{
		"Version":    VERSION,
		"Action":     "GetMetricStatistics",
		"MetricName": action.MetricName,
		"Namespace":  action.Namespace,
		"Period":     strconv.Itoa(action.Period),
		"EndTime":    action.EndTime.UTC().Format(time.RFC3339),
		"StartTime":  action.StartTime.UTC().Format(time.RFC3339),
		"Unit":       action.Unit,
	}

	for i, s := range action.Statistics {
		values.Add("Statistics.member."+strconv.Itoa(i+1), s)
	}

	values.addDimensions("", action.Dimensions)

	rsp, e := client.DoSignedRequest("GET", endpoint(client.Client), values.Encode(), nil)
	if e != nil {
		return nil, e
	}

	i := &GetMetricStatisticsResponse{}
	e = xml.Unmarshal(rsp.Content, i)
	return i, e
}