metadata

package
v0.1.58 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

README

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

How To Use

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

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

As an example of use, to find a device using the Metadata client, first create a new device client (see core-data init.go)

mdc = metadata.NewDeviceClient(params, types.Endpoint{})

And then use the device client to located a device by Device struct (see core-data event.go)

_, err := mdc.CheckForDevice(device)

Documentation

Overview

metadata provides clients used for integration with the core-metadata service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressableClient

type AddressableClient interface {
	// Add creates a new Addressable and returns the ID of the new item if successful.
	Add(ctx context.Context, addr *models.Addressable) (string, error)
	// Addressable returns an Addressable for the specified ID
	Addressable(ctx context.Context, id string) (models.Addressable, error)
	// Addressable returns an Addressable for the specified name
	AddressableForName(ctx context.Context, name string) (models.Addressable, error)
	// Update will update the Addressable data
	Update(ctx context.Context, addr models.Addressable) error
	// Delete will eliminate the Addressable for the specified ID
	Delete(ctx context.Context, id string) error
}

AddressableClient defines the interface for interactions with the Addressable endpoint on core-metadata.

func NewAddressableClient

func NewAddressableClient(urlClient interfaces.URLClient) AddressableClient

NewAddressableClient creates an instance of AddressableClient

type CommandClient

type CommandClient interface {
	// Add a new command
	Add(ctx context.Context, com *models.Command) (string, error)
	// Command obtains the command for the specified ID
	Command(ctx context.Context, id string) (models.Command, error)
	// Commands lists all the commands
	Commands(ctx context.Context) ([]models.Command, error)
	// CommandsForName lists all the commands for the specified name
	CommandsForName(ctx context.Context, name string) ([]models.Command, error)
	// CommandsForDeviceId list all commands for device with specified ID
	CommandsForDeviceId(ctx context.Context, id string) ([]models.Command, error)
	// Delete a command for the specified ID
	Delete(ctx context.Context, id string) error
	// Update a command
	Update(ctx context.Context, com models.Command) error
}

CommandClient defines the interface for interactions with the Command endpoint on core-metadata.

func NewCommandClient

func NewCommandClient(urlClient interfaces.URLClient) CommandClient

NewCommandClient creates an instance of CommandClient

type DeviceClient

type DeviceClient interface {
	// Add creates a new device
	Add(ctx context.Context, dev *models.Device) (string, error)
	// Delete eliminates a device for the specified ID
	Delete(ctx context.Context, id string) error
	// DeleteByName eliminates a device for the specified name
	DeleteByName(ctx context.Context, name string) error
	// CheckForDevice will return a Device if one already exists for the specified device name
	CheckForDevice(ctx context.Context, token string) (models.Device, error)
	// Device loads the device for the specified ID
	Device(ctx context.Context, id string) (models.Device, error)
	// DeviceForName loads the device for the specified name
	DeviceForName(ctx context.Context, name string) (models.Device, error)
	// Devices lists all devices
	Devices(ctx context.Context) ([]models.Device, error)
	// DevicesByLabel lists all devices for the specified label
	DevicesByLabel(ctx context.Context, label string) ([]models.Device, error)
	// DevicesForProfile lists all devices for the specified profile ID
	DevicesForProfile(ctx context.Context, profileid string) ([]models.Device, error)
	// DevicesForProfileByName lists all devices for the specified profile name
	DevicesForProfileByName(ctx context.Context, profileName string) ([]models.Device, error)
	// DevicesForService lists all devices for the specified device service ID
	DevicesForService(ctx context.Context, serviceid string) ([]models.Device, error)
	// DevicesForServiceByName lists all devices for the specified device service name
	DevicesForServiceByName(ctx context.Context, serviceName string) ([]models.Device, error)
	// Update the specified device
	Update(ctx context.Context, dev models.Device) error
	// UpdateAdminState modifies a device's AdminState for the specified device ID
	UpdateAdminState(ctx context.Context, id string, adminState string) error
	// UpdateAdminStateByName modifies a device's AdminState according to the specified device name
	UpdateAdminStateByName(ctx context.Context, name string, adminState string) error
	// UpdateLastConnected updates a device's last connected timestamp according to the specified device ID
	UpdateLastConnected(ctx context.Context, id string, time int64) error
	// UpdateLastConnectedByName updates a device's last connected timestamp according to the specified device name
	UpdateLastConnectedByName(ctx context.Context, name string, time int64) error
	// UpdateLastReported updates a device's last reported timestamp according to the specified device ID
	UpdateLastReported(ctx context.Context, id string, time int64) error
	// UpdateLastReportedByName updates a device's last reported timestamp according to the specified device name
	UpdateLastReportedByName(ctx context.Context, name string, time int64) error
	// UpdateOpState updates a device's last OperatingState according to the specified device ID
	UpdateOpState(ctx context.Context, id string, opState string) error
	// UpdateOpStateByName updates a device's last OperatingState according to the specified device name
	UpdateOpStateByName(ctx context.Context, name string, opState string) error
}

DeviceClient defines the interface for interactions with the Device endpoint on core-metadata.

func NewDeviceClient

func NewDeviceClient(urlClient interfaces.URLClient) DeviceClient

NewDeviceClient creates an instance of DeviceClient

type DeviceProfileClient

type DeviceProfileClient interface {
	// Add a new device profile
	Add(ctx context.Context, dp *models.DeviceProfile) (string, error)
	// Delete eliminates a device profile for the specified ID
	Delete(ctx context.Context, id string) error
	// DeleteByName eliminates a device profile for the specified name
	DeleteByName(ctx context.Context, name string) error
	// DeviceProfile loads the device profile for the specified ID
	DeviceProfile(ctx context.Context, id string) (models.DeviceProfile, error)
	// DeviceProfiles lists all device profiles
	DeviceProfiles(ctx context.Context) ([]models.DeviceProfile, error)
	// DeviceProfileForName loads the device profile for the specified name
	DeviceProfileForName(ctx context.Context, name string) (models.DeviceProfile, error)
	// Update a device profile
	Update(ctx context.Context, dp models.DeviceProfile) error
	// Upload a new device profile using raw YAML content
	Upload(ctx context.Context, yamlString string) (string, error)
	// Upload a new device profile using a file in YAML format
	UploadFile(ctx context.Context, yamlFilePath string) (string, error)
}

DeviceProfileClient defines the interface for interactions with the DeviceProfile endpoint on metadata.

func NewDeviceProfileClient

func NewDeviceProfileClient(urlClient interfaces.URLClient) DeviceProfileClient

Return an instance of DeviceProfileClient

type DeviceServiceClient

type DeviceServiceClient interface {
	// Add a new device service
	Add(ctx context.Context, ds *models.DeviceService) (string, error)
	// DeviceServiceForName loads a device service for the specified name
	DeviceServiceForName(ctx context.Context, name string) (models.DeviceService, error)
	// UpdateLastConnected updates a device service's last connected timestamp for the specified service ID
	UpdateLastConnected(ctx context.Context, id string, time int64) error
	// UpdateLastReported updates a device service's last reported timestamp for the specified service ID
	UpdateLastReported(ctx context.Context, id string, time int64) error
}

DeviceServiceClient defines the interface for interactions with the DeviceService endpoint on metadata.

func NewDeviceServiceClient

func NewDeviceServiceClient(urlClient interfaces.URLClient) DeviceServiceClient

NewDeviceServiceClient creates an instance of DeviceServiceClient

type ProvisionWatcherClient

type ProvisionWatcherClient interface {
	// Add a new provision watcher
	Add(ctx context.Context, dev *models.ProvisionWatcher) (string, error)
	// Delete a provision watcher for the specified ID
	Delete(ctx context.Context, id string) error
	// ProvisionWatcher loads an instance of a provision watcher for the specified ID
	ProvisionWatcher(ctx context.Context, id string) (models.ProvisionWatcher, error)
	// ProvisionWatcherForName loads an instance of a provision watcher for the specified name
	ProvisionWatcherForName(ctx context.Context, name string) (models.ProvisionWatcher, error)
	// ProvisionWatchers lists all provision watchers.
	ProvisionWatchers(ctx context.Context) ([]models.ProvisionWatcher, error)
	// ProvisionWatchersForService lists all provision watchers associated with the specified device service id
	ProvisionWatchersForService(ctx context.Context, serviceId string) ([]models.ProvisionWatcher, error)
	// ProvisionWatchersForServiceByName lists all provision watchers associated with the specified device service name
	ProvisionWatchersForServiceByName(ctx context.Context, serviceName string) ([]models.ProvisionWatcher, error)
	// ProvisionWatchersForProfile lists all provision watchers associated with the specified device profile ID
	ProvisionWatchersForProfile(ctx context.Context, profileID string) ([]models.ProvisionWatcher, error)
	// ProvisionWatchersForProfileByName lists all provision watchers associated with the specified device profile name
	ProvisionWatchersForProfileByName(ctx context.Context, profileName string) ([]models.ProvisionWatcher, error)
	// Update the provision watcher
	Update(ctx context.Context, dev models.ProvisionWatcher) error
}

ProvisionWatcherClient defines the interface for interactions with the ProvisionWatcher endpoint on metadata.

func NewProvisionWatcherClient

func NewProvisionWatcherClient(urlClient interfaces.URLClient) ProvisionWatcherClient

NewProvisionWatcherClient creates an instance of ProvisionWatcherClient

Jump to

Keyboard shortcuts

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