coredata

package
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: Apache-2.0 Imports: 8 Imported by: 12

README

README

This package contains the core data client written in the Go programming language. The core data client is used by Go services or other Go code to communicate with the EdgeX core-data microservice (regardless of underlying implemenation type) by sending REST requests to the service's API endpoints.

How To Use

To use the core-data client package you first need to import the library into your project:

import "github.com/edgexfoundry/go-mod-core-contracts/clients/coredata"

As an example of use, to find a Value Descriptor using the Core Data client, first create a new device client

vdc := NewValueDescriptorClient(params, types.Endpoint{})

And then use the client to get all value descriptors

vdc.ValueDescriptors()

Documentation

Overview

Package coredata provides clients used for integration with the core-data service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventClient

type EventClient interface {
	// Events gets a list of all events
	Events(ctx context.Context) ([]models.Event, error)
	// Event gets an event by its id
	Event(id string, ctx context.Context) (models.Event, error)
	// EventCount returns the total count of events
	EventCount(ctx context.Context) (int, error)
	// EventCountForDevice returns the total event count for the specified device
	EventCountForDevice(deviceId string, ctx context.Context) (int, error)
	// EventsForDevice returns events up to a specified number that were generated by a given device
	EventsForDevice(id string, limit int, ctx context.Context) ([]models.Event, error)
	// EventsForInterval returns events generated within a specific time period
	EventsForInterval(start int, end int, limit int, ctx context.Context) ([]models.Event, error)
	// EventsForDeviceAndValueDescriptor returns events for the specified device and value descriptor
	EventsForDeviceAndValueDescriptor(deviceId string, vd string, limit int, ctx context.Context) ([]models.Event, error)
	// Add will post a new event
	Add(event *models.Event, ctx context.Context) (string, error)
	//AddBytes posts a new event using an array of bytes, supporting encoding of the event by the caller.
	AddBytes(event []byte, ctx context.Context) (string, error)
	// DeleteForDevice will delete events by the specified device name
	DeleteForDevice(id string, ctx context.Context) error
	// DeleteOld deletes events according to their age
	DeleteOld(age int, ctx context.Context) error
	// Delete will delete an event by its id
	Delete(id string, ctx context.Context) error
	// MarkPushed designates an event as having been successfully exported
	MarkPushed(id string, ctx context.Context) error
	// MarkPushedByChecksum designates an event as having been successfully exported using a checksum for the respective event.
	MarkPushedByChecksum(checksum string, ctx context.Context) error
	// MarshalEvent will perform JSON or CBOR encoding of the supplied Event. If one or more Readings on the Event
	// has a populated BinaryValue, the marshaling will be CBOR. Default is JSON.
	MarshalEvent(e models.Event) ([]byte, error)
}

EventClient defines the interface for interactions with the Event endpoint on the EdgeX Foundry core-data service.

func NewEventClient

func NewEventClient(params types.EndpointParams, m clients.Endpointer) EventClient

NewEventClient creates an instance of EventClient

type ReadingClient

type ReadingClient interface {
	// Readings returns a list of all readings
	Readings(ctx context.Context) ([]models.Reading, error)
	// ReadingCount returns a count of the total readings
	ReadingCount(ctx context.Context) (int, error)
	// Reading returns a reading by its id
	Reading(id string, ctx context.Context) (models.Reading, error)
	// ReadingsForDevice returns readings up to a specified limit for a given device
	ReadingsForDevice(deviceId string, limit int, ctx context.Context) ([]models.Reading, error)
	// ReadingsForNameAndDevice returns readings up to a specified limit for a given device and value descriptor name
	ReadingsForNameAndDevice(name string, deviceId string, limit int, ctx context.Context) ([]models.Reading, error)
	// ReadingsForName returns readings up to a specified limit for a given value descriptor name
	ReadingsForName(name string, limit int, ctx context.Context) ([]models.Reading, error)
	// ReadingsForUOMLabel returns readings up to a specified limit for a given UOM label
	ReadingsForUOMLabel(uomLabel string, limit int, ctx context.Context) ([]models.Reading, error)
	// ReadingsForLabel returns readings up to a specified limit for a given label
	ReadingsForLabel(label string, limit int, ctx context.Context) ([]models.Reading, error)
	// ReadingsForType returns readings up to a specified limit of a given type
	ReadingsForType(readingType string, limit int, ctx context.Context) ([]models.Reading, error)
	// ReadingsForInterval returns readings up to a specified limit generated within a specific time period
	ReadingsForInterval(start int, end int, limit int, ctx context.Context) ([]models.Reading, error)
	// Add a new reading
	Add(readiing *models.Reading, ctx context.Context) (string, error)
	// Delete eliminates a reading by its id
	Delete(id string, ctx context.Context) error
}

ReadingClient defines the interface for interactions with the Reading endpoint on the EdgeX Foundry core-data service.

func NewReadingClient

func NewReadingClient(params types.EndpointParams, m clients.Endpointer) ReadingClient

NewReadingClient creates an instance of a ReadingClient

type ValueDescriptorClient

type ValueDescriptorClient interface {
	// ValueDescriptors returns a list of all value descriptors
	ValueDescriptors(ctx context.Context) ([]models.ValueDescriptor, error)
	// ValueDescriptor returns the value descriptor for the specified id
	ValueDescriptor(id string, ctx context.Context) (models.ValueDescriptor, error)
	// ValueDescriptorForName returns the value descriptor for the specified name
	ValueDescriptorForName(name string, ctx context.Context) (models.ValueDescriptor, error)
	// ValueDescriptorsByLabel returns the value descriptors for the specified label
	ValueDescriptorsByLabel(label string, ctx context.Context) ([]models.ValueDescriptor, error)
	// ValueDescriptorsForDevice returns the value descriptors associated with readings from the specified device (by id)
	ValueDescriptorsForDevice(deviceId string, ctx context.Context) ([]models.ValueDescriptor, error)
	// ValueDescriptorsForDeviceByName returns the value descriptors associated with readings from the specified device (by name)
	ValueDescriptorsForDeviceByName(deviceName string, ctx context.Context) ([]models.ValueDescriptor, error)
	// ValueDescriptorsByUomLabel returns the value descriptors for the specified uomLabel
	ValueDescriptorsByUomLabel(uomLabel string, ctx context.Context) ([]models.ValueDescriptor, error)
	// ValueDescriptorsUsage return a map describing which ValueDescriptors are currently in use. The key is the
	// ValueDescriptor name and the value is a bool specifying if the ValueDescriptor is in use.
	ValueDescriptorsUsage(names []string, ctx context.Context) (map[string]bool, error)
	// Adds the specified value descriptor
	Add(vdr *models.ValueDescriptor, ctx context.Context) (string, error)
	// Updates the specified value descriptor
	Update(vdr *models.ValueDescriptor, ctx context.Context) error
	// Delete eliminates a value descriptor (specified by id)
	Delete(id string, ctx context.Context) error
	// Delete eliminates a value descriptor (specified by name)
	DeleteByName(name string, ctx context.Context) error
}

ValueDescriptorClient defines the interface for interactions with the Value Descriptor endpoint on the EdgeX Foundry core-data service.

Jump to

Keyboard shortcuts

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