Documentation ¶
Index ¶
- Constants
- Variables
- func AddDeviceToMulticastGroup(db sqlx.Ext, multicastGroupID uuid.UUID, devEUI lorawan.EUI64) error
- func CreateApplication(db sqlx.Queryer, item *Application) error
- func CreateDevice(db sqlx.Ext, d *Device) error
- func CreateDeviceActivation(db sqlx.Queryer, da *DeviceActivation) error
- func CreateDeviceKeys(db sqlx.Execer, dc *DeviceKeys) error
- func CreateDeviceProfile(db sqlx.Ext, dp *DeviceProfile) error
- func CreateGateway(db sqlx.Execer, gw *Gateway) error
- func CreateGatewayPing(db sqlx.Queryer, ping *GatewayPing) error
- func CreateGatewayPingRX(db sqlx.Queryer, rx *GatewayPingRX) error
- func CreateGatewayProfile(db sqlx.Ext, gp *GatewayProfile) error
- func CreateIntegration(db sqlx.Queryer, i *Integration) error
- func CreateMulticastGroup(db sqlx.Ext, mg *MulticastGroup) error
- func CreateNetworkServer(db sqlx.Queryer, n *NetworkServer) error
- func CreateOrganization(db sqlx.Queryer, org *Organization) error
- func CreateOrganizationUser(db sqlx.Execer, organizationID, userID int64, isAdmin bool) error
- func CreateServiceProfile(db sqlx.Ext, sp *ServiceProfile) error
- func CreateUser(db sqlx.Queryer, user *User, password string) (int64, error)
- func DeleteAllApplicationsForOrganizationID(db sqlx.Ext, organizationID int64) error
- func DeleteAllDeviceProfilesForOrganizationID(db sqlx.Ext, organizationID int64) error
- func DeleteAllDevicesForApplicationID(db sqlx.Ext, applicationID int64) error
- func DeleteAllGatewaysForOrganizationID(db sqlx.Ext, organizationID int64) error
- func DeleteAllServiceProfilesForOrganizationID(db sqlx.Ext, organizationID int64) error
- func DeleteApplication(db sqlx.Ext, id int64) error
- func DeleteDevice(db sqlx.Ext, devEUI lorawan.EUI64) error
- func DeleteDeviceKeys(db sqlx.Execer, devEUI lorawan.EUI64) error
- func DeleteDeviceProfile(db sqlx.Ext, id uuid.UUID) error
- func DeleteGateway(db sqlx.Ext, mac lorawan.EUI64) error
- func DeleteGatewayProfile(db sqlx.Ext, id uuid.UUID) error
- func DeleteIntegration(db sqlx.Execer, id int64) error
- func DeleteMulticastGroup(db sqlx.Ext, id uuid.UUID) error
- func DeleteNetworkServer(db sqlx.Ext, id int64) error
- func DeleteOrganization(db sqlx.Ext, id int64) error
- func DeleteOrganizationUser(db sqlx.Execer, organizationID, userID int64) error
- func DeleteServiceProfile(db sqlx.Ext, id uuid.UUID) error
- func DeleteUser(db sqlx.Execer, id int64) error
- func GetApplicationCount(db sqlx.Queryer, search string) (int, error)
- func GetApplicationCountForOrganizationID(db sqlx.Queryer, organizationID int64, search string) (int, error)
- func GetApplicationCountForUser(db sqlx.Queryer, username string, organizationID int64, search string) (int, error)
- func GetDeviceCount(db sqlx.Queryer, filters DeviceFilters) (int, error)
- func GetDeviceCountForMulticastGroup(db sqlx.Queryer, multicastGroup uuid.UUID) (int, error)
- func GetDeviceProfileCount(db sqlx.Queryer) (int, error)
- func GetDeviceProfileCountForApplicationID(db sqlx.Queryer, applicationID int64) (int, error)
- func GetDeviceProfileCountForOrganizationID(db sqlx.Queryer, organizationID int64) (int, error)
- func GetDeviceProfileCountForUser(db sqlx.Queryer, username string) (int, error)
- func GetGatewayCount(db sqlx.Queryer, search string) (int, error)
- func GetGatewayCountForOrganizationID(db sqlx.Queryer, organizationID int64, search string) (int, error)
- func GetGatewayCountForUser(db sqlx.Queryer, username string, search string) (int, error)
- func GetGatewayProfileCount(db sqlx.Queryer) (int, error)
- func GetGatewayProfileCountForNetworkServerID(db sqlx.Queryer, networkServerID int64) (int, error)
- func GetGatewaysForMACs(db sqlx.Queryer, macs []lorawan.EUI64) (map[lorawan.EUI64]Gateway, error)
- func GetLastGatewayPingAndRX(db sqlx.Queryer, mac lorawan.EUI64) (GatewayPing, []GatewayPingRX, error)
- func GetMulticastGroupCount(db sqlx.Queryer, filters MulticastGroupFilters) (int, error)
- func GetNetworkServerCount(db sqlx.Queryer) (int, error)
- func GetNetworkServerCountForOrganizationID(db sqlx.Queryer, organizationID int64) (int, error)
- func GetOrganizationCount(db sqlx.Queryer, search string) (int, error)
- func GetOrganizationCountForUser(db sqlx.Queryer, username string, search string) (int, error)
- func GetOrganizationUserCount(db sqlx.Queryer, organizationID int64) (int, error)
- func GetServiceProfileCount(db sqlx.Queryer) (int, error)
- func GetServiceProfileCountForOrganizationID(db sqlx.Queryer, organizationID int64) (int, error)
- func GetServiceProfileCountForUser(db sqlx.Queryer, username string) (int, error)
- func GetUserCount(db sqlx.Queryer, search string) (int32, error)
- func LoginUser(db sqlx.Queryer, username string, password string) (string, error)
- func NewRedisPool(redisURL string, maxIdle int, idleTimeout time.Duration) *redis.Pool
- func OpenDatabase(dsn string) (*common.DBLogger, error)
- func RemoveDeviceFromMulticastGroup(db sqlx.Ext, multicastGroupID uuid.UUID, devEUI lorawan.EUI64) error
- func SetUserSecret(s string)
- func Transaction(db *common.DBLogger, f func(tx sqlx.Ext) error) error
- func UpdateApplication(db sqlx.Execer, item Application) error
- func UpdateDevice(db sqlx.Ext, d *Device, localOnly bool) error
- func UpdateDeviceKeys(db sqlx.Execer, dc *DeviceKeys) error
- func UpdateDeviceProfile(db sqlx.Ext, dp *DeviceProfile) error
- func UpdateGateway(db sqlx.Execer, gw *Gateway) error
- func UpdateGatewayProfile(db sqlx.Ext, gp *GatewayProfile) error
- func UpdateIntegration(db sqlx.Execer, i *Integration) error
- func UpdateMulticastGroup(db sqlx.Ext, mg *MulticastGroup) error
- func UpdateNetworkServer(db sqlx.Execer, n *NetworkServer) error
- func UpdateOrganization(db sqlx.Execer, org *Organization) error
- func UpdateOrganizationUser(db sqlx.Execer, organizationID, userID int64, isAdmin bool) error
- func UpdatePassword(db sqlx.Execer, id int64, newpassword string) error
- func UpdateServiceProfile(db sqlx.Ext, sp *ServiceProfile) error
- func UpdateUser(db sqlx.Execer, item UserUpdate) error
- func ValidateEmail(email string) error
- func ValidatePassword(password string) error
- func ValidateUsername(username string) error
- type Action
- type Application
- type ApplicationListItem
- func GetApplications(db sqlx.Queryer, limit, offset int, search string) ([]ApplicationListItem, error)
- func GetApplicationsForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int, search string) ([]ApplicationListItem, error)
- func GetApplicationsForUser(db sqlx.Queryer, username string, organizationID int64, limit, offset int, ...) ([]ApplicationListItem, error)
- type Device
- type DeviceActivation
- type DeviceFilters
- type DeviceKeys
- type DeviceListItem
- type DeviceProfile
- type DeviceProfileMeta
- func GetDeviceProfiles(db sqlx.Queryer, limit, offset int) ([]DeviceProfileMeta, error)
- func GetDeviceProfilesForApplicationID(db sqlx.Queryer, applicationID int64, limit, offset int) ([]DeviceProfileMeta, error)
- func GetDeviceProfilesForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]DeviceProfileMeta, error)
- func GetDeviceProfilesForUser(db sqlx.Queryer, username string, limit, offset int) ([]DeviceProfileMeta, error)
- type ExtraChannel
- type GPSPoint
- type Gateway
- func GetGateway(db sqlx.Queryer, mac lorawan.EUI64, forUpdate bool) (Gateway, error)
- func GetGateways(db sqlx.Queryer, limit, offset int, search string) ([]Gateway, error)
- func GetGatewaysForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int, search string) ([]Gateway, error)
- func GetGatewaysForUser(db sqlx.Queryer, username string, limit, offset int, search string) ([]Gateway, error)
- type GatewayPing
- type GatewayPingRX
- type GatewayProfile
- type GatewayProfileMeta
- type Integration
- type MulticastGroup
- type MulticastGroupFilters
- type MulticastGroupListItem
- type NetworkServer
- func GetNetworkServer(db sqlx.Queryer, id int64) (NetworkServer, error)
- func GetNetworkServerForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (NetworkServer, error)
- func GetNetworkServerForDeviceProfileID(db sqlx.Queryer, id uuid.UUID) (NetworkServer, error)
- func GetNetworkServerForGatewayMAC(db sqlx.Queryer, mac lorawan.EUI64) (NetworkServer, error)
- func GetNetworkServerForGatewayProfileID(db sqlx.Queryer, id uuid.UUID) (NetworkServer, error)
- func GetNetworkServerForMulticastGroupID(db sqlx.Queryer, id uuid.UUID) (NetworkServer, error)
- func GetNetworkServerForServiceProfileID(db sqlx.Queryer, id uuid.UUID) (NetworkServer, error)
- func GetNetworkServers(db sqlx.Queryer, limit, offset int) ([]NetworkServer, error)
- func GetNetworkServersForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]NetworkServer, error)
- type Organization
- type OrganizationUser
- type SearchResult
- type ServiceProfile
- type ServiceProfileMeta
- func GetServiceProfiles(db sqlx.Queryer, limit, offset int) ([]ServiceProfileMeta, error)
- func GetServiceProfilesForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]ServiceProfileMeta, error)
- func GetServiceProfilesForUser(db sqlx.Queryer, username string, limit, offset int) ([]ServiceProfileMeta, error)
- type User
- type UserProfile
- type UserProfileApplication
- type UserProfileOrganization
- type UserProfileUser
- type UserUpdate
Constants ¶
const ( ModulationFSK = "FSK" ModulationLoRa = "LORA" )
Modulations
Variables ¶
var ( ErrAlreadyExists = errors.New("object already exists") ErrDoesNotExist = errors.New("object does not exist") ErrUsedByOtherObjects = errors.New("this object is used by other objects, remove them first") ErrApplicationInvalidName = errors.New("invalid application name") ErrNodeInvalidName = errors.New("invalid node name") ErrNodeMaxRXDelay = errors.New("max value of RXDelay is 15") ErrCFListTooManyChannels = errors.New("too many channels in channel-list") ErrUserInvalidUsername = errors.New("username name may only be composed of upper and lower case characters and digits") ErrUserPasswordLength = errors.New("passwords must be at least 6 characters long") ErrInvalidUsernameOrPassword = errors.New("invalid username or password") ErrOrganizationInvalidName = errors.New("invalid organization name") ErrGatewayInvalidName = errors.New("invalid gateway name") ErrInvalidEmail = errors.New("invalid e-mail") ErrInvalidGatewayDiscoveryInterval = errors.New("invalid gateway-discovery interval, it must be greater than 0") ErrDeviceProfileInvalidName = errors.New("invalid device-profile name") )
errors
var HashIterations = 100000
HashIterations defines the number of hash iterations.
Functions ¶
func AddDeviceToMulticastGroup ¶
AddDeviceToMulticastGroup adds the given device to the given multicast-group. It is recommended that db is a transaction.
func CreateApplication ¶
func CreateApplication(db sqlx.Queryer, item *Application) error
CreateApplication creates the given Application.
func CreateDevice ¶
CreateDevice creates the given device.
func CreateDeviceActivation ¶
func CreateDeviceActivation(db sqlx.Queryer, da *DeviceActivation) error
CreateDeviceActivation creates the given device-activation.
func CreateDeviceKeys ¶
func CreateDeviceKeys(db sqlx.Execer, dc *DeviceKeys) error
CreateDeviceKeys creates the keys for the given device.
func CreateDeviceProfile ¶
func CreateDeviceProfile(db sqlx.Ext, dp *DeviceProfile) error
CreateDeviceProfile creates the given device-profile. This will create the device-profile at the network-server side and will create a local reference record.
func CreateGateway ¶
CreateGateway creates the given Gateway.
func CreateGatewayPing ¶
func CreateGatewayPing(db sqlx.Queryer, ping *GatewayPing) error
CreateGatewayPing creates the given gateway ping.
func CreateGatewayPingRX ¶
func CreateGatewayPingRX(db sqlx.Queryer, rx *GatewayPingRX) error
CreateGatewayPingRX creates the received ping.
func CreateGatewayProfile ¶
func CreateGatewayProfile(db sqlx.Ext, gp *GatewayProfile) error
CreateGatewayProfile creates the given gateway-profile. This will create the gateway-profile at the network-server side and will create a local reference record.
func CreateIntegration ¶
func CreateIntegration(db sqlx.Queryer, i *Integration) error
CreateIntegration creates the given Integration.
func CreateMulticastGroup ¶
func CreateMulticastGroup(db sqlx.Ext, mg *MulticastGroup) error
CreateMulticastGroup creates the given multicast-group.
func CreateNetworkServer ¶
func CreateNetworkServer(db sqlx.Queryer, n *NetworkServer) error
CreateNetworkServer creates the given network-server.
func CreateOrganization ¶
func CreateOrganization(db sqlx.Queryer, org *Organization) error
CreateOrganization creates the given Organization.
func CreateOrganizationUser ¶
CreateOrganizationUser adds the given user to the organization.
func CreateServiceProfile ¶
func CreateServiceProfile(db sqlx.Ext, sp *ServiceProfile) error
CreateServiceProfile creates the given service-profile.
func CreateUser ¶
CreateUser creates the given user.
func DeleteAllApplicationsForOrganizationID ¶
DeleteAllApplicationsForOrganizationID deletes all applications given an organization id.
func DeleteAllDeviceProfilesForOrganizationID ¶
DeleteAllDeviceProfilesForOrganizationID deletes all device-profiles given an organization id.
func DeleteAllDevicesForApplicationID ¶
DeleteAllDevicesForApplicationID deletes all devices given an application id.
func DeleteAllGatewaysForOrganizationID ¶
DeleteAllGatewaysForOrganizationID deletes all gateways for a given organization id.
func DeleteAllServiceProfilesForOrganizationID ¶
DeleteAllServiceProfilesForOrganizationID deletes all service-profiles given an organization id.
func DeleteApplication ¶
DeleteApplication deletes the Application matching the given ID.
func DeleteDevice ¶
DeleteDevice deletes the device matching the given DevEUI.
func DeleteDeviceKeys ¶
DeleteDeviceKeys deletes the device-keys for the given DevEUI.
func DeleteDeviceProfile ¶
DeleteDeviceProfile deletes the device-profile matching the given id.
func DeleteGateway ¶
DeleteGateway deletes the gateway matching the given MAC.
func DeleteGatewayProfile ¶
DeleteGatewayProfile deletes the gateway-profile matching the given id.
func DeleteIntegration ¶
DeleteIntegration deletes the integration matching the given id.
func DeleteMulticastGroup ¶
DeleteMulticastGroup deletes a multicast-group given an id.
func DeleteNetworkServer ¶
DeleteNetworkServer deletes the network-server matching the given id.
func DeleteOrganization ¶
DeleteOrganization deletes the organization matching the given id.
func DeleteOrganizationUser ¶
DeleteOrganizationUser deletes the given organization user.
func DeleteServiceProfile ¶
DeleteServiceProfile deletes the service-profile matching the given id.
func DeleteUser ¶
DeleteUser deletes the User record matching the given ID.
func GetApplicationCount ¶
GetApplicationCount returns the total number of applications.
func GetApplicationCountForOrganizationID ¶
func GetApplicationCountForOrganizationID(db sqlx.Queryer, organizationID int64, search string) (int, error)
GetApplicationCountForOrganizationID returns the total number of applications for the given organization.
func GetApplicationCountForUser ¶
func GetApplicationCountForUser(db sqlx.Queryer, username string, organizationID int64, search string) (int, error)
GetApplicationCountForUser returns the total number of applications available for the given user. When an organizationID is given, the results will be filtered by this organization ID.
func GetDeviceCount ¶
func GetDeviceCount(db sqlx.Queryer, filters DeviceFilters) (int, error)
GetDeviceCount returns the number of devices.
func GetDeviceCountForMulticastGroup ¶
GetDeviceCountForMulticastGroup returns the number of devices for the given multicast-group.
func GetDeviceProfileCount ¶
GetDeviceProfileCount returns the total number of device-profiles.
func GetDeviceProfileCountForApplicationID ¶
GetDeviceProfileCountForApplicationID returns the total number of device-profiles that can be used for the given application id (based on the service-profile of the application).
func GetDeviceProfileCountForOrganizationID ¶
GetDeviceProfileCountForOrganizationID returns the total number of device-profiles for the given organization id.
func GetDeviceProfileCountForUser ¶
GetDeviceProfileCountForUser returns the total number of device-profiles for the given username.
func GetGatewayCount ¶
GetGatewayCount returns the total number of gateways.
func GetGatewayCountForOrganizationID ¶
func GetGatewayCountForOrganizationID(db sqlx.Queryer, organizationID int64, search string) (int, error)
GetGatewayCountForOrganizationID returns the total number of gateways given an organization ID.
func GetGatewayCountForUser ¶
GetGatewayCountForUser returns the total number of gateways to which the given user has access.
func GetGatewayProfileCount ¶
GetGatewayProfileCount returns the total number of gateway-profiles.
func GetGatewayProfileCountForNetworkServerID ¶
GetGatewayProfileCountForNetworkServerID returns the total number of gateway-profiles given a network-server ID.
func GetGatewaysForMACs ¶
GetGatewaysForMACs returns a map of gateways given a slice of MACs.
func GetLastGatewayPingAndRX ¶
func GetLastGatewayPingAndRX(db sqlx.Queryer, mac lorawan.EUI64) (GatewayPing, []GatewayPingRX, error)
GetLastGatewayPingAndRX returns the last gateway ping and RX for the given gateway MAC.
func GetMulticastGroupCount ¶
func GetMulticastGroupCount(db sqlx.Queryer, filters MulticastGroupFilters) (int, error)
GetMulticastGroupCount returns the total number of multicast-groups given the provided filters. Note that empty values are not used as filters.
func GetNetworkServerCount ¶
GetNetworkServerCount returns the total number of network-servers.
func GetNetworkServerCountForOrganizationID ¶
GetNetworkServerCountForOrganizationID returns the total number of network-servers accessible for the given organization id. A network-server is accessible for an organization when it is used by one of its service-profiles.
func GetOrganizationCount ¶
GetOrganizationCount returns the total number of organizations.
func GetOrganizationCountForUser ¶
GetOrganizationCountForUser returns the number of organizations to which the given user is member of.
func GetOrganizationUserCount ¶
GetOrganizationUserCount returns the number of users for the given organization.
func GetServiceProfileCount ¶
GetServiceProfileCount returns the total number of service-profiles.
func GetServiceProfileCountForOrganizationID ¶
GetServiceProfileCountForOrganizationID returns the total number of service-profiles for the given organization id.
func GetServiceProfileCountForUser ¶
GetServiceProfileCountForUser returns the total number of service-profiles for the given username.
func GetUserCount ¶
GetUserCount returns the total number of users.
func LoginUser ¶
LoginUser returns a JWT token for the user matching the given username and password.
func NewRedisPool ¶
NewRedisPool returns a new Redis connection pool.
func OpenDatabase ¶
OpenDatabase opens the database and performs a ping to make sure the database is up.
func RemoveDeviceFromMulticastGroup ¶
func RemoveDeviceFromMulticastGroup(db sqlx.Ext, multicastGroupID uuid.UUID, devEUI lorawan.EUI64) error
RemoveDeviceFromMulticastGroup removes the given device from the given multicast-group.
func Transaction ¶
Transaction wraps the given function in a transaction. In case the given functions returns an error, the transaction will be rolled back.
func UpdateApplication ¶
func UpdateApplication(db sqlx.Execer, item Application) error
UpdateApplication updates the given Application.
func UpdateDevice ¶
UpdateDevice updates the given device. When localOnly is set, it will not update the device on the network-server.
func UpdateDeviceKeys ¶
func UpdateDeviceKeys(db sqlx.Execer, dc *DeviceKeys) error
UpdateDeviceKeys updates the given device-keys.
func UpdateDeviceProfile ¶
func UpdateDeviceProfile(db sqlx.Ext, dp *DeviceProfile) error
UpdateDeviceProfile updates the given device-profile.
func UpdateGateway ¶
UpdateGateway updates the given Gateway.
func UpdateGatewayProfile ¶
func UpdateGatewayProfile(db sqlx.Ext, gp *GatewayProfile) error
UpdateGatewayProfile updates the given gateway-profile.
func UpdateIntegration ¶
func UpdateIntegration(db sqlx.Execer, i *Integration) error
UpdateIntegration updates the given Integration.
func UpdateMulticastGroup ¶
func UpdateMulticastGroup(db sqlx.Ext, mg *MulticastGroup) error
UpdateMulticastGroup updates the given multicast-group.
func UpdateNetworkServer ¶
func UpdateNetworkServer(db sqlx.Execer, n *NetworkServer) error
UpdateNetworkServer updates the given network-server.
func UpdateOrganization ¶
func UpdateOrganization(db sqlx.Execer, org *Organization) error
UpdateOrganization updates the given organization.
func UpdateOrganizationUser ¶
UpdateOrganizationUser updates the given user of the organization.
func UpdatePassword ¶
UpdatePassword updates the user with the new password.
func UpdateServiceProfile ¶
func UpdateServiceProfile(db sqlx.Ext, sp *ServiceProfile) error
UpdateServiceProfile updates the given service-profile.
func UpdateUser ¶
func UpdateUser(db sqlx.Execer, item UserUpdate) error
UpdateUser updates the given User.
func ValidateEmail ¶
ValidateEmail validates the given e-mail.
func ValidatePassword ¶
ValidatePassword validates the given password.
func ValidateUsername ¶
ValidateUsername validates the given username.
Types ¶
type Application ¶
type Application struct { ID int64 `db:"id"` Name string `db:"name"` Description string `db:"description"` OrganizationID int64 `db:"organization_id"` ServiceProfileID uuid.UUID `db:"service_profile_id"` PayloadCodec codec.Type `db:"payload_codec"` PayloadEncoderScript string `db:"payload_encoder_script"` PayloadDecoderScript string `db:"payload_decoder_script"` }
Application represents an application.
func GetApplication ¶
func GetApplication(db sqlx.Queryer, id int64) (Application, error)
GetApplication returns the Application for the given id.
func (Application) Validate ¶
func (a Application) Validate() error
Validate validates the data of the Application.
type ApplicationListItem ¶
type ApplicationListItem struct { Application ServiceProfileName string `db:"service_profile_name"` }
ApplicationListItem devices the application as a list item.
func GetApplications ¶
func GetApplications(db sqlx.Queryer, limit, offset int, search string) ([]ApplicationListItem, error)
GetApplications returns a slice of applications, sorted by name and respecting the given limit and offset.
func GetApplicationsForOrganizationID ¶
func GetApplicationsForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int, search string) ([]ApplicationListItem, error)
GetApplicationsForOrganizationID returns a slice of applications for the given organization.
func GetApplicationsForUser ¶
func GetApplicationsForUser(db sqlx.Queryer, username string, organizationID int64, limit, offset int, search string) ([]ApplicationListItem, error)
GetApplicationsForUser returns a slice of application of which the given user is a member of.
type Device ¶
type Device struct { DevEUI lorawan.EUI64 `db:"dev_eui"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` LastSeenAt *time.Time `db:"last_seen_at"` ApplicationID int64 `db:"application_id"` DeviceProfileID uuid.UUID `db:"device_profile_id"` Name string `db:"name"` Description string `db:"description"` SkipFCntCheck bool `db:"-"` ReferenceAltitude float64 `db:"-"` DeviceStatusBattery *float32 `db:"device_status_battery"` DeviceStatusMargin *int `db:"device_status_margin"` DeviceStatusExternalPower bool `db:"device_status_external_power_source"` Latitude *float64 `db:"latitude"` Longitude *float64 `db:"longitude"` Altitude *float64 `db:"altitude"` }
Device defines a LoRaWAN device.
type DeviceActivation ¶
type DeviceActivation struct { ID int64 `db:"id"` CreatedAt time.Time `db:"created_at"` DevEUI lorawan.EUI64 `db:"dev_eui"` DevAddr lorawan.DevAddr `db:"dev_addr"` AppSKey lorawan.AES128Key `db:"app_s_key"` }
DeviceActivation defines the device-activation for a LoRaWAN device.
func GetLastDeviceActivationForDevEUI ¶
func GetLastDeviceActivationForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceActivation, error)
GetLastDeviceActivationForDevEUI returns the most recent device-activation for the given DevEUI.
type DeviceFilters ¶
type DeviceFilters struct { ApplicationID int64 `db:"application_id"` MulticastGroupID uuid.UUID `db:"multicast_group_id"` ServiceProfileID uuid.UUID `db:"service_profile_id"` Search string `db:"search"` // Limit and Offset are added for convenience so that this struct can // be given as the arguments. Limit int `db:"limit"` Offset int `db:"offset"` }
DeviceFilters provide filters that can be used to filter on devices. Note that empty values are not used as filter.
type DeviceKeys ¶
type DeviceKeys struct { CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` DevEUI lorawan.EUI64 `db:"dev_eui"` NwkKey lorawan.AES128Key `db:"nwk_key"` AppKey lorawan.AES128Key `db:"app_key"` JoinNonce int `db:"join_nonce"` }
DeviceKeys defines the keys for a LoRaWAN device.
func GetDeviceKeys ¶
GetDeviceKeys returns the device-keys for the given DevEUI.
type DeviceListItem ¶
DeviceListItem defines the Device as list item.
func GetDevices ¶
func GetDevices(db sqlx.Queryer, filters DeviceFilters) ([]DeviceListItem, error)
GetDevices returns a slice of devices.
func GetDevicesForMulticastGroup ¶
func GetDevicesForMulticastGroup(db sqlx.Queryer, multicastGroupID uuid.UUID, limit, offset int) ([]DeviceListItem, error)
GetDevicesForMulticastGroup returns a slice of devices for the given multicast-group.
type DeviceProfile ¶
type DeviceProfile struct { NetworkServerID int64 `db:"network_server_id"` OrganizationID int64 `db:"organization_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` DeviceProfile ns.DeviceProfile `db:"-"` }
DeviceProfile defines the device-profile.
func GetDeviceProfile ¶
GetDeviceProfile returns the device-profile matching the given id.
func (DeviceProfile) Validate ¶
func (dp DeviceProfile) Validate() error
Validate validates the device-profile data.
type DeviceProfileMeta ¶
type DeviceProfileMeta struct { DeviceProfileID uuid.UUID `db:"device_profile_id"` NetworkServerID int64 `db:"network_server_id"` OrganizationID int64 `db:"organization_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` }
DeviceProfileMeta defines the device-profile meta record.
func GetDeviceProfiles ¶
func GetDeviceProfiles(db sqlx.Queryer, limit, offset int) ([]DeviceProfileMeta, error)
GetDeviceProfiles returns a slice of device-profiles.
func GetDeviceProfilesForApplicationID ¶
func GetDeviceProfilesForApplicationID(db sqlx.Queryer, applicationID int64, limit, offset int) ([]DeviceProfileMeta, error)
GetDeviceProfilesForApplicationID returns a slice of device-profiles that can be used for the given application id (based on the service-profile of the application).
func GetDeviceProfilesForOrganizationID ¶
func GetDeviceProfilesForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]DeviceProfileMeta, error)
GetDeviceProfilesForOrganizationID returns a slice of device-profiles for the given organization id.
func GetDeviceProfilesForUser ¶
func GetDeviceProfilesForUser(db sqlx.Queryer, username string, limit, offset int) ([]DeviceProfileMeta, error)
GetDeviceProfilesForUser returns a slice of device-profiles for the given username.
type ExtraChannel ¶
type ExtraChannel struct { Modulation string Frequency int Bandwidth int Bitrate int SpreadingFactors []int }
ExtraChannel defines an extra channel for the gateway-profile.
type GPSPoint ¶
GPSPoint contains a GPS point.
type Gateway ¶
type Gateway struct { MAC lorawan.EUI64 `db:"mac"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` Description string `db:"description"` OrganizationID int64 `db:"organization_id"` Ping bool `db:"ping"` LastPingID *int64 `db:"last_ping_id"` LastPingSentAt *time.Time `db:"last_ping_sent_at"` NetworkServerID int64 `db:"network_server_id"` GatewayProfileID *string `db:"gateway_profile_id"` }
Gateway represents a gateway.
func GetGateway ¶
GetGateway returns the gateway for the given mac.
func GetGateways ¶
GetGateways returns a slice of gateways sorted by name.
func GetGatewaysForOrganizationID ¶
func GetGatewaysForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int, search string) ([]Gateway, error)
GetGatewaysForOrganizationID returns a slice of gateways sorted by name for the given organization ID.
type GatewayPing ¶
type GatewayPing struct { ID int64 `db:"id"` CreatedAt time.Time `db:"created_at"` GatewayMAC lorawan.EUI64 `db:"gateway_mac"` Frequency int `db:"frequency"` DR int `db:"dr"` }
GatewayPing represents a gateway ping.
func GetGatewayPing ¶
func GetGatewayPing(db sqlx.Queryer, id int64) (GatewayPing, error)
GetGatewayPing returns the ping matching the given id.
type GatewayPingRX ¶
type GatewayPingRX struct { ID int64 `db:"id"` PingID int64 `db:"ping_id"` CreatedAt time.Time `db:"created_at"` GatewayMAC lorawan.EUI64 `db:"gateway_mac"` ReceivedAt *time.Time `db:"received_at"` RSSI int `db:"rssi"` LoRaSNR float64 `db:"lora_snr"` Location GPSPoint `db:"location"` Altitude float64 `db:"altitude"` }
GatewayPingRX represents a ping received by one of the gateways.
func GetGatewayPingRXForPingID ¶
func GetGatewayPingRXForPingID(db sqlx.Queryer, pingID int64) ([]GatewayPingRX, error)
GetGatewayPingRXForPingID returns the received gateway pings for the given ping ID.
type GatewayProfile ¶
type GatewayProfile struct { NetworkServerID int64 `db:"network_server_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` GatewayProfile ns.GatewayProfile `db:"-"` }
GatewayProfile defines a gateway-profile.
func GetGatewayProfile ¶
GetGatewayProfile returns the gateway-profile matching the given id.
type GatewayProfileMeta ¶
type GatewayProfileMeta struct { GatewayProfileID uuid.UUID `db:"gateway_profile_id"` NetworkServerID int64 `db:"network_server_id"` NetworkServerName string `db:"network_server_name"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` }
GatewayProfileMeta defines the gateway-profile meta record.
func GetGatewayProfiles ¶
func GetGatewayProfiles(db sqlx.Queryer, limit, offset int) ([]GatewayProfileMeta, error)
GetGatewayProfiles returns a slice of gateway-profiles.
func GetGatewayProfilesForNetworkServerID ¶
func GetGatewayProfilesForNetworkServerID(db sqlx.Queryer, networkServerID int64, limit, offset int) ([]GatewayProfileMeta, error)
GetGatewayProfilesForNetworkServerID returns a slice of gateway-profiles for the given network-server ID.
type Integration ¶
type Integration struct { ID int64 `db:"id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` ApplicationID int64 `db:"application_id"` Kind string `db:"kind"` Settings json.RawMessage `db:"settings"` }
Integration represents an integration.
func GetIntegration ¶
func GetIntegration(db sqlx.Queryer, id int64) (Integration, error)
GetIntegration returns the Integration for the given id.
func GetIntegrationByApplicationID ¶
func GetIntegrationByApplicationID(db sqlx.Queryer, applicationID int64, kind string) (Integration, error)
GetIntegrationByApplicationID returns the Integration for the given application id and kind.
func GetIntegrationsForApplicationID ¶
func GetIntegrationsForApplicationID(db sqlx.Queryer, applicationID int64) ([]Integration, error)
GetIntegrationsForApplicationID returns the integrations for the given application id.
type MulticastGroup ¶
type MulticastGroup struct { CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` MCAppSKey lorawan.AES128Key `db:"mc_app_s_key"` ServiceProfileID uuid.UUID `db:"service_profile_id"` MulticastGroup ns.MulticastGroup `db:"-"` }
MulticastGroup defines the multicast-group.
func GetMulticastGroup ¶
func GetMulticastGroup(db sqlx.Queryer, id uuid.UUID, forUpdate, localOnly bool) (MulticastGroup, error)
GetMulticastGroup returns the multicast-group given an id.
type MulticastGroupFilters ¶
type MulticastGroupFilters struct { OrganizationID int64 `db:"organization_id"` ServiceProfileID uuid.UUID `db:"service_profile_id"` DevEUI lorawan.EUI64 `db:"dev_eui"` Search string `db:"search"` // Limit and Offset are added for convenience so that this struct can // be given as the arguments. Limit int `db:"limit"` Offset int `db:"offset"` }
MulticastGroupFilters provide filters that can be used to filter on multicast-groups. Note that empty values are not used as filters.
func (MulticastGroupFilters) SQL ¶
func (f MulticastGroupFilters) SQL() string
SQL returns the SQL filter.
type MulticastGroupListItem ¶
type MulticastGroupListItem struct { ID uuid.UUID `db:"id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` ServiceProfileID uuid.UUID `db:"service_profile_id"` ServiceProfileName string `db:"service_profile_name"` }
MulticastGroupListItem defines the multicast-group for listing.
func GetMulticastGroups ¶
func GetMulticastGroups(db sqlx.Queryer, filters MulticastGroupFilters) ([]MulticastGroupListItem, error)
GetMulticastGroups returns a slice of multicast-groups, given the privded filters. Note that empty values are not used as filters.
type NetworkServer ¶
type NetworkServer struct { ID int64 `db:"id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` Server string `db:"server"` CACert string `db:"ca_cert"` TLSCert string `db:"tls_cert"` TLSKey string `db:"tls_key"` RoutingProfileCACert string `db:"routing_profile_ca_cert"` RoutingProfileTLSCert string `db:"routing_profile_tls_cert"` RoutingProfileTLSKey string `db:"routing_profile_tls_key"` GatewayDiscoveryEnabled bool `db:"gateway_discovery_enabled"` GatewayDiscoveryInterval int `db:"gateway_discovery_interval"` GatewayDiscoveryTXFrequency int `db:"gateway_discovery_tx_frequency"` GatewayDiscoveryDR int `db:"gateway_discovery_dr"` }
NetworkServer defines the information to connect to a network-server.
func GetNetworkServer ¶
func GetNetworkServer(db sqlx.Queryer, id int64) (NetworkServer, error)
GetNetworkServer returns the network-server matching the given id.
func GetNetworkServerForDevEUI ¶
GetNetworkServerForDevEUI returns the network-server for the given DevEUI.
func GetNetworkServerForDeviceProfileID ¶
GetNetworkServerForDeviceProfileID returns the network-server for the given device-profile id.
func GetNetworkServerForGatewayMAC ¶
GetNetworkServerForGatewayMAC returns the network-server for a given gateway mac.
func GetNetworkServerForGatewayProfileID ¶
GetNetworkServerForGatewayProfileID returns the network-server for the given gateway-profile id.
func GetNetworkServerForMulticastGroupID ¶
GetNetworkServerForMulticastGroupID returns the network-server for the given multicast-group id.
func GetNetworkServerForServiceProfileID ¶
GetNetworkServerForServiceProfileID returns the network-server for the given service-profile id.
func GetNetworkServers ¶
func GetNetworkServers(db sqlx.Queryer, limit, offset int) ([]NetworkServer, error)
GetNetworkServers returns a slice of network-servers.
func GetNetworkServersForOrganizationID ¶
func GetNetworkServersForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]NetworkServer, error)
GetNetworkServersForOrganizationID returns a slice of network-server accessible for the given organization id. A network-server is accessible for an organization when it is used by one of its service-profiles.
func (NetworkServer) Validate ¶
func (ns NetworkServer) Validate() error
Validate validates the network-server data.
type Organization ¶
type Organization struct { ID int64 `db:"id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` DisplayName string `db:"display_name"` CanHaveGateways bool `db:"can_have_gateways"` }
Organization represents an organization.
func GetOrganization ¶
func GetOrganization(db sqlx.Queryer, id int64) (Organization, error)
GetOrganization returns the Organization for the given id.
func GetOrganizations ¶
GetOrganizations returns a slice of organizations, sorted by name and respecting the given limit and offset.
func GetOrganizationsForUser ¶
func GetOrganizationsForUser(db sqlx.Queryer, username string, limit, offset int, search string) ([]Organization, error)
GetOrganizationsForUser returns a slice of organizations to which the given user is member of.
func (Organization) Validate ¶
func (o Organization) Validate() error
Validate validates the data of the Organization.
type OrganizationUser ¶
type OrganizationUser struct { UserID int64 `db:"user_id"` Username string `db:"username"` IsAdmin bool `db:"is_admin"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
OrganizationUser represents an organization user.
func GetOrganizationUser ¶
func GetOrganizationUser(db sqlx.Queryer, organizationID, userID int64) (OrganizationUser, error)
GetOrganizationUser gets the information of the given organization user.
func GetOrganizationUsers ¶
func GetOrganizationUsers(db sqlx.Queryer, organizationID int64, limit, offset int) ([]OrganizationUser, error)
GetOrganizationUsers returns the users for the given organization.
type SearchResult ¶
type SearchResult struct { Kind string `db:"kind"` Score float64 `db:"score"` OrganizationID *int64 `db:"organization_id"` OrganizationName *string `db:"organization_name"` ApplicationID *int64 `db:"application_id"` ApplicationName *string `db:"application_name"` DeviceDevEUI *lorawan.EUI64 `db:"device_dev_eui"` DeviceName *string `db:"device_name"` GatewayMAC *lorawan.EUI64 `db:"gateway_mac"` GatewayName *string `db:"gateway_name"` }
SearchResult defines a search result.
func GlobalSearch ¶
func GlobalSearch(db sqlx.Queryer, username string, globalAdmin bool, search string, limit, offset int) ([]SearchResult, error)
GlobalSearch performs a search on organizations, applications, gateways and devices.
type ServiceProfile ¶
type ServiceProfile struct { NetworkServerID int64 `db:"network_server_id"` OrganizationID int64 `db:"organization_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` ServiceProfile ns.ServiceProfile `db:"-"` }
ServiceProfile defines the service-profile.
func GetServiceProfile ¶
GetServiceProfile returns the service-profile matching the given id.
func (ServiceProfile) Validate ¶
func (sp ServiceProfile) Validate() error
Validate validates the service-profile data.
type ServiceProfileMeta ¶
type ServiceProfileMeta struct { ServiceProfileID uuid.UUID `db:"service_profile_id"` NetworkServerID int64 `db:"network_server_id"` OrganizationID int64 `db:"organization_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Name string `db:"name"` }
ServiceProfileMeta defines the service-profile meta record.
func GetServiceProfiles ¶
func GetServiceProfiles(db sqlx.Queryer, limit, offset int) ([]ServiceProfileMeta, error)
GetServiceProfiles returns a slice of service-profiles.
func GetServiceProfilesForOrganizationID ¶
func GetServiceProfilesForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]ServiceProfileMeta, error)
GetServiceProfilesForOrganizationID returns a slice of service-profiles for the given organization id.
func GetServiceProfilesForUser ¶
func GetServiceProfilesForUser(db sqlx.Queryer, username string, limit, offset int) ([]ServiceProfileMeta, error)
GetServiceProfilesForUser returns a slice of service-profile for the given username.
type User ¶
type User struct { ID int64 `db:"id"` Username string `db:"username"` IsAdmin bool `db:"is_admin"` IsActive bool `db:"is_active"` SessionTTL int32 `db:"session_ttl"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` PasswordHash string `db:"password_hash"` Email string `db:"email"` Note string `db:"note"` }
User represents a user to external code.
func GetUserByUsername ¶
GetUserByUsername returns the User for the given username.
type UserProfile ¶
type UserProfile struct { User UserProfileUser Organizations []UserProfileOrganization }
UserProfile contains the profile of the user.
func GetProfile ¶
func GetProfile(db sqlx.Queryer, id int64) (UserProfile, error)
GetProfile returns the user profile (user, applications and organizations to which the user is linked).
type UserProfileApplication ¶
type UserProfileApplication struct { ID int64 `db:"application_id"` Name string `db:"application_name"` IsAdmin bool `db:"is_admin"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
UserProfileApplication contains the applications to which the user is linked.
type UserProfileOrganization ¶
type UserProfileOrganization struct { ID int64 `db:"organization_id"` Name string `db:"organization_name"` IsAdmin bool `db:"is_admin"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
UserProfileOrganization contains the organizations to which the user is linked.
type UserProfileUser ¶
type UserProfileUser struct { ID int64 `db:"id"` Username string `db:"username"` IsAdmin bool `db:"is_admin"` IsActive bool `db:"is_active"` SessionTTL int32 `db:"session_ttl"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
UserProfileUser contains the user information of the profile.
type UserUpdate ¶
type UserUpdate struct { ID int64 `db:"id"` Username string `db:"username"` IsAdmin bool `db:"is_admin"` IsActive bool `db:"is_active"` SessionTTL int32 `db:"session_ttl"` Email string `db:"email"` Note string `db:"note"` }
UserUpdate represents the user fields that can be "updated" in the simple case. This excludes id, which identifies the record to be updated.