Documentation ¶
Overview ¶
Copyright 2023 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func GetDeviceAttributeNameReplacer() *strings.Replacer
- type Device
- type DeviceAttribute
- type DeviceAttributes
- func (d DeviceAttributes) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (d DeviceAttributes) MarshalJSON() ([]byte, error)
- func (d *DeviceAttributes) UnmarshalBSONValue(t bsontype.Type, b []byte) error
- func (d *DeviceAttributes) UnmarshalJSON(b []byte) error
- func (d DeviceAttributes) Validate() error
- type DeviceGroups
- type DeviceID
- type DeviceUpdate
- type Filter
- type FilterAttribute
- type FilterPredicate
- type GroupName
- type NewTenant
- type SearchParams
- type SelectAttribute
- type SortCriteria
- type UpdateResult
Constants ¶
View Source
const ( AttrScopeInventory = "inventory" AttrScopeIdentity = "identity" AttrScopeSystem = "system" AttrScopeTags = "tags" AttrScopeMonitor = "monitor" AttrNameID = "id" AttrNameGroup = "group" AttrNameUpdated = "updated_ts" AttrNameCreated = "created_ts" AttrNameTagsEtag = "tags_etag" AttrNameNumberOfAlerts = "alert_count" AttrNameAlerts = "alerts" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Device ¶
type Device struct { //system-generated device ID ID DeviceID `json:"id" bson:"_id,omitempty"` //a map of attributes names and their values. Attributes DeviceAttributes `json:"attributes,omitempty" bson:"attributes,omitempty"` //device's group name Group GroupName `json:"-" bson:"group,omitempty"` CreatedTs time.Time `json:"-" bson:"created_ts,omitempty"` //Timestamp of the last attribute update. UpdatedTs *time.Time `json:"updated_ts,omitempty" bson:"updated_ts,omitempty"` //device object revision Revision uint `json:"-" bson:"revision,omitempty"` //tags attributes ETag TagsEtag string `json:"-" bson:"tags_etag,omitempty"` //text attribute for the full-text search Text string `json:"-" bson:"text,omitempty"` }
Device wrapper
func (Device) MarshalBSON ¶
func (*Device) UnmarshalBSON ¶
type DeviceAttribute ¶
type DeviceAttribute struct { Name string `json:"name" bson:",omitempty"` Description *string `json:"description,omitempty" bson:",omitempty"` Value interface{} `json:"value" bson:",omitempty"` Scope string `json:"scope" bson:",omitempty"` Timestamp *time.Time `json:"timestamp,omitempty" bson:",omitempty"` }
func (DeviceAttribute) Validate ¶
func (da DeviceAttribute) Validate() error
type DeviceAttributes ¶
type DeviceAttributes []DeviceAttribute
wrapper for device attributes names and values
func (DeviceAttributes) MarshalBSONValue ¶
func (d DeviceAttributes) MarshalBSONValue() (bsontype.Type, []byte, error)
MarshalBSONValue marshals the DeviceAttributes to a mongo-compatible document. That is, each attribute is given a unique field consisting of "<scope>-<name>".
func (DeviceAttributes) MarshalJSON ¶
func (d DeviceAttributes) MarshalJSON() ([]byte, error)
MarshalJSON ensures that an empty array is returned if DeviceAttributes is empty.
func (*DeviceAttributes) UnmarshalBSONValue ¶
func (d *DeviceAttributes) UnmarshalBSONValue(t bsontype.Type, b []byte) error
UnmarshalBSONValue correctly unmarshals DeviceAttributes from Device documents stored in the DB.
func (*DeviceAttributes) UnmarshalJSON ¶
func (d *DeviceAttributes) UnmarshalJSON(b []byte) error
func (DeviceAttributes) Validate ¶
func (d DeviceAttributes) Validate() error
type DeviceGroups ¶
type DeviceGroups struct {
Groups []string `json:"groups" bson:"-"`
}
type DeviceID ¶
type DeviceID string
var NilDeviceID DeviceID //TODO: how to make it NilDeviceID:=DeviceID(primitive.NilObjectID)
type DeviceUpdate ¶
type Filter ¶
type Filter struct { Id string `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Terms []FilterPredicate `json:"terms" bson:"terms"` }
type FilterAttribute ¶
type FilterPredicate ¶
type FilterPredicate struct { Scope string `json:"scope" bson:"scope"` Attribute string `json:"attribute" bson:"attribute"` Type string `json:"type" bson:"type"` Value interface{} `json:"value" bson:"value"` }
func (FilterPredicate) Validate ¶
func (f FilterPredicate) Validate() error
type SearchParams ¶
type SearchParams struct { Page int `json:"page"` PerPage int `json:"per_page"` Filters []FilterPredicate `json:"filters"` Sort []SortCriteria `json:"sort"` Attributes []SelectAttribute `json:"attributes"` DeviceIDs []string `json:"device_ids"` Text string `json:"text"` }
func (SearchParams) Validate ¶
func (sp SearchParams) Validate() error
type SelectAttribute ¶
type SortCriteria ¶
Click to show internal directories.
Click to hide internal directories.