views

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package views define views for Clarify resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateSummary added in v0.3.0

type CreateSummary struct {
	ID      string `json:"id"`
	Created bool   `json:"created"`
}

CreateSummary holds the identity of a resource, and describes weather it was created due to your operation.

type DataFrame

type DataFrame map[string]DataSeries

DataFrame provides JSON encoding and decoding for a map of series identified by a series key.

func (DataFrame) MarshalJSON

func (df DataFrame) MarshalJSON() ([]byte, error)

func (DataFrame) Timestamps added in v0.3.0

func (df DataFrame) Timestamps() []fields.Timestamp

Timestamps returns an ordered set of all timestamps in the data-frame where there is at least one non-empty (not NaN) value.

func (*DataFrame) UnmarshalJSON

func (df *DataFrame) UnmarshalJSON(b []byte) error

type DataFrameInclude added in v0.3.0

type DataFrameInclude struct {
	Items []Item
}

type DataSeries

type DataSeries map[fields.Timestamp]float64

DataSeries contain a map of timestamps in micro seconds since the epoch to a floating point value.

func (DataSeries) Timestamps added in v0.3.0

func (s DataSeries) Timestamps() []fields.Timestamp

Timestamps returns an ordered set of all timestamps in the data-series where there is at least one NaN value.

type Identifier added in v0.3.0

type Identifier struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

Identifier uniquely identifies a resource entry.

type Item

Item describe the select view for an item.

type ItemAttributes

type ItemAttributes struct {
	ItemSaveAttributes
}

ItemAttributes contains attributes for the item select view.

type ItemInclude

type ItemInclude struct{}

type ItemRelationships

type ItemRelationships struct {
	CreatedBy    ToOne `json:"createdBy"`
	UpdatedBy    ToOne `json:"updatedBy"`
	Organization ToOne `json:"organization"`
}

ItemRelationships describe the item relationships that's exposed by the API.

type ItemSave

type ItemSave struct {
	ItemSaveAttributes
	MetaSave
}

ItemSave describe the save view for an item.

func PublishedItem

func PublishedItem(signal Signal, transforms ...func(dest *ItemSave)) ItemSave

PublishedItem constructs a view for an item based on the passed in signal, including a set of base annotations referring the item back to the signal it was generated from. The passed in transforms, if any, are run in order.

type ItemSaveAttributes

type ItemSaveAttributes struct {
	Name           string                       `json:"name"`
	Description    string                       `json:"description"`
	ValueType      ValueType                    `json:"valueType"`
	SourceType     SourceType                   `json:"sourceType"`
	EngUnit        string                       `json:"engUnit"`
	SampleInterval fields.FixedDurationNullZero `json:"sampleInterval"`
	GapDetection   fields.FixedDurationNullZero `json:"gapDetection"`
	Labels         fields.Labels                `json:"labels"`
	EnumValues     fields.EnumValues            `json:"enumValues"`
	Visible        bool                         `json:"visible"`
}

ItemSaveAttributes contains attributes that are part of the item save view.

type Meta added in v0.3.0

type Meta struct {
	Annotations       fields.Annotations `json:"annotations,omitempty"`
	AttributesHash    fields.Hexadecimal `json:"attributesHash,omitempty"`
	RelationshipsHash fields.Hexadecimal `json:"relationshipsHash,omitempty"`
	CreatedAt         time.Time          `json:"createdAt"`
	UpdatedAt         time.Time          `json:"updatedAt"`
}

Meta holds the meta data fields for a resource entry select view.

type MetaSave added in v0.2.0

type MetaSave struct {
	Annotations fields.Annotations `json:"annotations,omitempty"`
}

MetaSave holds the mutable meta fields for a resource entry.

type Normalizer added in v0.3.0

type Normalizer interface {
	Normalize()
}

Normalizer describes a type that should be normalized before encoding.

type NullIdentifier added in v0.3.0

type NullIdentifier Identifier

NullIdentifier is a version of Identifier where the zero-value is encoded as null in JSON.

func (NullIdentifier) MarshalJSON added in v0.3.0

func (id NullIdentifier) MarshalJSON() ([]byte, error)

func (*NullIdentifier) UnmarshalJSON added in v0.3.0

func (id *NullIdentifier) UnmarshalJSON(data []byte) error

type Resource added in v0.3.0

type Resource[A, R any] struct {
	Identifier
	Meta          Meta `json:"meta"`
	Attributes    A    `json:"attributes"`
	Relationships R    `json:"relationships"`
}

Resource describes a generic resource entry select view.

func (Resource[A, R]) MarshalJSON added in v0.3.0

func (e Resource[A, R]) MarshalJSON() ([]byte, error)

type SaveSummary added in v0.3.0

type SaveSummary struct {
	ID      string `json:"id"`
	Created bool   `json:"created"`
	Updated bool   `json:"updated"`
}

SaveSummary holds the identity of a resource, and describes weather it was updated or created due to your operation.

type Selection added in v0.3.0

type Selection[D, I any] struct {
	Meta     SelectionMeta `json:"meta"`
	Data     D             `json:"data"`
	Included I             `json:"included"`
}

Selection holds resource selection results.

type SelectionFormat added in v0.3.0

type SelectionFormat struct {
	DataAsArray         bool `json:"dataAsArray"`
	GroupIncludedByType bool `json:"groupIncludedByType"`
}

SelectionFormat contains configuration for how a resource selection is formatted.

type SelectionMeta added in v0.3.0

type SelectionMeta struct {
	Total  int             `json:"total"`
	Format SelectionFormat `json:"format"`
}

SelectionMeta contains top-level meta information about a resource selection.

type Signal

Signal describe the select view for a signal.

type SignalAttributes

type SignalAttributes struct {
	SignalSaveAttributes
	SignalReadOnlyAttributes
}

SignalAttributes contains attributes for the signal select view.

type SignalInclude

type SignalInclude struct {
	Items []Item `json:"items"`
}

type SignalReadOnlyAttributes

type SignalReadOnlyAttributes struct {
	Input string `json:"input"`
}

SignalReadOnlyAttributes contains read-only signal attributes.

type SignalRelationships

type SignalRelationships struct {
	Integration ToOne `json:"integration"`
	Item        ToOne `json:"item"`
}

SignalRelationships declare the available relationships for the signal model.

type SignalSave

type SignalSave struct {
	MetaSave
	SignalSaveAttributes
}

SignalSave describe the save view for a signal.

type SignalSaveAttributes

type SignalSaveAttributes struct {
	Name           string                       `json:"name"`
	Description    string                       `json:"description"`
	ValueType      ValueType                    `json:"valueType"`
	SourceType     SourceType                   `json:"sourceType"`
	EngUnit        string                       `json:"engUnit"`
	SampleInterval fields.FixedDurationNullZero `json:"sampleInterval"`
	GapDetection   fields.FixedDurationNullZero `json:"gapDetection"`
	Labels         fields.Labels                `json:"labels"`
	EnumValues     fields.EnumValues            `json:"enumValues"`
}

SignalSaveAttributes contains attributes that are part of the signal save view.

type SourceType

type SourceType string

SourceType describe how data values where produced.

const (
	// Measurement indicates that values are retrieved "directly" from a sensor.
	Measurement SourceType = "measurement"

	// Aggregation indicates that values are aggregated from one or more
	// sources.
	Aggregation SourceType = "aggregation"

	// Prediction indicates that values are predictions or forecasts.
	Prediction SourceType = "prediction"
)

Allowed signal/item source types.

type ToMany added in v0.3.0

type ToMany struct {
	Meta map[string]json.RawMessage `json:"meta,omitempty"`
	Data []Identifier               `json:"data"`
}

ToMany describes a to-many relationship entry.

type ToOne added in v0.3.0

type ToOne struct {
	Meta map[string]json.RawMessage `json:"meta,omitempty"`
	Data NullIdentifier             `json:"data"`
}

ToOne describes a to-one relationship entry.

type ValueType

type ValueType string

ValueType determine how data values should be interpreted.

const (
	// Numeric indicates that values should be treated as decimal numbers.
	Numeric ValueType = "numeric"

	// Enum indicates that values should be treated as integer indices to a map
	// of enumerated values.
	Enum ValueType = "enum"
)

Allowed signal/items types.

Jump to

Keyboard shortcuts

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