Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Add interfaces which used to interact with the edge-side platform
Browse files Browse the repository at this point in the history
  • Loading branch information
qclc committed Aug 20, 2021
1 parent e764d4b commit 50fa71c
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions clients/interface.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 50fa71c

Please sign in to comment.