~nskaggs/+junk/xenial-test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package params

import (
	"time"
)

// MetricResults contains results from a GetMetrics call, with
// one item per Entity given as an argument to the command.
type MetricResults struct {
	Results []EntityMetrics `json:"results"`
}

// OneError returns the first error
func (m *MetricResults) OneError() error {
	for _, r := range m.Results {
		if err := r.Error; err != nil {
			return err
		}
	}
	return nil
}

// EntityMetrics contains the results of a GetMetrics call for a single
// entity.
type EntityMetrics struct {
	Metrics []MetricResult `json:"metrics,omitempty"`
	Error   *Error         `json:"error,omitempty"`
}

// MetricResults contains a single metric.
type MetricResult struct {
	Time  time.Time `json:"time"`
	Key   string    `json:"key"`
	Value string    `json:"value"`
}