github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/apiserver/params/metrics.go (about)

     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  // MetricResult 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  	Unit  string    `json:"unit"`
    39  }