measurement

package
v0.0.0-...-0600186 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MEASUREMENTS_API = "/measurement/measurements"

	MEASUREMENT_TYPE            = "application/vnd.com.nsn.cumulocity.measurement+json;charset=UTF-8;ver=0.9"
	MEASUREMENT_COLLECTION_TYPE = "application/vnd.com.nsn.cumulocity.measurementCollection+json;charset=UTF-8;ver=0.9"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Measurement

type Measurement struct {
	Id              string                 `json:"id"`
	Self            string                 `json:"self"`
	Time            *time.Time             `json:"time"`
	MeasurementType string                 `json:"type"`
	Source          Source                 `json:"source"`
	Metrics         map[string]interface{} `jsonc:"flat"`
}

type MeasurementApi

type MeasurementApi interface {
	// Create a new measurement and returns the created entity with id and creation time
	Create(measurement *NewMeasurement) (*Measurement, *generic.Error)

	CreateMany(measurement *NewMeasurements) (*MeasurementCollection, *generic.Error)

	// Gets an exiting measurement by its id. If the id does not exists, nil is returned.
	Get(measurementId string) (*Measurement, *generic.Error)

	// Deletion by measurement id. If error is nil, measurement was deleted successfully.
	Delete(measurementId string) *generic.Error

	// Deletes measurements by filter. If error is nil, measurements were deleted successfully.
	// ATTENTION: at least one filter should be set otherwise an error will be thrown.
	// Use DeleteAll() (with caution!) instead if you want delete all measurements!
	DeleteMany(measurementQuery *MeasurementQuery) *generic.Error

	// Deletes all measurements. If error is nil, measurements were deleted successfully.
	// ATTENTION: use it with caution!
	DeleteAll() *generic.Error

	// Gets a measurement collection by a source (aka managed object id).
	GetForDevice(sourceId string, pageSize int) (*MeasurementCollection, *generic.Error)

	// Returns an measurement collection, found by the given measurement query parameters.
	// All query parameters are AND concatenated.
	Find(measurementQuery *MeasurementQuery, pageSize int) (*MeasurementCollection, *generic.Error)

	// Gets the next page from an existing measurement collection.
	// If there is no next page, nil is returned.
	NextPage(c *MeasurementCollection) (*MeasurementCollection, *generic.Error)

	// Gets the previous page from an existing measurement collection.
	// If there is no previous page, nil is returned.
	PreviousPage(c *MeasurementCollection) (*MeasurementCollection, *generic.Error)
}

func NewMeasurementApi

func NewMeasurementApi(client *generic.Client) MeasurementApi

Creates a new measurement api object client - Must be a gomulocity client. returns - The `measurement`-api object

type MeasurementCollection

type MeasurementCollection struct {
	Measurements []Measurement             `json:"measurements" jsonc:"collection"`
	Self         string                    `json:"self,omitempty"`
	Statistics   *generic.PagingStatistics `json:"statistics,omitempty"`
	Prev         string                    `json:"prev,omitempty"`
	Next         string                    `json:"next,omitempty"`
}

type MeasurementQuery

type MeasurementQuery struct {
	DateFrom            *time.Time
	DateTo              *time.Time
	Type                string
	ValueFragmentType   string
	ValueFragmentSeries string
	SourceId            string
	Revert              bool // It's not a filter. It's the sort order. As per default the measurements will be delivered in ascending sort order.

}

func (MeasurementQuery) QueryParams

func (q MeasurementQuery) QueryParams(params *url.Values) error

type NewMeasurement

type NewMeasurement struct {
	Time            *time.Time             `json:"time"`
	MeasurementType string                 `json:"type"`
	Source          Source                 `json:"source"`
	Metrics         map[string]interface{} `jsonc:"flat"`
}

type NewMeasurements

type NewMeasurements struct {
	Measurements []NewMeasurement `json:"measurements" jsonc:"collection"`
}

type Source

type Source struct {
	Id   string `json:"id"`
	Self string `json:"self,omitempty"`
}

type ValueFragment

type ValueFragment struct {
	Value float64 `json:"value"`
	Unit  string  `json:"unit,omitempty"`
}

Jump to

Keyboard shortcuts

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