service

package
v0.0.0-...-6e89ea1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceUpdateRequest

type DeviceUpdateRequest struct {
	DeviceData string `json:"deviceData"`
	Status     int    `json:"status"`
}

DeviceUpdateRequest holds request to update a device registration

type EnrollDeviceRequest

type EnrollDeviceRequest struct {
	Model  asserts.Assertion
	Serial asserts.Assertion
}

EnrollDeviceRequest is the request to enroll a device via assertions

type Identity

type Identity interface {
	RegisterOrganization(req *RegisterOrganizationRequest) (string, error)
	RegisterDevice(req *RegisterDeviceRequest) (string, error)
	OrganizationList() ([]domain.Organization, error)
	DeviceList(orgID string) ([]domain.Enrollment, error)
	DeviceGet(orgID, deviceID string) (*domain.Enrollment, error)
	DeviceUpdate(orgID, deviceID string, req *DeviceUpdateRequest) error

	EnrollDevice(req *EnrollDeviceRequest) (*domain.Enrollment, error)
}

Identity interface for the service

type IdentityService

type IdentityService struct {
	Settings *config.Settings
	DB       datastore.DataStore
}

IdentityService implementation of the identity use cases

func NewIdentityService

func NewIdentityService(settings *config.Settings, db datastore.DataStore) *IdentityService

NewIdentityService creates an implementation of the identity use cases

func (IdentityService) DeviceGet

func (id IdentityService) DeviceGet(orgID, deviceID string) (*domain.Enrollment, error)

DeviceGet fetches a device registration

func (IdentityService) DeviceList

func (id IdentityService) DeviceList(orgID string) ([]domain.Enrollment, error)

DeviceList fetches the registered devices

func (IdentityService) DeviceUpdate

func (id IdentityService) DeviceUpdate(orgID, deviceID string, req *DeviceUpdateRequest) error

DeviceUpdate updates an existing device with the service Status changes are limited, depending on whether the device has enrolled with the service. If it has, then it already has credentials. If a device has not enrolled: - Waiting => Disabled - Disabled => Waiting If a device has enrolled: - Enrolled => Disabled (TODO: needs to trigger the removal of credentials from MQTT broker or device or both) - Enrolled => Waiting

func (IdentityService) EnrollDevice

func (id IdentityService) EnrollDevice(req *EnrollDeviceRequest) (*domain.Enrollment, error)

EnrollDevice connects an IoT device with the service

func (IdentityService) OrganizationList

func (id IdentityService) OrganizationList() ([]domain.Organization, error)

OrganizationList fetches the existing organizations

func (IdentityService) RegisterDevice

func (id IdentityService) RegisterDevice(req *RegisterDeviceRequest) (string, error)

RegisterDevice registers a new device with the service

func (IdentityService) RegisterOrganization

func (id IdentityService) RegisterOrganization(req *RegisterOrganizationRequest) (string, error)

RegisterOrganization registers a new organization with the service

type RegisterDeviceRequest

type RegisterDeviceRequest struct {
	OrganizationID string `json:"orgid"`
	Brand          string `json:"brand"`
	Model          string `json:"model"`
	SerialNumber   string `json:"serial"`
	DeviceData     string `json:"deviceData"`
}

RegisterDeviceRequest is the request to create a new device

type RegisterOrganizationRequest

type RegisterOrganizationRequest struct {
	Name        string `json:"name"`
	CountryName string `json:"country"`
}

RegisterOrganizationRequest is the request to create a new organization

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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