From 50fa71c94ecff035c8dda812077c1a19d7f04941 Mon Sep 17 00:00:00 2001 From: qclc <39878907+qclc@users.noreply.github.com> Date: Fri, 20 Aug 2021 11:59:31 +0800 Subject: [PATCH] Add interfaces which used to interact with the edge-side platform --- clients/interface.go | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 clients/interface.go diff --git a/clients/interface.go b/clients/interface.go new file mode 100644 index 0000000..5daaaa6 --- /dev/null +++ b/clients/interface.go @@ -0,0 +1,63 @@ +package clients + +import ( + "github.com/charleszheng44/device-controller/api/v1alpha1" + "github.com/go-resty/resty/v2" +) + +// Options represents the additional parameters required to manipulate the actual object +type Options map[string]string + +// DeviceInterface defines the interfaces which used to create, delete, update, get and list Device objects on edge-side platform +type DeviceInterface interface { + DevicePropertyInterface + Create(device *v1alpha1.Device, options Options) (string, error) + Delete(deviceName string, option Options) error + Update(device *v1alpha1.Device, options Options) (string, error) + Get(deviceName string, options Options) (*v1alpha1.Device, error) + List(options Options) ([]v1alpha1.Device, error) +} + +// DevicePropertyInterface defines the interfaces which used to get, list and set the actual status value of the device properties +type DevicePropertyInterface interface { + GetPropertyState(propertyName string, d *v1alpha1.Device, options Options) (*v1alpha1.ActualPropertyState, error) + SetPropertyState(propertyName string, d *v1alpha1.Device, options Options) (*resty.Response, error) + ListPropertiesState(deviceName string) (map[string]v1alpha1.DesiredPropertyState, map[string]v1alpha1.ActualPropertyState, error) +} + +// DeviceServiceInterface defines the interfaces which used to create, delete, update, get and list DeviceService objects on edge-side platform +type DeviceServiceInterface interface { + AddressableInterface + Create(deviceService *v1alpha1.DeviceService, options Options) (string, error) + Delete(deviceServiceName string) error + Update(deviceService *v1alpha1.DeviceService, options Options) (string, error) + Get(deviceServiceName string, options Options) (*v1alpha1.DeviceService, error) + List(options Options) ([]v1alpha1.DeviceService, error) +} + +// AddressableInterface defines the interfaces which used to create, delete, update, get and list Addressable objects on edge-side platform +type AddressableInterface interface { + CreateAddressable(addressable *v1alpha1.Addressable, options Options) (string, error) + DeleteAddressable(addressableName string, options Options) error + UpdateAddressable(device *v1alpha1.Addressable, options Options) (string, error) + GetAddressable(addressableName string, options Options) (*v1alpha1.Addressable, error) + ListAddressables(options Options) ([]v1alpha1.Addressable, error) +} + +// DeviceProfileInterface defines the interfaces which used to create, delete, update, get and list DeviceProfile objects on edge-side platform +type DeviceProfileInterface interface { + Create(deviceProfile *v1alpha1.DeviceProfile, options Options) (string, error) + Delete(deviceProfileName string, options Options) error + Update(deviceProfile *v1alpha1.DeviceProfile, options Options) (string, error) + Get(deviceProfileName string, options Options) (*v1alpha1.DeviceProfile, error) + List(options Options) ([]v1alpha1.DeviceProfile, error) +} + +// ValueDescriptorInterface defines the interfaces which used to create, delete, update, get and list valueDescriptor objects on edge-side platform +type ValueDescriptorInterface interface { + Create(valueDescriptor *v1alpha1.ValueDescriptor, options Options) (string, error) + Delete(valueDescriptorName string, options Options) error + Update(valueDescriptor *v1alpha1.ValueDescriptor, options Options) (string, error) + Get(valueDescriptorName string, options Options) (*v1alpha1.ValueDescriptor, error) + List(options Options) ([]v1alpha1.ValueDescriptor, error) +}