model

package
v0.0.0-...-e4c96ca Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2017 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2017 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	//system-generated device ID
	ID DeviceID `json:"id" bson:"_id,omitempty" valid:"length(1|1024),required"`

	//a map of attributes names and their values.
	Attributes DeviceAttributes `json:"attributes,omitempty" bson:",omitempty" valid:"optional"`

	//device's group name
	Group GroupName `json:"-" bson:"group,omitempty" valid:"optional"`

	CreatedTs time.Time `json:"-" bson:"created_ts,omitempty"`
	//Timestamp of the last attribute update.
	UpdatedTs time.Time `json:"updated_ts" bson:"updated_ts,omitempty"`
}

Device wrapper

func (*Device) Validate

func (d *Device) Validate() error

Validate checkes structure according to valid tags

type DeviceAttribute

type DeviceAttribute struct {
	Name        string      `json:"name" bson:",omitempty"  valid:"length(1|4096),required"`
	Description *string     `json:"description,omitempty" bson:",omitempty"  valid:"optional"`
	Value       interface{} `json:"value" bson:",omitempty"  valid:"length(1|4096),required,deviceAttributeValueValidator"`
}

type DeviceAttributes

type DeviceAttributes map[string]DeviceAttribute

wrapper for device attributes names and values

func (DeviceAttributes) MarshalJSON

func (d DeviceAttributes) MarshalJSON() ([]byte, error)

func (*DeviceAttributes) UnmarshalJSON

func (d *DeviceAttributes) UnmarshalJSON(b []byte) error

type DeviceID

type DeviceID string

func (DeviceID) String

func (did DeviceID) String() string

type GroupName

type GroupName string

func (GroupName) String

func (gn GroupName) String() string

Jump to

Keyboard shortcuts

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