Documentation
¶
Overview ¶
* Smart contracts and chaincode functions.
Index ¶
- type DeviceRegistry
- func (r *DeviceRegistry) Deregister(device *common.Device) error
- func (r *DeviceRegistry) Get(organizationId string, deviceId string) (*common.Device, error)
- func (r *DeviceRegistry) GetAll(organizationId string) ([]*common.Device, error)
- func (r *DeviceRegistry) Register(device *common.Device) error
- type DeviceRegistryInterface
- type DeviceRegistrySmartContract
- func (s *DeviceRegistrySmartContract) Deregister(ctx TransactionContextInterface, data string) error
- func (s *DeviceRegistrySmartContract) Get(ctx TransactionContextInterface, organizationId string, deviceId string) (*common.Device, error)
- func (s *DeviceRegistrySmartContract) GetAll(ctx TransactionContextInterface, organizationId string) ([]*common.Device, error)
- func (s *DeviceRegistrySmartContract) Register(ctx TransactionContextInterface, data string) error
- type ServiceBroker
- func (b *ServiceBroker) Get(requestId string) (*common.ServiceRequestResponse, error)
- func (b *ServiceBroker) GetAll(organizationId string, deviceId string, serviceName string) ([]*common.ServiceRequestResponse, error)
- func (b *ServiceBroker) Remove(requestId string) error
- func (b *ServiceBroker) Request(request *common.ServiceRequest) error
- func (b *ServiceBroker) Respond(response *common.ServiceResponse) error
- type ServiceBrokerInterface
- type ServiceBrokerSmartContract
- func (s *ServiceBrokerSmartContract) Get(ctx TransactionContextInterface, requestId string) (*common.ServiceRequestResponse, error)
- func (s *ServiceBrokerSmartContract) GetAll(ctx TransactionContextInterface, organizationId string, deviceId string, ...) ([]*common.ServiceRequestResponse, error)
- func (s *ServiceBrokerSmartContract) Remove(ctx TransactionContextInterface, requestId string) error
- func (s *ServiceBrokerSmartContract) Request(ctx TransactionContextInterface, data string) error
- func (s *ServiceBrokerSmartContract) Respond(ctx TransactionContextInterface, data string) error
- type ServiceRegistry
- func (r *ServiceRegistry) Deregister(service *common.Service) error
- func (r *ServiceRegistry) Get(organizationId string, deviceId string, name string) (*common.Service, error)
- func (r *ServiceRegistry) GetAll(organizationId string, deviceId string) ([]*common.Service, error)
- func (r *ServiceRegistry) Register(service *common.Service) error
- type ServiceRegistryInterface
- type ServiceRegistrySmartContract
- func (s *ServiceRegistrySmartContract) Deregister(ctx TransactionContextInterface, data string) error
- func (s *ServiceRegistrySmartContract) Get(ctx TransactionContextInterface, organizationId string, deviceId string, ...) (*common.Service, error)
- func (s *ServiceRegistrySmartContract) GetAll(ctx TransactionContextInterface, organizationId string, deviceId string) ([]*common.Service, error)
- func (s *ServiceRegistrySmartContract) Register(ctx TransactionContextInterface, data string) error
- type StateInterface
- type StateRegistry
- type StateRegistryInterface
- type TransactionContext
- func (c *TransactionContext) GetDeviceId() (string, error)
- func (c *TransactionContext) GetDeviceRegistry() DeviceRegistryInterface
- func (c *TransactionContext) GetOrganizationId() (string, error)
- func (c *TransactionContext) GetServiceBroker() ServiceBrokerInterface
- func (c *TransactionContext) GetServiceRegistry() ServiceRegistryInterface
- type TransactionContextInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
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
}
DeviceRegistryInterface core utilities for managing devices on the ledger
type DeviceRegistrySmartContract ¶
type DeviceRegistrySmartContract struct {
contractapi.Contract
}
DeviceRegistrySmartContract smart contract for managing devices on the ledger
func (*DeviceRegistrySmartContract) Deregister ¶
func (s *DeviceRegistrySmartContract) Deregister(ctx TransactionContextInterface, data string) error
Deregister remove a device and its services from the ledger
func (*DeviceRegistrySmartContract) Get ¶
func (s *DeviceRegistrySmartContract) Get(ctx TransactionContextInterface, organizationId string, deviceId string) (*common.Device, error)
Get return a device by its organization ID and device ID
func (*DeviceRegistrySmartContract) GetAll ¶
func (s *DeviceRegistrySmartContract) GetAll(ctx TransactionContextInterface, organizationId string) ([]*common.Device, error)
GetAll return a list of devices by their organization ID
func (*DeviceRegistrySmartContract) Register ¶
func (s *DeviceRegistrySmartContract) Register(ctx TransactionContextInterface, data string) error
Register create or update a device in the ledger
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 (b *ServiceBroker) Get(requestId string) (*common.ServiceRequestResponse, error)
Get return an IoT service request and its response by the request ID
func (*ServiceBroker) GetAll ¶
func (b *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) Remove ¶
func (b *ServiceBroker) Remove(requestId string) error
Remove remove a (request, response) pair from the ledger
func (*ServiceBroker) Request ¶
func (b *ServiceBroker) Request(request *common.ServiceRequest) error
Request make a request to an IoT service
func (*ServiceBroker) Respond ¶
func (b *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 by the request ID
Get(requestId string) (*common.ServiceRequestResponse, error)
// GetAll return a list of IoT service requests and their responses by their organization ID, device ID, and service name
GetAll(organizationId string, deviceId string, serviceName string) ([]*common.ServiceRequestResponse, error)
// Remove remove a (request, response) pair from the ledger
Remove(requestId string) error
}
ServiceBrokerInterface core utilities for managing service requests on ledger
type ServiceBrokerSmartContract ¶
type ServiceBrokerSmartContract struct {
contractapi.Contract
}
ServiceBrokerSmartContract smart contract for managing IoT service requests and responses
func (*ServiceBrokerSmartContract) Get ¶
func (s *ServiceBrokerSmartContract) Get(ctx TransactionContextInterface, requestId string) (*common.ServiceRequestResponse, error)
Get return an IoT service request and its response by the request ID
func (*ServiceBrokerSmartContract) GetAll ¶
func (s *ServiceBrokerSmartContract) GetAll(ctx TransactionContextInterface, 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 (*ServiceBrokerSmartContract) Remove ¶
func (s *ServiceBrokerSmartContract) Remove(ctx TransactionContextInterface, requestId string) error
Remove remove a (request, response) pair from the ledger
func (*ServiceBrokerSmartContract) Request ¶
func (s *ServiceBrokerSmartContract) Request(ctx TransactionContextInterface, data string) error
Request make a request to an IoT service
func (*ServiceBrokerSmartContract) Respond ¶
func (s *ServiceBrokerSmartContract) Respond(ctx TransactionContextInterface, data string) error
Respond respond to an IoT service request
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, name string) (*common.Service, error)
Get return a service by its organization ID, device ID, and name
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
}
ServiceRegistryInterface core utilities for managing services on the ledger
type ServiceRegistrySmartContract ¶
type ServiceRegistrySmartContract struct {
contractapi.Contract
}
ServiceRegistrySmartContract smart contract for managing IoT services on the ledger
func (*ServiceRegistrySmartContract) Deregister ¶
func (s *ServiceRegistrySmartContract) Deregister(ctx TransactionContextInterface, data string) error
Deregister remove an IoT service and its request/responses from the ledger
func (*ServiceRegistrySmartContract) Get ¶
func (s *ServiceRegistrySmartContract) Get(ctx TransactionContextInterface, organizationId string, deviceId string, name string) (*common.Service, error)
Get return a device by its organization ID, device ID, and name
func (*ServiceRegistrySmartContract) GetAll ¶
func (s *ServiceRegistrySmartContract) GetAll(ctx TransactionContextInterface, organizationId string, deviceId string) ([]*common.Service, error)
GetAll return a list of devices by their organization ID and device ID
func (*ServiceRegistrySmartContract) Register ¶
func (s *ServiceRegistrySmartContract) Register(ctx TransactionContextInterface, data string) error
Register create or update an IoT service in the ledger
type StateInterface ¶
type StateInterface interface {
// GetKeyComponents return components that compose the state key
GetKeyComponents() []string
// Serialize transform current state object to JSON string
Serialize() ([]byte, error)
// Validate check if the state properties are valid
Validate() error
}
StateInterface common ledger state interface
type StateRegistry ¶
type StateRegistry struct {
// Name name of the state list
Name string
// Deserialize create a new state instance from its JSON representation
Deserialize func([]byte) (StateInterface, error)
// contains filtered or unexported fields
}
StateRegistry default implementations of StateRegistryInterface
func (*StateRegistry) GetState ¶
func (r *StateRegistry) GetState(key ...string) (StateInterface, error)
GetState return a state by its key
func (*StateRegistry) GetStates ¶
func (r *StateRegistry) GetStates(key ...string) ([]StateInterface, error)
GetStates return a list of states by their partial composite key
func (*StateRegistry) PutState ¶
func (r *StateRegistry) PutState(state StateInterface) error
PutState create or update a state in the ledger
func (*StateRegistry) RemoveState ¶
func (r *StateRegistry) RemoveState(state StateInterface) error
RemoveState remove a state from the ledger
type StateRegistryInterface ¶
type StateRegistryInterface interface {
// PutState create or update a state in the ledger
PutState(state StateInterface) error
// GetState return a state by its key components
GetState(keyComponents ...string) (StateInterface, error)
// GetStates return a list of states by key components
GetStates(keyComponents ...string) ([]StateInterface, error)
// RemoveState remove a state from the ledger
RemoveState(state StateInterface) error
}
StateRegistryInterface core utilities for managing a list of ledger states
type TransactionContext ¶
type TransactionContext struct {
contractapi.TransactionContext
// contains filtered or unexported fields
}
TransactionContext an implementation of TransactionContextInterface
func (*TransactionContext) GetDeviceId ¶
func (c *TransactionContext) GetDeviceId() (string, error)
GetDeviceId returns the ID associated with the invoking identity which is unique within the MSP
func (*TransactionContext) GetDeviceRegistry ¶
func (c *TransactionContext) GetDeviceRegistry() DeviceRegistryInterface
GetDeviceRegistry get the device registry instance
func (*TransactionContext) GetOrganizationId ¶
func (c *TransactionContext) GetOrganizationId() (string, error)
GetOrganizationId return the organization MSP ID
func (*TransactionContext) GetServiceBroker ¶
func (c *TransactionContext) GetServiceBroker() ServiceBrokerInterface
GetServiceBroker get the device broker instance
func (*TransactionContext) GetServiceRegistry ¶
func (c *TransactionContext) GetServiceRegistry() ServiceRegistryInterface
GetServiceRegistry get the device registry instance
type TransactionContextInterface ¶
type TransactionContextInterface interface {
contractapi.TransactionContextInterface
// GetOrganizationId return the organization MSP ID
GetOrganizationId() (string, error)
// GetDeviceId returns the ID associated with the invoking identity which is unique within the MSP
GetDeviceId() (string, error)
// GetDeviceRegistry get the default instance of device registry
GetDeviceRegistry() DeviceRegistryInterface
// GetServiceRegistry get the default instance of service registry
GetServiceRegistry() ServiceRegistryInterface
// GetServiceBroker get the default instance of service broker
GetServiceBroker() ServiceBrokerInterface
}
TransactionContextInterface extends the default transaction context with specific services