manage

package
v0.0.0-...-a11ed81 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package manage provides the interface and implementation of the Manage service

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manage

type Manage interface {
	OpenIDNonceStore() openid.NonceStore
	CreateUser(user domain.User) error
	GetUser(username string) (domain.User, error)
	UserList() ([]domain.User, error)
	UserUpdate(user domain.User) error
	UserDelete(username string) error

	RegDeviceList(orgID, username string, role int) idweb.DevicesResponse
	RegisterDevice(orgID, username string, role int, body []byte) idweb.RegisterResponse
	RegDeviceGet(orgID, username string, role int, deviceID string) idweb.EnrollResponse
	RegDeviceUpdate(orgID, username string, role int, deviceID string, body []byte) idweb.StandardResponse

	DeviceList(orgID, username string, role int) web.DevicesResponse
	DeviceGet(orgID, username string, role int, deviceID string) web.DeviceResponse
	DeviceDelete(orgID, username string, role int, deviceID string) web.StandardResponse
	DeviceLogs(orgID, username string, role int, deviceID string, body []byte) web.StandardResponse
	DeviceUsersAction(orgID, username string, role int, deviceID string, body []byte) web.StandardResponse
	ActionList(orgID, username string, role int, deviceID string) web.ActionsResponse

	SnapSnapshot(orgID, username string, role int, deviceID, snap string, body []byte) web.StandardResponse
	SnapList(orgID, username string, role int, deviceID string) web.SnapsResponse
	SnapListOnDevice(orgID, username string, role int, deviceID string) web.StandardResponse
	SnapInstall(orgID, username string, role int, deviceID, snap string) web.StandardResponse
	SnapRemove(orgID, username string, role int, deviceID, snap string) web.StandardResponse
	SnapUpdate(orgID, username string, role int, deviceID, snap, action string, body []byte) web.StandardResponse
	SnapConfigSet(orgID, username string, role int, deviceID, snap string, config []byte) web.StandardResponse
	SnapServiceAction(orgID, username string, role int, deviceID, snap, action string, body []byte) web.StandardResponse

	GroupList(orgID, username string, role int) web.GroupsResponse
	GroupCreate(orgID, username string, role int, body []byte) web.StandardResponse
	GroupDevices(orgID, username string, role int, name string) web.DevicesResponse
	GroupExcludedDevices(orgID, username string, role int, name string) web.DevicesResponse
	GroupDeviceLink(orgID, username string, role int, name, deviceID string) web.StandardResponse
	GroupDeviceUnlink(orgID, username string, role int, name, deviceID string) web.StandardResponse

	OrganizationsForUser(username string) ([]domain.Organization, error)
	OrganizationForUserToggle(orgID, username string) error
	OrganizationGet(orgID string) (domain.Organization, error)
	OrganizationCreate(org domain.OrganizationCreate) error
	OrganizationUpdate(org domain.Organization) error
}

Manage interface for the service

type Management

type Management struct {
	DB          datastore.DataStore
	TwinAPI     twinapi.Client
	IdentityAPI identityapi.Client
}

Management implementation of the management service use cases

func NewManagement

func NewManagement(db datastore.DataStore, api twinapi.Client, id identityapi.Client) *Management

NewManagement creates an implementation of the management use cases

func (*Management) ActionList

func (srv *Management) ActionList(orgID, username string, role int, deviceID string) web.ActionsResponse

ActionList gets the actions for a device

func (*Management) CreateUser

func (srv *Management) CreateUser(user domain.User) error

CreateUser creates a new user

func (*Management) DeviceDelete

func (srv *Management) DeviceDelete(orgID, username string, role int, deviceID string) web.StandardResponse

DeviceDelete deletes the device from an organization

func (*Management) DeviceGet

func (srv *Management) DeviceGet(orgID, username string, role int, deviceID string) web.DeviceResponse

DeviceGet gets the device for an organization

func (*Management) DeviceList

func (srv *Management) DeviceList(orgID, username string, role int) web.DevicesResponse

DeviceList gets the devices a user can access for an organization

func (*Management) DeviceLogs

func (srv *Management) DeviceLogs(orgID, username string, role int, deviceID string, body []byte) web.StandardResponse

DeviceLogs requests from the DeviceTwin API that logs for a device be sent

func (*Management) DeviceUsersAction

func (srv *Management) DeviceUsersAction(orgID, username string, role int, deviceID string, body []byte) web.StandardResponse

DeviceUsersAction requests from the DeviceTwin API that a user action be performed on the device

func (*Management) GetUser

func (srv *Management) GetUser(username string) (domain.User, error)

GetUser fetches a user from the database

func (*Management) GroupCreate

func (srv *Management) GroupCreate(orgID, username string, role int, body []byte) web.StandardResponse

GroupCreate creates a device group

func (srv *Management) GroupDeviceLink(orgID, username string, role int, name, deviceID string) web.StandardResponse

GroupDeviceLink links a device to a group

func (srv *Management) GroupDeviceUnlink(orgID, username string, role int, name, deviceID string) web.StandardResponse

GroupDeviceUnlink unlinks a device from a group

func (*Management) GroupDevices

func (srv *Management) GroupDevices(orgID, username string, role int, name string) web.DevicesResponse

GroupDevices lists the devices for a groups

func (*Management) GroupExcludedDevices

func (srv *Management) GroupExcludedDevices(orgID, username string, role int, name string) web.DevicesResponse

GroupExcludedDevices lists the devices for a groups

func (*Management) GroupList

func (srv *Management) GroupList(orgID, username string, role int) web.GroupsResponse

GroupList lists the device groups

func (*Management) OpenIDNonceStore

func (srv *Management) OpenIDNonceStore() openid.NonceStore

OpenIDNonceStore fetches the OpenID nonce store

func (*Management) OrganizationCreate

func (srv *Management) OrganizationCreate(org domain.OrganizationCreate) error

OrganizationCreate creates a new organization

func (*Management) OrganizationForUserToggle

func (srv *Management) OrganizationForUserToggle(orgID, username string) error

OrganizationForUserToggle toggles organization access for a user

func (*Management) OrganizationGet

func (srv *Management) OrganizationGet(orgID string) (domain.Organization, error)

OrganizationGet fetches an organization

func (*Management) OrganizationUpdate

func (srv *Management) OrganizationUpdate(org domain.Organization) error

OrganizationUpdate updates an organization

func (*Management) OrganizationsForUser

func (srv *Management) OrganizationsForUser(username string) ([]domain.Organization, error)

OrganizationsForUser fetches the organizations for a user

func (*Management) RegDeviceGet

func (srv *Management) RegDeviceGet(orgID, username string, role int, deviceID string) web.EnrollResponse

RegDeviceGet fetches a device registration

func (*Management) RegDeviceList

func (srv *Management) RegDeviceList(orgID, username string, role int) web.DevicesResponse

RegDeviceList gets the registered devices a user can access for an organization

func (*Management) RegDeviceUpdate

func (srv *Management) RegDeviceUpdate(orgID, username string, role int, deviceID string, body []byte) web.StandardResponse

RegDeviceUpdate updates a device registration

func (*Management) RegisterDevice

func (srv *Management) RegisterDevice(orgID, username string, role int, body []byte) web.RegisterResponse

RegisterDevice registers a new device

func (*Management) SnapConfigSet

func (srv *Management) SnapConfigSet(orgID, username string, role int, deviceID, snap string, config []byte) web.StandardResponse

SnapConfigSet updates a snap config on a device

func (*Management) SnapInstall

func (srv *Management) SnapInstall(orgID, username string, role int, deviceID, snap string) web.StandardResponse

SnapInstall installs a snap on a device

func (*Management) SnapList

func (srv *Management) SnapList(orgID, username string, role int, deviceID string) web.SnapsResponse

SnapList lists the snaps for a device

func (*Management) SnapListOnDevice

func (srv *Management) SnapListOnDevice(orgID, username string, role int, deviceID string) web.StandardResponse

SnapListOnDevice lists snaps on a device

func (*Management) SnapRemove

func (srv *Management) SnapRemove(orgID, username string, role int, deviceID, snap string) web.StandardResponse

SnapRemove uninstalls a snap on a device

func (*Management) SnapServiceAction

func (srv *Management) SnapServiceAction(orgID, username string, role int, deviceID, snap, action string, body []byte) web.StandardResponse

SnapServiceAction requests from the DeviceTwin API that an action be performed on a snap service

func (*Management) SnapSnapshot

func (srv *Management) SnapSnapshot(orgID, username string, role int, deviceID, snap string, body []byte) web.StandardResponse

SnapSnapshot requests from the DeviceTwin API that a snapshot be made of a given snap

func (*Management) SnapUpdate

func (srv *Management) SnapUpdate(orgID, username string, role int, deviceID, snap, action string, body []byte) web.StandardResponse

SnapUpdate enables/disables/refreshes/swtich a snap on a device

func (*Management) UserDelete

func (srv *Management) UserDelete(username string) error

UserDelete removes a user

func (*Management) UserList

func (srv *Management) UserList() ([]domain.User, error)

UserList fetches the existing users

func (*Management) UserUpdate

func (srv *Management) UserUpdate(user domain.User) error

UserUpdate updates a new user

type MockManage

type MockManage struct {
	DB datastore.DataStore
}

MockManage mocks the management service

func NewMockManagement

func NewMockManagement(db datastore.DataStore) *MockManage

NewMockManagement creates an implementation of the management use cases

func (*MockManage) ActionList

func (m *MockManage) ActionList(orgID, username string, role int, deviceID string) web.ActionsResponse

ActionList mocks fetching action list

func (*MockManage) CreateUser

func (m *MockManage) CreateUser(user domain.User) error

CreateUser mocks creating a user

func (*MockManage) DeviceDelete

func (m *MockManage) DeviceDelete(orgID, username string, role int, deviceID string) web.StandardResponse

nolint

func (*MockManage) DeviceGet

func (m *MockManage) DeviceGet(orgID, username string, role int, deviceID string) web.DeviceResponse

DeviceGet mocks fetching a device

func (*MockManage) DeviceList

func (m *MockManage) DeviceList(orgID, username string, role int) web.DevicesResponse

DeviceList mocks fetching devices

func (*MockManage) DeviceLogs

func (m *MockManage) DeviceLogs(orgID, username string, role int, deviceID string, body []byte) web.StandardResponse

DeviceLogs mocks create a device logs

func (*MockManage) DeviceUsersAction

func (m *MockManage) DeviceUsersAction(orgID, username string, role int, deviceID string, body []byte) web.StandardResponse

nolint

func (*MockManage) GetUser

func (m *MockManage) GetUser(username string) (domain.User, error)

GetUser mocks fetching a user

func (*MockManage) GroupCreate

func (m *MockManage) GroupCreate(orgID, username string, role int, body []byte) web.StandardResponse

GroupCreate mocks creating a group

func (m *MockManage) GroupDeviceLink(orgID, username string, role int, name, deviceID string) web.StandardResponse

GroupDeviceLink mocks linking a device to a group

func (m *MockManage) GroupDeviceUnlink(orgID, username string, role int, name, deviceID string) web.StandardResponse

GroupDeviceUnlink mocks unlinking a device from a group

func (*MockManage) GroupDevices

func (m *MockManage) GroupDevices(orgID, username string, role int, name string) web.DevicesResponse

GroupDevices mocks listing devices for a group

func (*MockManage) GroupExcludedDevices

func (m *MockManage) GroupExcludedDevices(orgID, username string, role int, name string) web.DevicesResponse

GroupExcludedDevices mocks listing devices not in a group

func (*MockManage) GroupList

func (m *MockManage) GroupList(orgID, username string, role int) web.GroupsResponse

GroupList mocks listing groups

func (*MockManage) OpenIDNonceStore

func (m *MockManage) OpenIDNonceStore() openid.NonceStore

OpenIDNonceStore mocks the openid nonce store

func (*MockManage) OrganizationCreate

func (m *MockManage) OrganizationCreate(org domain.OrganizationCreate) error

OrganizationCreate mocks creating an organization

func (*MockManage) OrganizationForUserToggle

func (m *MockManage) OrganizationForUserToggle(orgID, username string) error

OrganizationForUserToggle mocks toggling user access to an organization

func (*MockManage) OrganizationGet

func (m *MockManage) OrganizationGet(orgID string) (domain.Organization, error)

OrganizationGet mocks fetching an organization

func (*MockManage) OrganizationUpdate

func (m *MockManage) OrganizationUpdate(org domain.Organization) error

OrganizationUpdate mocks updating an organization

func (*MockManage) OrganizationsForUser

func (m *MockManage) OrganizationsForUser(username string) ([]domain.Organization, error)

OrganizationsForUser mocks organizations for a user

func (*MockManage) RegDeviceGet

func (m *MockManage) RegDeviceGet(orgID, username string, role int, deviceID string) idweb.EnrollResponse

RegDeviceGet mocks fetching a registered device

func (*MockManage) RegDeviceList

func (m *MockManage) RegDeviceList(orgID, username string, role int) idweb.DevicesResponse

RegDeviceList mocks listing registered devices

func (*MockManage) RegDeviceUpdate

func (m *MockManage) RegDeviceUpdate(orgID, username string, role int, deviceID string, body []byte) idweb.StandardResponse

RegDeviceUpdate mocks updating a registered device

func (*MockManage) RegisterDevice

func (m *MockManage) RegisterDevice(orgID, username string, role int, body []byte) idweb.RegisterResponse

RegisterDevice mocks registering a device

func (*MockManage) SnapConfigSet

func (m *MockManage) SnapConfigSet(orgID, username string, role int, deviceID, snap string, config []byte) web.StandardResponse

SnapConfigSet mocks updating a snap config

func (*MockManage) SnapInstall

func (m *MockManage) SnapInstall(orgID, username string, role int, deviceID, snap string) web.StandardResponse

SnapInstall mocks installing a snap

func (*MockManage) SnapList

func (m *MockManage) SnapList(orgID, username string, role int, deviceID string) web.SnapsResponse

SnapList mocks listing snaps

func (*MockManage) SnapListOnDevice

func (m *MockManage) SnapListOnDevice(orgID, username string, role int, deviceID string) web.StandardResponse

SnapListOnDevice mocks listing snaps

func (*MockManage) SnapRemove

func (m *MockManage) SnapRemove(orgID, username string, role int, deviceID, snap string) web.StandardResponse

SnapRemove mocks uninstalling a snap

func (*MockManage) SnapServiceAction

func (m *MockManage) SnapServiceAction(orgID, username string, role int, deviceID, snap, action string, body []byte) web.StandardResponse

nolint

func (*MockManage) SnapShot

func (m *MockManage) SnapShot(orgID, username string, role int, deviceID, snap, action string, body []byte) web.StandardResponse

SnapShot mocks create a snap snapshot

func (*MockManage) SnapSnapshot

func (m *MockManage) SnapSnapshot(orgID, username string, role int, deviceID, snap string, body []byte) web.StandardResponse

nolint

func (*MockManage) SnapUpdate

func (m *MockManage) SnapUpdate(orgID, username string, role int, deviceID, snap, action string, body []byte) web.StandardResponse

SnapUpdate mocks updating a snap

func (*MockManage) UserDelete

func (m *MockManage) UserDelete(username string) error

UserDelete mocks removing a user

func (*MockManage) UserList

func (m *MockManage) UserList() ([]domain.User, error)

UserList mocks fetching users

func (*MockManage) UserUpdate

func (m *MockManage) UserUpdate(user domain.User) error

UserUpdate mocks updating a user

Jump to

Keyboard shortcuts

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