sdk

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: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contract

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

Contract default implementation of the smart contract interface

func (*Contract) RegisterEvent

func (c *Contract) RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *client.ChaincodeEvent, context.CancelFunc, error)

RegisterEvent register for chaincode events

func (*Contract) SubmitTransaction

func (c *Contract) SubmitTransaction(name string, args ...string) ([]byte, error)

SubmitTransaction submit a transaction to the ledger

type ContractInterface

type ContractInterface interface {
	// SubmitTransaction submit a transaction to the ledger
	SubmitTransaction(name string, args ...string) ([]byte, error)

	// RegisterEvent register for chaincode events
	RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *client.ChaincodeEvent, context.CancelFunc, error)
}

ContractInterface the smart contract interface

type DeviceEvent

type DeviceEvent struct {
	// Action name of the action performed on the device
	Action string

	// OrganizationId organization ID of the device
	OrganizationId string

	// DeviceId ID of the device
	DeviceId string

	// Payload custom event payload
	Payload interface{}
}

DeviceEvent an event emitted by the device registry contract notifying a device update

type DeviceRegistry

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

DeviceRegistry core utilities for managing devices on the ledger

func (*DeviceRegistry) Deregister

func (r *DeviceRegistry) Deregister(device *common.Device) error

Deregister remove a device from the ledger

func (*DeviceRegistry) Get

func (r *DeviceRegistry) Get(organizationId string, deviceId string) (*common.Device, error)

Get return a device by its organization ID and device ID

func (*DeviceRegistry) GetAll

func (r *DeviceRegistry) GetAll(organizationId string) ([]*common.Device, error)

GetAll return a list of devices by their organization ID

func (*DeviceRegistry) Register

func (r *DeviceRegistry) Register(device *common.Device) error

Register create or update a device in the ledger

func (*DeviceRegistry) RegisterEvent

func (r *DeviceRegistry) RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *DeviceEvent, context.CancelFunc, error)

RegisterEvent registers for device registry events

type DeviceRegistryInterface

type DeviceRegistryInterface interface {
	// Register create or update a device in the ledger
	Register(device *common.Device) error

	// Get return a device by its organization ID and device ID
	Get(organizationId string, deviceId string) (*common.Device, error)

	// GetAll return a list of devices by their organization ID
	GetAll(organizationId string) ([]*common.Device, error)

	// Deregister remove a device from the ledger
	Deregister(device *common.Device) error

	// RegisterEvent registers for device registry events
	RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *DeviceEvent, context.CancelFunc, error)
}

DeviceRegistryInterface core utilities for managing devices on the ledger

func CreateDeviceRegistry

func CreateDeviceRegistry(network *client.Network, chaincodeId string) DeviceRegistryInterface

CreateDeviceRegistry the default factory for creating device registries

type Sdk

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

Sdk the iot service blockchain sdk

func NewSdk

func NewSdk(options *SdkOptions) (*Sdk, error)

NewSdk create a new SDK instance from options

func (*Sdk) Close

func (s *Sdk) Close() error

Close close connection to the Hyperledger Fabric gateway

func (*Sdk) GetDeviceId

func (s *Sdk) GetDeviceId() string

GetDeviceId return the device/client ID of the current calling application

func (*Sdk) GetDeviceRegistry

func (s *Sdk) GetDeviceRegistry() DeviceRegistryInterface

GetDeviceRegistry return the device registry

func (*Sdk) GetOrganizationId

func (s *Sdk) GetOrganizationId() string

GetOrganizationId return the organization ID of the current calling application

func (*Sdk) GetServiceBroker

func (s *Sdk) GetServiceBroker() ServiceBrokerInterface

GetServiceBroker return the service broker

func (*Sdk) GetServiceRegistry

func (s *Sdk) GetServiceRegistry() ServiceRegistryInterface

GetServiceRegistry return the service registry

type SdkOptions

type SdkOptions struct {
	// OrganizationId organization/MSP ID
	OrganizationId string

	// Certificate PEM-formated X509 client certificate
	Certificate []byte

	// PrivateKey PEM-formated client private key
	PrivateKey []byte

	// GatewayPeerEndpoint network address of the gateway peer
	GatewayPeerEndpoint string

	// GatewayPeerServerName server name of the gateway peer
	GatewayPeerServerName string

	// GatewayPeerTLSCertificate PEM-formated X509 TLS certificate of the gateway peer
	GatewayPeerTLSCertificate []byte

	// NetworkName blockchain network channel name
	NetworkName string

	// ChaincodeId name of the chaincode
	ChaincodeId string
}

SdkOptions SDK initialization options

type ServiceBroker

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

ServiceBroker core utilities for managing IoT service requests and responses on the ledger

func (*ServiceBroker) Get

func (r *ServiceBroker) Get(requestId string) (*common.ServiceRequestResponse, error)

Get return an IoT service request and its response by the request ID

func (*ServiceBroker) GetAll

func (r *ServiceBroker) GetAll(organizationId string, deviceId string, serviceName string) ([]*common.ServiceRequestResponse, error)

GetAll return a list of IoT service requests and their responses by their organization ID, device ID, and service name

func (*ServiceBroker) RegisterEvent

func (r *ServiceBroker) RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *ServiceRequestEvent, context.CancelFunc, error)

RegisterEvent registers for service request events

func (*ServiceBroker) Remove

func (r *ServiceBroker) Remove(requestId string) error

Remove remove a (request, response) pair from the ledger

func (*ServiceBroker) Request

func (r *ServiceBroker) Request(request *common.ServiceRequest) error

Request make a request to an IoT service

func (*ServiceBroker) Respond

func (r *ServiceBroker) Respond(response *common.ServiceResponse) error

Respond respond to an IoT service request

type ServiceBrokerInterface

type ServiceBrokerInterface interface {
	// Request make a request to an IoT service
	Request(request *common.ServiceRequest) error

	// Respond respond to an IoT service request
	Respond(response *common.ServiceResponse) error

	// Get return an IoT service request and its response (if any) by the request ID
	Get(requestId string) (*common.ServiceRequestResponse, error)

	// GetAll return a list of IoT service requests and their responses (if any) by their service organization ID, service device ID, and service name
	GetAll(organizationId string, deviceId string, serviceName string) ([]*common.ServiceRequestResponse, error)

	// Remove remove a service request and its response (if any) from the ledger
	Remove(requestId string) error

	// RegisterEvent registers for service request events
	RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *ServiceRequestEvent, context.CancelFunc, error)
}

ServiceBrokerInterface core utilities for managing service requests on ledger

func CreateServiceBroker

func CreateServiceBroker(network *client.Network, chaincodeId string) ServiceBrokerInterface

CreateServiceBroker the default factory for creating service brokers

type ServiceEvent

type ServiceEvent struct {
	// Action name of the action performed on the service
	Action string

	// OrganizationId organization ID of the service
	OrganizationId string

	// DeviceId ID of the device to which the service belongs
	DeviceId string

	// ServiceName name of the service
	ServiceName string

	// Payload custom event payload
	Payload interface{}
}

ServiceEvent an event emitted by the service registry contract notifying a service update

type ServiceRegistry

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

ServiceRegistry core utilities for managing services on the ledger

func (*ServiceRegistry) Deregister

func (r *ServiceRegistry) Deregister(service *common.Service) error

Deregister remove a service from the ledger

func (*ServiceRegistry) Get

func (r *ServiceRegistry) Get(organizationId string, deviceId string, serviceName string) (*common.Service, error)

Get return a service by its organization ID, device ID, and name

func (*ServiceRegistry) GetAll

func (r *ServiceRegistry) GetAll(organizationId string, deviceId string) ([]*common.Service, error)

GetAll return a list of services by their organization ID and device ID

func (*ServiceRegistry) Register

func (r *ServiceRegistry) Register(service *common.Service) error

Register create or update a service in the ledger

func (*ServiceRegistry) RegisterEvent

func (r *ServiceRegistry) RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *ServiceEvent, context.CancelFunc, error)

RegisterEvent registers for service registry events

type ServiceRegistryInterface

type ServiceRegistryInterface interface {
	// Register create or update a service in the ledger
	Register(service *common.Service) error

	// Get return a service by its organization ID, device ID, and name
	Get(organizationId string, deviceId string, serviceName string) (*common.Service, error)

	// GetAll return a list of services by their organization ID and device ID
	GetAll(organizationId string, deviceId string) ([]*common.Service, error)

	// Deregister remove a service from the ledger
	Deregister(service *common.Service) error

	// RegisterEvent registers for service registry events
	RegisterEvent(options ...client.ChaincodeEventsOption) (<-chan *ServiceEvent, context.CancelFunc, error)
}

ServiceRegistryInterface core utilities for managing services on the ledger

func CreateServiceRegistry

func CreateServiceRegistry(network *client.Network, chaincodeId string) ServiceRegistryInterface

CreateServiceRegistry the default factory for creating service registries

type ServiceRequestEvent

type ServiceRequestEvent struct {
	// Action name of the action performed on the service request
	Action string

	// OrganizationId organization ID of the requested service
	OrganizationId string

	// DeviceId device ID of the requested service
	DeviceId string

	// ServiceName name of the requested service
	ServiceName string

	// RequestId ID of the request
	RequestId string

	// Payload custom event payload
	Payload interface{}
}

ServiceRequestEvent an event emitted by the service broker contract notifying a service request/response update

Jump to

Keyboard shortcuts

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