Documentation ¶
Index ¶
- type Account
- func New(server string) *Account
- func NewWithAccessToken(server, accessToken string) *Account
- func NewWithBasicAuth(server, username, password string) *Account
- func NewWithKey(server, accessKey string) *Account
- func NewWithManager(server, accessToken string, manager tokens.Manager) *Account
- func NewWithPublic(server string) *Account
- func (a *Account) AddAccessKey(appID string, name string, rights []types.Right) (key types.AccessKey, err error)
- func (a *Account) AddEUI(appID string, eui types.AppEUI) error
- func (a *Account) AppRights(appID string) (rights []types.Right, err error)
- func (a *Account) BrokerToken(id string) (token string, err error)
- func (a *Account) ChangeAltitude(gatewayID string, altitude float64) error
- func (a *Account) ChangeFrequencyPlan(gatewayID, plan string) error
- func (a *Account) ChangeLocation(gatewayID string, latitude, longitude float64) error
- func (a *Account) ChangeName(appID string, name string) error
- func (a *Account) ChangeRouter(gatewayID string, router string) error
- func (a *Account) ComponentToken(typ, id string) (token string, err error)
- func (a *Account) CreateApplication(appID string, name string, EUIs []types.AppEUI) (app Application, err error)
- func (a *Account) CreateBroker(id string) error
- func (a *Account) CreateComponent(typ, id string) error
- func (a *Account) CreateHandler(id string) error
- func (a *Account) CreateRouter(id string) error
- func (a *Account) DeleteApplication(appID string) error
- func (a *Account) DeleteGateway(gatewayID string) error
- func (a *Account) EditGateway(gatewayID string, edits GatewayEdits) error
- func (a *Account) EditPassword(oldPassword, newPassword string) error
- func (a *Account) EditProfile(profile Profile) error
- func (a *Account) FindApplication(appID string) (app Application, err error)
- func (a *Account) FindBroker(id string) (component Component, err error)
- func (a *Account) FindComponent(typ, id string) (component Component, err error)
- func (a *Account) FindGateway(gatewayID string) (gateway Gateway, err error)
- func (a *Account) FindHandler(id string) (component Component, err error)
- func (a *Account) FindRouter(id string) (component Component, err error)
- func (a *Account) FrequencyPlans() (map[string]FrequencyPlan, error)
- func (a *Account) GenerateEUI(appID string) (*types.AppEUI, error)
- func (a *Account) GetGatewayToken(gatewayID string) (*oauth2.Token, error)
- func (a *Account) Grant(appID string, username string, rights []types.Right) error
- func (a *Account) GrantGatewayRights(gatewayID string, username string, rights []types.Right) error
- func (a *Account) HandlerToken(id string) (token string, err error)
- func (a *Account) ListApplications() (apps []Application, err error)
- func (a *Account) ListComponents() ([]Component, error)
- func (a *Account) ListGateways() (gateways []Gateway, err error)
- func (a *Account) Profile() (user Profile, err error)
- func (a *Account) RegisterGateway(gatewayID string, frequencyPlan string, location *Location) (gateway Gateway, err error)
- func (a *Account) RegisterUser(username, email, password string) error
- func (a *Account) RemoveAccessKey(appID string, name string) error
- func (a *Account) RemoveEUI(appID string, eui types.AppEUI) error
- func (a *Account) Retract(appID string, username string) error
- func (a *Account) RetractGatewayRights(gatewayID string, username string) error
- func (a *Account) RouterToken(id string) (token string, err error)
- func (a *Account) SetPublicRights(gatewayID string, rights []types.Right) error
- func (a *Account) StreamApplications() (*ApplicationStream, error)
- func (a *Account) StreamGateways() (*GatewayStream, error)
- func (a *Account) TransferOwnership(gatewayID, username string) error
- func (a *Account) WithAuth(strategy auth.Strategy) *Account
- func (a *Account) WithHeader(name, value string) *Account
- func (a *Account) WithLogger(logger log.Interface) *Account
- type Application
- type ApplicationStream
- type Collaborator
- type Component
- type ComponentType
- type FrequencyPlan
- type Gateway
- type GatewayAttributes
- type GatewayEdits
- type GatewayStream
- type Location
- type Name
- type Placement
- type Profile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account is a client to an account server
func NewWithAccessToken ¶
NewWithAccessToken creates a new account client that will use the accessToken to make requests to the specified account server
func NewWithBasicAuth ¶
NewWithBasicAuth creates an account client that uses basic authentication
func NewWithKey ¶
NewWithKey creates an account client that uses an accessKey to authenticate
func NewWithManager ¶
NewWithManager creates a new account client that will use the accessToken to make requests to the specified account server and the manager to request new tokens for different scopes
func NewWithPublic ¶
NewWithPublic creates an account client that does not use authentication
func (*Account) AddAccessKey ¶
func (a *Account) AddAccessKey(appID string, name string, rights []types.Right) (key types.AccessKey, err error)
AddAccessKey adds an access key to the application with the specified name and rights
func (*Account) AppRights ¶
AppRights returns the rights the current account client has to a certain application
func (*Account) BrokerToken ¶
BrokerToken gets the specified brokers token
func (*Account) ChangeAltitude ¶
ChangeAltitude changes the altitude of the gateway with the specified ID
func (*Account) ChangeFrequencyPlan ¶
ChangeFrequencyPlan changes the requency plan of a gateway
func (*Account) ChangeLocation ¶
ChangeLocation changes the location of the gateway
func (*Account) ChangeName ¶
ChangeName changes the application name
func (*Account) ChangeRouter ¶
ChangeRouter changes the router the gateway talks to
func (*Account) ComponentToken ¶
ComponentToken fetches a token for the component with the given type and id
func (*Account) CreateApplication ¶
func (a *Account) CreateApplication(appID string, name string, EUIs []types.AppEUI) (app Application, err error)
CreateApplication creates a new application on the account server
func (*Account) CreateBroker ¶
CreateBroker creates a broker with the specified id
func (*Account) CreateComponent ¶
CreateComponent creates a component with the specified type and id
func (*Account) CreateHandler ¶
CreateHandler creates a handler with the specified id
func (*Account) CreateRouter ¶
CreateRouter creates a Router with the specified id
func (*Account) DeleteApplication ¶
DeleteApplication deletes an application
func (*Account) DeleteGateway ¶
DeleteGateway removes a gateway from the account server
func (*Account) EditGateway ¶
func (a *Account) EditGateway(gatewayID string, edits GatewayEdits) error
EditGateway edits the fields of a gateway
func (*Account) EditPassword ¶
EditPassword edits the users password, it requires the old password to be given.
func (*Account) EditProfile ¶
EditProfile edits the users profile. You can change only part of the profile (only the name, for instance) by omitting the other fields from the passed in Profile struct.
func (*Account) FindApplication ¶
func (a *Account) FindApplication(appID string) (app Application, err error)
FindApplication gets a specific application from the account server
func (*Account) FindBroker ¶
FindBroker finds a broker with the specified id
func (*Account) FindComponent ¶
FindComponent finds a comonent of the specified type with the specified id
func (*Account) FindGateway ¶
FindGateway returns the information about a specific gateay
func (*Account) FindHandler ¶
FindHandler finds a handler with the specified id
func (*Account) FindRouter ¶
FindRouter finds a router with the specified id
func (*Account) FrequencyPlans ¶
func (a *Account) FrequencyPlans() (map[string]FrequencyPlan, error)
FrequencyPlans returns the frequency plans the account server supports
func (*Account) GenerateEUI ¶
GenerateEUI creates a new EUI for the application
func (*Account) GetGatewayToken ¶
GetGatewayToken gets the gateway token
func (*Account) GrantGatewayRights ¶
GrantGatewayRights grants rights to a collaborator of the gateway
func (*Account) HandlerToken ¶
HandlerToken gets the specified handlers token
func (*Account) ListApplications ¶
func (a *Account) ListApplications() (apps []Application, err error)
ListApplications list all applications
func (*Account) ListComponents ¶
ListComponents lists all of the users components
func (*Account) ListGateways ¶
ListGateways list all gateways
func (*Account) RegisterGateway ¶
func (a *Account) RegisterGateway(gatewayID string, frequencyPlan string, location *Location) (gateway Gateway, err error)
RegisterGateway registers a new gateway on the account server
func (*Account) RegisterUser ¶
RegisterUser registers a user on the account server
func (*Account) RemoveAccessKey ¶
RemoveAccessKey removes the specified access key from the application
func (*Account) RetractGatewayRights ¶
RetractGatewayRights removes rights from a collaborator of the gateway
func (*Account) RouterToken ¶
RouterToken gets the specified routers token
func (*Account) SetPublicRights ¶
SetPublicRights changes the publicily visible rights of the gateway
func (*Account) StreamApplications ¶
func (a *Account) StreamApplications() (*ApplicationStream, error)
StreamGateways lists all gateways in a streaming fashion
func (*Account) StreamGateways ¶
func (a *Account) StreamGateways() (*GatewayStream, error)
StreamGateways lists all gateways in a streaming fashion
func (*Account) TransferOwnership ¶
TransferOwnership transfers the owenership of the gateway to another user
func (*Account) WithHeader ¶
WithHeader adds the header to every request to the account server
type Application ¶
type Application struct { ID string `json:"id" valid:"required"` Name string `json:"name" valid:"required"` EUIs []types.AppEUI `json:"euis,omitempty"` AccessKeys []types.AccessKey `json:"access_keys,omitempty"` Created time.Time `json:"created,omitempty"` Collaborators []Collaborator `json:"collaborators,omitempty"` }
Application represents an application on The Things Network
type ApplicationStream ¶
type ApplicationStream struct {
// contains filtered or unexported fields
}
GatewayStream is a stream of gateways that can be closed
func (*ApplicationStream) Close ¶
func (s *ApplicationStream) Close() error
Close closes the gateway stream
func (*ApplicationStream) Next ¶
func (s *ApplicationStream) Next() (*Application, error)
Next requests the next gateway on the stream, blocking until there is one If there are no more gateways, the error will be io.EOF
type Collaborator ¶
type Collaborator struct { Username string `json:"username" valid:"required"` Rights []types.Right `json:"rights" valid:"required"` }
Collaborator is a user that has rights to a certain application
type Component ¶
type Component struct { Type string `json:"type"` ID string `json:"id"` Created time.Time `json:"created,omitempty"` }
Component represents a component on the newtork
type ComponentType ¶
type ComponentType string
const ( Handler ComponentType = "handler" Router ComponentType = "router" Broker ComponentType = "broker" )
type FrequencyPlan ¶
type Gateway ¶
type Gateway struct { ID string `json:"id" valid:"required"` Activated bool `json:"activated"` FrequencyPlan string `json:"frequency_plan"` FrequencyPlanURL string `json:"frequency_plan_url"` PublicRights []types.Right `json:"public_rights"` LocationPublic bool `json:"location_public"` StatusPublic bool `json:"status_public"` AutoUpdate bool `json:"auto_update"` Location *Location `json:"location"` Altitude float64 `json:"altitude"` Collaborators []Collaborator `json:"collaborator"` Key string `json:"key"` Token *oauth2.Token Attributes GatewayAttributes `json:"attributes"` Router string `json:"string"` // contains filtered or unexported fields }
Gateway represents a gateway on the account server
type GatewayAttributes ¶
type GatewayEdits ¶
type GatewayEdits struct { Owner string `json:"owner,omitempty"` PublicRights []types.Right `json:"public_rights,omitempty"` FrequencyPlan string `json:"frequency_plan,omitempty"` AutoUpdate *bool `json:"auto_update,omitempty"` Location *Location `json:"location,omitempty"` Altitude float64 `json:"altitude,omitempty"` Attributes GatewayAttributes `json:"attributes,omitempty"` Router string `json:"router,omitempty"` }
GatewayEdits contains editable fields of gateways
type GatewayStream ¶
type GatewayStream struct {
// contains filtered or unexported fields
}
GatewayStream is a stream of gateways that can be closed
func (*GatewayStream) Next ¶
func (s *GatewayStream) Next() (*Gateway, error)
Next requests the next gateway on the stream, blocking until there is one If there are no more gateways, the error will be io.EOF
type Location ¶
type Location struct { // Empty denotes that the location is not given as oposed to (0, 0) which is a // valid location Empty bool `json:"-"` Longitude float64 `json:"lng"` Latitude float64 `json:"lat"` }
Location is the GPS location of a gateway
func (Location) MarshalJSON ¶
MarshalJSON is a custom json marshaller for Location that maps an empty Location to `false`
func (*Location) UnmarshalJSON ¶
UnmarshalJSON is a custom unmarshaller for location that allows falsy types false | {} | null -> Location{ Empty: true } ... -> Location