common

package
v0.0.0-...-0030b84 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: GPL-3.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientId

func GetClientId(cert *x509.Certificate) (string, error)

GetClientId return unique client ID from client certificate.

func ParseCertificate

func ParseCertificate(certificate []byte) (*x509.Certificate, error)

ParseCertificate parse an X509 certificate from PEM string

Types

type Device

type Device struct {
	// Id identity of the device
	Id string `json:"id"`

	// Id identity of the organization to which the device belongs
	OrganizationId string `json:"organizationId"`

	// Name friendly name of the device
	Name string `json:"name"`

	// Description a brief summary of the device's functions
	Description string `json:"description"`

	// LastUpdateTime the latest time that the device state has been updated
	LastUpdateTime time.Time `json:"lastUpdateTime"`
}

Device an IoT device state

func DeserializeDevice

func DeserializeDevice(data []byte) (*Device, error)

DeserializeDevice create a new device instance from its JSON representation

func (*Device) GetKeyComponents

func (d *Device) GetKeyComponents() []string

GetKeyComponents return components that compose the device key

func (*Device) Serialize

func (d *Device) Serialize() ([]byte, error)

Serialize transform current device to JSON string

func (*Device) Validate

func (d *Device) Validate() error

Validate check if the device properties are valid

type NotFoundError

type NotFoundError struct {
	What string
}

NotFoundError an error indicates something is not found in the ledger

func (NotFoundError) Error

func (e NotFoundError) Error() string

Error get the error message

type Service

type Service struct {
	// Name name of the IoT service
	Name string `json:"name"`

	// DeviceId identity of the device to which the IoT service belongs
	DeviceId string `json:"deviceId"`

	// OrganizationId identity of the organization to which the IoT service belongs
	OrganizationId string `json:"organizationId"`

	// Version version number of the IoT service
	Version int32 `json:"version"`

	// Description a brief summary of the service's functions
	Description string `json:"description"`

	// LastUpdateTime the latest time that the service state has been updated
	LastUpdateTime time.Time `json:"lastUpdateTime"`
}

Service an IoT service state

func DeserializeService

func DeserializeService(data []byte) (*Service, error)

DeserializeService create an IoT service instance from its JSON representation

func (*Service) GetKeyComponents

func (s *Service) GetKeyComponents() []string

GetKeyComponents return components that compose the IoT service key

func (*Service) Serialize

func (s *Service) Serialize() ([]byte, error)

Serialize transform current IoT service to JSON string

func (*Service) Validate

func (s *Service) Validate() error

Validate check if the IoT service properties are valid

type ServiceRequest

type ServiceRequest struct {
	// Id identity of the IoT service request
	Id string `json:"id"`

	// Time time of the IoT service request
	Time time.Time `json:"time"`

	// Service requested IoT service information
	Service Service `json:"service"`

	// Method IoT service request method
	Method string `json:"method"`

	// Arguments IoT service request arguments
	Arguments []string `json:"arguments"`
}

ServiceRequest an IoT service request

func DeserializeServiceRequest

func DeserializeServiceRequest(data []byte) (*ServiceRequest, error)

DeserializeService create an IoT service request instance from its JSON representation

func (*ServiceRequest) GetKeyComponents

func (r *ServiceRequest) GetKeyComponents() []string

GetKeyComponents return components that compose the IoT service request key

func (*ServiceRequest) Serialize

func (r *ServiceRequest) Serialize() ([]byte, error)

Serialize transform current IoT service request to JSON string

func (*ServiceRequest) Validate

func (r *ServiceRequest) Validate() error

Validate check if the IoT service request properties are valid

type ServiceRequestResponse

type ServiceRequestResponse struct {
	// Request IoT service request
	Request *ServiceRequest `json:"request"`

	// Request IoT service response
	Response *ServiceResponse `json:"response"`
}

ServiceRequestResponse a wrapper of a pair of IoT service request and response

func DeserializeServiceRequestResponse

func DeserializeServiceRequestResponse(data []byte) (*ServiceRequestResponse, error)

DeserializeService create an IoT service response instance from its JSON representation

func (*ServiceRequestResponse) Serialize

func (r *ServiceRequestResponse) Serialize() ([]byte, error)

Serialize transform current IoT service response to JSON string

type ServiceResponse

type ServiceResponse struct {
	// RequestId identity of the IoT service request to respond to
	RequestId string `json:"requestId"`

	// Time time of the IoT service response
	Time time.Time `json:"time"`

	// StatusCode status code of the IoT service response
	StatusCode int32 `json:"statusCode"`

	// ReturnValue return value of the IoT service response
	ReturnValue string `json:"returnValue"`
}

ServiceRequest an IoT service response

func DeserializeServiceResponse

func DeserializeServiceResponse(data []byte) (*ServiceResponse, error)

DeserializeService create an IoT service response instance from its JSON representation

func (*ServiceResponse) GetKeyComponents

func (r *ServiceResponse) GetKeyComponents() []string

GetKeyComponents return components that compose the IoT service response key

func (*ServiceResponse) Serialize

func (r *ServiceResponse) Serialize() ([]byte, error)

Serialize transform current IoT service response to JSON string

func (*ServiceResponse) Validate

func (r *ServiceResponse) Validate() error

Validate check if the IoT service response properties are valid

Jump to

Keyboard shortcuts

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