metadata

package
v0.0.0-...-7b61fee Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 6 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/Circutor/edgex/pkg/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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressableClient

type AddressableClient interface {
	Add(addr *models.Addressable, ctx context.Context) (string, error)
	Addressable(id string, ctx context.Context) (models.Addressable, error)
	AddressableForName(name string, ctx context.Context) (models.Addressable, error)
	Update(addr models.Addressable, ctx context.Context) error
	Delete(id string, ctx context.Context) error
}

Addressable client for interacting with the addressable section of metadata

func NewAddressableClient

func NewAddressableClient(url string) AddressableClient

Return an instance of AddressableClient

type AddressableRestClient

type AddressableRestClient struct {
	// contains filtered or unexported fields
}

func (*AddressableRestClient) Add

Add an addressable - handle error codes Returns the ID of the addressable and an error

func (*AddressableRestClient) Addressable

func (a *AddressableRestClient) Addressable(id string, ctx context.Context) (models.Addressable, error)

Get an addressable by id

func (*AddressableRestClient) AddressableForName

func (a *AddressableRestClient) AddressableForName(name string, ctx context.Context) (models.Addressable, error)

Get the addressable by name

func (*AddressableRestClient) Delete

func (a *AddressableRestClient) Delete(id string, ctx context.Context) error

Delete a addressable (specified by id)

func (*AddressableRestClient) Update

Update a addressable

type CommandClient

type CommandClient interface {
	Add(com *models.Command, ctx context.Context) (string, error)
	Command(id string, ctx context.Context) (models.Command, error)
	Commands(ctx context.Context) ([]models.Command, error)
	CommandsForName(name string, ctx context.Context) ([]models.Command, error)
	Delete(id string, ctx context.Context) error
	Update(com models.Command, ctx context.Context) error
}

Command client for interacting with the command section of metadata

func NewCommandClient

func NewCommandClient(url string) CommandClient

Return an instance of CommandClient

type CommandRestClient

type CommandRestClient struct {
	// contains filtered or unexported fields
}

func (*CommandRestClient) Add

Add a new command

func (*CommandRestClient) Command

func (c *CommandRestClient) Command(id string, ctx context.Context) (models.Command, error)

Get a command by id

func (*CommandRestClient) Commands

func (c *CommandRestClient) Commands(ctx context.Context) ([]models.Command, error)

Get a list of all the commands

func (*CommandRestClient) CommandsForName

func (c *CommandRestClient) CommandsForName(name string, ctx context.Context) ([]models.Command, error)

Get a list of commands for a certain name

func (*CommandRestClient) Delete

func (c *CommandRestClient) Delete(id string, ctx context.Context) error

Delete a command

func (*CommandRestClient) Update

func (c *CommandRestClient) Update(com models.Command, ctx context.Context) error

Update a command

type DeviceClient

type DeviceClient interface {
	Add(dev *models.Device, ctx context.Context) (string, error)
	Delete(id string, ctx context.Context) error
	DeleteByName(name string, ctx context.Context) error
	CheckForDevice(token string, ctx context.Context) (models.Device, error)
	Device(id string, ctx context.Context) (models.Device, error)
	DeviceForName(name string, ctx context.Context) (models.Device, error)
	Devices(ctx context.Context) ([]models.Device, error)
	DevicesByLabel(label string, ctx context.Context) ([]models.Device, error)
	DevicesForProfile(profileid string, ctx context.Context) ([]models.Device, error)
	DevicesForProfileByName(profileName string, ctx context.Context) ([]models.Device, error)
	DevicesForService(serviceid string, ctx context.Context) ([]models.Device, error)
	DevicesForServiceByName(serviceName string, ctx context.Context) ([]models.Device, error)
	Update(dev models.Device, ctx context.Context) error
	UpdateAdminState(id string, adminState string, ctx context.Context) error
	UpdateAdminStateByName(name string, adminState string, ctx context.Context) error
	UpdateLastConnected(id string, time int64, ctx context.Context) error
	UpdateLastConnectedByName(name string, time int64, ctx context.Context) error
	UpdateLastReported(id string, time int64, ctx context.Context) error
	UpdateLastReportedByName(name string, time int64, ctx context.Context) error
	UpdateOpState(id string, opState string, ctx context.Context) error
	UpdateOpStateByName(name string, opState string, ctx context.Context) error
}

Device client for interacting with the device section of metadata

func NewDeviceClient

func NewDeviceClient(url string) DeviceClient

Return an instance of DeviceClient

type DeviceProfileClient

type DeviceProfileClient interface {
	Add(dp *models.DeviceProfile, ctx context.Context) (string, error)
	Delete(id string, ctx context.Context) error
	DeleteByName(name string, ctx context.Context) error
	DeviceProfile(id string, ctx context.Context) (models.DeviceProfile, error)
	DeviceProfiles(ctx context.Context) ([]models.DeviceProfile, error)
	DeviceProfileForName(name string, ctx context.Context) (models.DeviceProfile, error)
	Update(dp models.DeviceProfile, ctx context.Context) error
	Upload(yamlString string, ctx context.Context) (string, error)
	UploadFile(yamlFilePath string, ctx context.Context) (string, error)
}

Device Profile client for interacting with the device profile section of metadata

func NewDeviceProfileClient

func NewDeviceProfileClient(url string) DeviceProfileClient

Return an instance of DeviceProfileClient

type DeviceProfileRestClient

type DeviceProfileRestClient struct {
	// contains filtered or unexported fields
}

func (*DeviceProfileRestClient) Add

Add a new device profile to metadata

func (*DeviceProfileRestClient) Delete

func (dpc *DeviceProfileRestClient) Delete(id string, ctx context.Context) error

Delete a device profile (specified by id)

func (*DeviceProfileRestClient) DeleteByName

func (dpc *DeviceProfileRestClient) DeleteByName(name string, ctx context.Context) error

Delete a device profile (specified by name)

func (*DeviceProfileRestClient) DeviceProfile

func (dpc *DeviceProfileRestClient) DeviceProfile(id string, ctx context.Context) (models.DeviceProfile, error)

Get the device profile by id

func (*DeviceProfileRestClient) DeviceProfileForName

func (dpc *DeviceProfileRestClient) DeviceProfileForName(name string, ctx context.Context) (models.DeviceProfile, error)

Get the device profile by name

func (*DeviceProfileRestClient) DeviceProfiles

func (dpc *DeviceProfileRestClient) DeviceProfiles(ctx context.Context) ([]models.DeviceProfile, error)

Get a list of all devices

func (*DeviceProfileRestClient) Update

Update an existing device profile in metadata

func (*DeviceProfileRestClient) Upload

func (dpc *DeviceProfileRestClient) Upload(yamlString string, ctx context.Context) (string, error)

func (*DeviceProfileRestClient) UploadFile

func (dpc *DeviceProfileRestClient) UploadFile(yamlFilePath string, ctx context.Context) (string, error)

type DeviceRestClient

type DeviceRestClient struct {
	// contains filtered or unexported fields
}

func (*DeviceRestClient) Add

func (d *DeviceRestClient) Add(dev *models.Device, ctx context.Context) (string, error)

Add a device - handle error codes

func (*DeviceRestClient) CheckForDevice

func (d *DeviceRestClient) CheckForDevice(token string, ctx context.Context) (models.Device, error)

Use the models.Event.Device property for the supplied token parameter. The above property is currently double-purposed and needs to be refactored. This call replaces the previous two calls necessary to lookup a device by id followed by name.

func (*DeviceRestClient) Delete

func (d *DeviceRestClient) Delete(id string, ctx context.Context) error

Delete a device (specified by id)

func (*DeviceRestClient) DeleteByName

func (d *DeviceRestClient) DeleteByName(name string, ctx context.Context) error

Delete a device (specified by name)

func (*DeviceRestClient) Device

func (d *DeviceRestClient) Device(id string, ctx context.Context) (models.Device, error)

Get the device by id

func (*DeviceRestClient) DeviceForName

func (d *DeviceRestClient) DeviceForName(name string, ctx context.Context) (models.Device, error)

Get the device by name

func (*DeviceRestClient) Devices

func (d *DeviceRestClient) Devices(ctx context.Context) ([]models.Device, error)

Get a list of all devices

func (*DeviceRestClient) DevicesByLabel

func (d *DeviceRestClient) DevicesByLabel(label string, ctx context.Context) ([]models.Device, error)

Get the device by label

func (*DeviceRestClient) DevicesForProfile

func (d *DeviceRestClient) DevicesForProfile(profileId string, ctx context.Context) ([]models.Device, error)

Get the devices for a profile

func (*DeviceRestClient) DevicesForProfileByName

func (d *DeviceRestClient) DevicesForProfileByName(profileName string, ctx context.Context) ([]models.Device, error)

Get the devices for a profile (by name)

func (*DeviceRestClient) DevicesForService

func (d *DeviceRestClient) DevicesForService(serviceId string, ctx context.Context) ([]models.Device, error)

Get the devices that are on a service

func (*DeviceRestClient) DevicesForServiceByName

func (d *DeviceRestClient) DevicesForServiceByName(serviceName string, ctx context.Context) ([]models.Device, error)

Get the devices that are on a service(by name)

func (*DeviceRestClient) Update

func (d *DeviceRestClient) Update(dev models.Device, ctx context.Context) error

Update a device - handle error codes

func (*DeviceRestClient) UpdateAdminState

func (d *DeviceRestClient) UpdateAdminState(id string, adminState string, ctx context.Context) error

Update the adminState value for a device (specified by id)

func (*DeviceRestClient) UpdateAdminStateByName

func (d *DeviceRestClient) UpdateAdminStateByName(name string, adminState string, ctx context.Context) error

Update the adminState value for a device (specified by name)

func (*DeviceRestClient) UpdateLastConnected

func (d *DeviceRestClient) UpdateLastConnected(id string, time int64, ctx context.Context) error

Update the lastConnected value for a device (specified by id)

func (*DeviceRestClient) UpdateLastConnectedByName

func (d *DeviceRestClient) UpdateLastConnectedByName(name string, time int64, ctx context.Context) error

Update the lastConnected value for a device (specified by name)

func (*DeviceRestClient) UpdateLastReported

func (d *DeviceRestClient) UpdateLastReported(id string, time int64, ctx context.Context) error

Update the lastReported value for a device (specified by id)

func (*DeviceRestClient) UpdateLastReportedByName

func (d *DeviceRestClient) UpdateLastReportedByName(name string, time int64, ctx context.Context) error

Update the lastReported value for a device (specified by name)

func (*DeviceRestClient) UpdateOpState

func (d *DeviceRestClient) UpdateOpState(id string, opState string, ctx context.Context) error

Update the opState value for a device (specified by id)

func (*DeviceRestClient) UpdateOpStateByName

func (d *DeviceRestClient) UpdateOpStateByName(name string, opState string, ctx context.Context) error

Update the opState value for a device (specified by name)

type DeviceServiceClient

type DeviceServiceClient interface {
	Add(ds *models.DeviceService, ctx context.Context) (string, error)
	DeviceServiceForName(name string, ctx context.Context) (models.DeviceService, error)
	UpdateLastConnected(id string, time int64, ctx context.Context) error
	UpdateLastReported(id string, time int64, ctx context.Context) error
}

Service client for interacting with the device service section of metadata

func NewDeviceServiceClient

func NewDeviceServiceClient(url string) DeviceServiceClient

Return an instance of DeviceServiceClient

type DeviceServiceRestClient

type DeviceServiceRestClient struct {
	// contains filtered or unexported fields
}

func (*DeviceServiceRestClient) Add

Add a new deviceservice

func (*DeviceServiceRestClient) DeviceServiceForName

func (s *DeviceServiceRestClient) DeviceServiceForName(name string, ctx context.Context) (models.DeviceService, error)

Request deviceservice for specified name

func (*DeviceServiceRestClient) UpdateLastConnected

func (s *DeviceServiceRestClient) UpdateLastConnected(id string, time int64, ctx context.Context) error

Update the last connected time for the device service

func (*DeviceServiceRestClient) UpdateLastReported

func (s *DeviceServiceRestClient) UpdateLastReported(id string, time int64, ctx context.Context) error

Update the last reported time for the device service

type ProvisionWatcherClient

type ProvisionWatcherClient interface {
	Add(dev *models.ProvisionWatcher, ctx context.Context) (string, error)
	Delete(id string, ctx context.Context) error
	ProvisionWatcher(id string, ctx context.Context) (models.ProvisionWatcher, error)
	ProvisionWatcherForName(name string, ctx context.Context) (models.ProvisionWatcher, error)
	ProvisionWatchers(ctx context.Context) ([]models.ProvisionWatcher, error)
	ProvisionWatchersForService(serviceId string, ctx context.Context) ([]models.ProvisionWatcher, error)
	ProvisionWatchersForServiceByName(serviceName string, ctx context.Context) ([]models.ProvisionWatcher, error)
	ProvisionWatchersForProfile(profileid string, ctx context.Context) ([]models.ProvisionWatcher, error)
	ProvisionWatchersForProfileByName(profileName string, ctx context.Context) ([]models.ProvisionWatcher, error)
	Update(dev models.ProvisionWatcher, ctx context.Context) error
}

Provision Watcher client for interacting with the provision watcher section of metadata

func NewProvisionWatcherClient

func NewProvisionWatcherClient(url string) ProvisionWatcherClient

Return an instance of ProvisionWatcherClient

type ProvisionWatcherRestClient

type ProvisionWatcherRestClient struct {
	// contains filtered or unexported fields
}

func (*ProvisionWatcherRestClient) Add

Add a provision watcher - handle error codes

func (*ProvisionWatcherRestClient) Delete

Delete a provision watcher (specified by id)

func (*ProvisionWatcherRestClient) ProvisionWatcher

Get the provision watcher by id

func (*ProvisionWatcherRestClient) ProvisionWatcherForName

func (pw *ProvisionWatcherRestClient) ProvisionWatcherForName(name string, ctx context.Context) (models.ProvisionWatcher, error)

Get the provision watcher by name

func (*ProvisionWatcherRestClient) ProvisionWatchers

func (pw *ProvisionWatcherRestClient) ProvisionWatchers(ctx context.Context) ([]models.ProvisionWatcher, error)

Get a list of all provision watchers

func (*ProvisionWatcherRestClient) ProvisionWatchersForProfile

func (pw *ProvisionWatcherRestClient) ProvisionWatchersForProfile(profileId string, ctx context.Context) ([]models.ProvisionWatcher, error)

Get the provision watchers for a profile

func (*ProvisionWatcherRestClient) ProvisionWatchersForProfileByName

func (pw *ProvisionWatcherRestClient) ProvisionWatchersForProfileByName(profileName string, ctx context.Context) ([]models.ProvisionWatcher, error)

Get the provision watchers for a profile (by name)

func (*ProvisionWatcherRestClient) ProvisionWatchersForService

func (pw *ProvisionWatcherRestClient) ProvisionWatchersForService(serviceId string, ctx context.Context) ([]models.ProvisionWatcher, error)

Get the provision watchers that are on a service

func (*ProvisionWatcherRestClient) ProvisionWatchersForServiceByName

func (pw *ProvisionWatcherRestClient) ProvisionWatchersForServiceByName(serviceName string, ctx context.Context) ([]models.ProvisionWatcher, error)

Get the provision watchers that are on a service(by name)

func (*ProvisionWatcherRestClient) Update

Update a provision watcher - handle error codes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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