~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/apiserver/params/metrics.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2016 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package params
 
5
 
 
6
import (
 
7
        "time"
 
8
)
 
9
 
 
10
// MetricResults contains results from a GetMetrics call, with
 
11
// one item per Entity given as an argument to the command.
 
12
type MetricResults struct {
 
13
        Results []EntityMetrics `json:"results"`
 
14
}
 
15
 
 
16
// OneError returns the first error
 
17
func (m *MetricResults) OneError() error {
 
18
        for _, r := range m.Results {
 
19
                if err := r.Error; err != nil {
 
20
                        return err
 
21
                }
 
22
        }
 
23
        return nil
 
24
}
 
25
 
 
26
// EntityMetrics contains the results of a GetMetrics call for a single
 
27
// entity.
 
28
type EntityMetrics struct {
 
29
        Metrics []MetricResult `json:"metrics,omitempty"`
 
30
        Error   *Error         `json:"error,omitempty"`
 
31
}
 
32
 
 
33
// MetricResults contains a single metric.
 
34
type MetricResult struct {
 
35
        Time  time.Time `json:"time"`
 
36
        Key   string    `json:"key"`
 
37
        Value string    `json:"value"`
 
38
}