handler

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2020 License: BSD-3-Clause Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClientRegistered

func IsClientRegistered(db *sqlx.DB, clientID string) (bool, error)

IsClientRegistered checks is a client is registered

func ListClientsHandler

func ListClientsHandler(c *gin.Context)

ListClientsHandler is the admin handler for listing registered clients

func Register

func Register(db *sqlx.DB, req ClientData) (string, error)

Register a new client

func RegisterHandler

func RegisterHandler(c *gin.Context)

RegisterHandler this is the public endpoint handler for registering new clients

func Update

func Update(db *sqlx.DB, clientID string, req ClientData) error

Update the metadata for a client

func UpdateHandler

func UpdateHandler(c *gin.Context)

UpdateHandler device endpoint for registered probes to update their metadata

Types

type ActiveClient

type ActiveClient struct {
	ClientID string `json:"client_id"`

	ProbeCC  string `json:"probe_cc"`
	ProbeASN string `json:"probe_asn"`
	Platform string `json:"platform"`

	SoftwareName    string `json:"software_name"`
	SoftwareVersion string `json:"software_version"`
	SupportedTests  string `json:"supported_tests"`

	NetworkType        string `json:"network_type"`
	AvailableBandwidth string `json:"available_bandwidth"`
	Language           string `json:"language"`

	Token string `json:"token"`

	ProbeFamily string `json:"probe_family"`
	ProbeID     string `json:"probe_id"`

	LastUpdated  time.Time `json:"last_updated"`
	CreationTime time.Time `json:"creation_time"`
}

ActiveClient metadata about an active client

func ListClients

func ListClients(db *sqlx.DB, q ClientsQuery) ([]ActiveClient, error)

ListClients lists all the clients in the database

type ClientData

type ClientData struct {
	ProbeCC  string `json:"probe_cc" binding:"required"`
	ProbeASN string `json:"probe_asn" binding:"required"`
	Platform string `json:"platform" binding:"required"`

	SoftwareName    string   `json:"software_name" binding:"required"`
	SoftwareVersion string   `json:"software_version" binding:"required"`
	SupportedTests  []string `json:"supported_tests" binding:"required"`

	NetworkType        string `json:"network_type"`
	AvailableBandwidth string `json:"available_bandwidth"`
	Language           string `json:"language"`

	Token string `json:"token"`

	ProbeFamily string `json:"probe_family"`
	ProbeID     string `json:"probe_id"`

	Password string `json:"password"`
}

ClientData metadata about a client

type ClientsQuery

type ClientsQuery struct {
	Limit       int64  `form:"limit" binding:"max=1000"`
	Offset      int64  `form:"offset"`
	CountryCode string `form:"country_code"`
}

ClientsQuery this is the query for the clients to be retrieved from the DB

func (ClientsQuery) MakeMetadata

func (q ClientsQuery) MakeMetadata(db *sqlx.DB) (Dict, error)

MakeMetadata generates the metadata for the request

type CountryCount

type CountryCount struct {
	CountryCode string `json:"probe_cc"`
	Count       int64  `json:"count"`
}

CountryCount is the count of active probes for the given country

type Dict

type Dict map[string]interface{}

Dict a dictionary datatype

Jump to

Keyboard shortcuts

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