nbiot-go: github.com/telenordigital/nbiot-go Index | Files

package nbiot

import "github.com/telenordigital/nbiot-go"

Package nbiot-go provides a client for the REST API for Telenor NB-IoT.

All Create* and Update* methods return the created and updated entity, respectively, which may include setting or updating fields.

Index

Package Files

client.go collection.go config.go device.go downstream.go output.go outputstream.go team.go

Constants

const (
    // DefaultAddr is the default address of the Telenor NB-IoT API. You normally won't
    // have to change this.
    DefaultAddr = "https://api.nbiot.telenor.io"

    // ConfigFile is the name for the config file. The configuration file is a
    // plain text file that contains the Telenor NB-IoT configuration.
    // The configuration file is expected to be in the current home directory
    // and contain a "address=<value>" line and/or a "token=<value>" line.
    ConfigFile = ".telenor-nbiot"

    // AddressEnvironmentVariable is the name of the environment variable that
    // can be used to override the address set in the configuration file.
    // If the  environment variable isn't set (or is empty) the configuration
    // file settings will be used.
    AddressEnvironmentVariable = "TELENOR_NBIOT_ADDRESS"

    // TokenEnvironmentVariable is the name of the environment variable that
    // can be used to override the token set in the configuration file.
    TokenEnvironmentVariable = "TELENOR_NBIOT_TOKEN"
)

type BroadcastError Uses

type BroadcastError struct {
    DeviceID string `json:"deviceId"`
    Message  string `json:"message"`
}

BroadcastError is an error from a broadcast.

type BroadcastResult Uses

type BroadcastResult struct {
    Sent   int              `json:"sent"`
    Failed int              `json:"failed"`
    Errors []BroadcastError `json:"errors"`
}

BroadcastResult is the result of a broadcast.

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client is a client for Telenor NB-IoT.

func New Uses

func New() (*Client, error)

New creates a new client with the default configuration. The default configuration can be specified in a configuration file or through environment variables.

func NewWithAddr Uses

func NewWithAddr(addr, token string) (*Client, error)

NewWithAddr creates a new client with the specified address and token.

func (*Client) AcceptInvite Uses

func (c *Client) AcceptInvite(code string) (t Team, err error)

AcceptInvite accepts a invite.

func (*Client) Address Uses

func (c *Client) Address() string

Address returns the client's address.

func (*Client) Broadcast Uses

func (c *Client) Broadcast(collectionID string, msg DownstreamMessage) (result BroadcastResult, err error)

Broadcast sends a message to all devices in a collection.

func (*Client) Collection Uses

func (c *Client) Collection(id string) (Collection, error)

Collection gets a collection.

func (*Client) CollectionData Uses

func (c *Client) CollectionData(collectionID string, since time.Time, until time.Time, limit int) ([]OutputDataMessage, error)

CollectionData returns all the stored data for the collection.

func (*Client) CollectionOutputStream Uses

func (c *Client) CollectionOutputStream(collectionID string) (*OutputStream, error)

CollectionOutputStream streams messages from all devices in a collection.

func (*Client) Collections Uses

func (c *Client) Collections() ([]Collection, error)

Collections gets all collections that the user has access to.

func (*Client) CreateCollection Uses

func (c *Client) CreateCollection(collection Collection) (Collection, error)

CreateCollection creates a collection.

func (*Client) CreateDevice Uses

func (c *Client) CreateDevice(collectionID string, device Device) (Device, error)

CreateDevice creates a device.

func (*Client) CreateInvite Uses

func (c *Client) CreateInvite(teamID string) (Invite, error)

CreateInvite creates a invite.

func (*Client) CreateOutput Uses

func (c *Client) CreateOutput(collectionID string, output Output) (Output, error)

CreateOutput creates an output

func (*Client) CreateTeam Uses

func (c *Client) CreateTeam(team Team) (Team, error)

CreateTeam creates a team.

func (*Client) DeleteCollection Uses

func (c *Client) DeleteCollection(id string) error

DeleteCollection deletes a collection.

func (*Client) DeleteCollectionTag Uses

func (c *Client) DeleteCollectionTag(id, name string) error

DeleteCollectionTag deletes a tag from a collection.

func (*Client) DeleteDevice Uses

func (c *Client) DeleteDevice(collectionID, deviceID string) error

DeleteDevice deletes a device.

func (*Client) DeleteDeviceTag Uses

func (c *Client) DeleteDeviceTag(collectionID, deviceID, name string) error

DeleteDeviceTag deletes a tag from a device.

func (*Client) DeleteInvite Uses

func (c *Client) DeleteInvite(teamID, code string) error

DeleteInvite deletes an invite.

func (*Client) DeleteOutput Uses

func (c *Client) DeleteOutput(collectionID, outputID string) error

DeleteOutput removes an output

func (*Client) DeleteOutputTag Uses

func (c *Client) DeleteOutputTag(collectionID, outputID, name string) error

DeleteOutputTag deletes a tag from an output.

func (*Client) DeleteTeam Uses

func (c *Client) DeleteTeam(id string) error

DeleteTeam deletes a team.

func (*Client) DeleteTeamMember Uses

func (c *Client) DeleteTeamMember(teamID, userID string) error

DeleteTeamMember deletes a team member.

func (*Client) DeleteTeamTag Uses

func (c *Client) DeleteTeamTag(id, name string) error

DeleteTeamTag deletes a tag from a team.

func (*Client) Device Uses

func (c *Client) Device(collectionID, deviceID string) (Device, error)

Device gets a device.

func (*Client) DeviceData Uses

func (c *Client) DeviceData(collectionID, deviceID string, since time.Time, until time.Time, limit int) ([]OutputDataMessage, error)

DeviceData returns all the stored data for the device.

func (*Client) DeviceOutputStream Uses

func (c *Client) DeviceOutputStream(collectionID, deviceID string) (*OutputStream, error)

DeviceOutputStream streams messages from one device.

func (*Client) Devices Uses

func (c *Client) Devices(collectionID string) ([]Device, error)

Devices gets all devices in the collection.

func (*Client) Invite Uses

func (c *Client) Invite(teamID, code string) (Invite, error)

Invite gets an invite.

func (*Client) Invites Uses

func (c *Client) Invites(teamID string) ([]Invite, error)

Invites gets all invites for the team.

func (*Client) Output Uses

func (c *Client) Output(collectionID, outputID string) (Output, error)

Output retrieves an output

func (*Client) OutputLogs Uses

func (c *Client) OutputLogs(collectionID, outputID string) ([]OutputLogEntry, error)

OutputLogs returns the logs for an output.

func (*Client) OutputStatus Uses

func (c *Client) OutputStatus(collectionID, outputID string) (stat OutputStatus, err error)

OutputStatus returns the status for an output.

func (*Client) Outputs Uses

func (c *Client) Outputs(collectionID string) ([]Output, error)

Outputs retrieves a list of outputs on a collection

func (*Client) Send Uses

func (c *Client) Send(collectionID, deviceID string, msg DownstreamMessage) error

Send sends a message to a device.

func (*Client) SystemDefaults Uses

func (c *Client) SystemDefaults() (SystemDefaults, error)

SystemDefaults returns the system defaults.

func (*Client) Team Uses

func (c *Client) Team(id string) (Team, error)

Team gets a team.

func (*Client) Teams Uses

func (c *Client) Teams() ([]Team, error)

Teams gets all teams that the user belongs to.

func (*Client) UpdateCollection Uses

func (c *Client) UpdateCollection(collection Collection) (Collection, error)

UpdateCollection updates a collection. No tags are deleted, only added or updated.

func (*Client) UpdateDevice Uses

func (c *Client) UpdateDevice(collectionID string, device Device) (Device, error)

UpdateDevice updates a device. No tags are deleted, only added or updated.

func (*Client) UpdateOutput Uses

func (c *Client) UpdateOutput(collectionID string, output Output) (Output, error)

UpdateOutput updates an output. The type field can't be modified No tags are deleted, only added or updated.

func (*Client) UpdateTeam Uses

func (c *Client) UpdateTeam(team Team) (Team, error)

UpdateTeam updates a team, but not its members. No tags are deleted, only added or updated.

func (*Client) UpdateTeamMemberRole Uses

func (c *Client) UpdateTeamMemberRole(teamID, userID, role string) (Member, error)

UpdateTeamMemberRole updates the role of a team member.

type ClientError Uses

type ClientError struct {
    HTTPStatusCode int
    Message        string
}

ClientError describes what went wrong with a request that otherwise succeeded but which resulted in an HTTP status code >= 300.

func (ClientError) Error Uses

func (e ClientError) Error() string

type Collection Uses

type Collection struct {
    ID        string            `json:"collectionId"`
    TeamID    string            `json:"teamId,omitempty"`
    FieldMask *FieldMask        `json:"fieldMask,omitempty"`
    Tags      map[string]string `json:"tags,omitempty"`
}

Collection represents a collection.

type Device Uses

type Device struct {
    ID           string            `json:"deviceId"`
    CollectionID string            `json:"collectionId,omitempty"`
    IMEI         string            `json:"imei,omitempty"`
    IMSI         string            `json:"imsi,omitempty"`
    Tags         map[string]string `json:"tags,omitempty"`
}

Device represents a device.

type DownstreamMessage Uses

type DownstreamMessage struct {
    Port    int    `json:"port"`
    Payload []byte `json:"payload"`
}

DownstreamMessage is a message to be sent to a device.

type FieldMask Uses

type FieldMask struct {
    IMSI     *bool `json:"imsi"`
    IMEI     *bool `json:"imei"`
    Location *bool `json:"location"`
    MSISDN   *bool `json:"msisdn"`
}

FieldMask indicates which fields will be masked from API responses.

type IFTTTOutput Uses

type IFTTTOutput struct {
    ID           string
    CollectionID string
    Key          string
    EventName    string
    AsIsPayload  bool
    Disabled     bool
    Tags         map[string]string
}

IFTTTOutput describes an IFTTT output.

func (IFTTTOutput) GetCollectionID Uses

func (o IFTTTOutput) GetCollectionID() string

GetCollectionID returns the collection ID.

func (IFTTTOutput) GetID Uses

func (o IFTTTOutput) GetID() string

GetID returns the output ID.

func (IFTTTOutput) GetTags Uses

func (o IFTTTOutput) GetTags() map[string]string

GetTags returns the output's tags.

func (IFTTTOutput) IsDisabled Uses

func (o IFTTTOutput) IsDisabled() bool

IsDisabled returns whether the output is disabled.

type Invite Uses

type Invite struct {
    Code      string `json:"code"`
    CreatedAt int    `json:"createdAt"` // time stamp (in ms)
}

Invite is an invitation to a team.

type MQTTOutput Uses

type MQTTOutput struct {
    ID               string
    CollectionID     string
    Endpoint         string
    DisableCertCheck bool
    Username         string
    Password         string
    ClientID         string
    TopicName        string
    Disabled         bool
    Tags             map[string]string
}

MQTTOutput describes an MQTT output.

func (MQTTOutput) GetCollectionID Uses

func (o MQTTOutput) GetCollectionID() string

GetCollectionID returns the collection ID.

func (MQTTOutput) GetID Uses

func (o MQTTOutput) GetID() string

GetID returns the output ID.

func (MQTTOutput) GetTags Uses

func (o MQTTOutput) GetTags() map[string]string

GetTags returns the output's tags.

func (MQTTOutput) IsDisabled Uses

func (o MQTTOutput) IsDisabled() bool

IsDisabled returns whether the output is disabled.

type Member Uses

type Member struct {
    UserID        string `json:"userId"`
    Role          string `json:"role"`
    Name          string `json:"name,omitempty"`
    Email         string `json:"email,omitempty"`
    Phone         string `json:"phone,omitempty"`
    VerifiedEmail bool   `json:"verifiedEmail"`
    VerifiedPhone bool   `json:"verifiedPhone"`
    ConnectID     string `json:"connectId,omitempty"`
    GitHubLogin   string `json:"gitHubLogin,omitempty"`
    AuthType      string `json:"authType,omitempty"`
    AvatarURL     string `json:"avatarUrl,omitempty"`
}

Member is a member of a team.

type Output Uses

type Output interface {
    GetID() string
    GetCollectionID() string
    IsDisabled() bool
    GetTags() map[string]string
    // contains filtered or unexported methods
}

Output represents a data output for a collection. WebHookOutput, MQTTOutput, IFTTTOutput, and UDPOutput implement this interface.

type OutputDataMessage Uses

type OutputDataMessage struct {
    Device   Device `json:"device"`
    Payload  []byte `json:"payload"`
    Received int64  `json:"received"`
}

OutputDataMessage represents a message sent by a device.

type OutputLogEntry Uses

type OutputLogEntry struct {
    Message   string `json:"message"`   // The message itself
    Timestamp int64  `json:"timestamp"` // Time in ms
    Repeated  uint8  `json:"repeated"`  // Repeat count
}

OutputLogEntry is an entry in an output log.

type OutputStatus Uses

type OutputStatus struct {
    ErrorCount int `json:"errorCount"`
    Forwarded  int `json:"forwarded"`
    Received   int `json:"received"`
    Retries    int `json:"retries"`
}

OutputStatus is the status of an output.

type OutputStream Uses

type OutputStream struct {
    // contains filtered or unexported fields
}

OutputStream provides a stream of OutputDataMessages.

func (*OutputStream) Close Uses

func (s *OutputStream) Close()

Close closes the output stream.

func (*OutputStream) Recv Uses

func (s *OutputStream) Recv() (OutputDataMessage, error)

Recv blocks until a new message is received. It returns io.EOF if the stream is closed by the server.

type SystemDefaults Uses

type SystemDefaults struct {
    DefaultFieldMask *FieldMask `json:"defaultFieldMask,omitempty"`
    ForcedFieldMask  *FieldMask `json:"forcedFieldMask,omitempty"`
}

SystemDefaults is the system defaults.

type Team Uses

type Team struct {
    ID      string            `json:"teamId"`
    Members []Member          `json:"members,omitempty"`
    Tags    map[string]string `json:"tags,omitempty"`
}

Team represents a team.

type UDPOutput Uses

type UDPOutput struct {
    ID           string
    CollectionID string
    Host         string
    Port         int
    Disabled     bool
    Tags         map[string]string
}

UDPOutput describes a UDP output.

func (UDPOutput) GetCollectionID Uses

func (o UDPOutput) GetCollectionID() string

GetCollectionID returns the collection ID.

func (UDPOutput) GetID Uses

func (o UDPOutput) GetID() string

GetID returns the output ID.

func (UDPOutput) GetTags Uses

func (o UDPOutput) GetTags() map[string]string

GetTags returns the output's tags.

func (UDPOutput) IsDisabled Uses

func (o UDPOutput) IsDisabled() bool

IsDisabled returns whether the output is disabled.

type WebHookOutput Uses

type WebHookOutput struct {
    ID                string
    CollectionID      string
    URL               string
    BasicAuthUser     string
    BasicAuthPass     string
    CustomHeaderName  string
    CustomHeaderValue string
    Disabled          bool
    Tags              map[string]string
}

WebHookOutput describes a webhook output.

func (WebHookOutput) GetCollectionID Uses

func (o WebHookOutput) GetCollectionID() string

GetCollectionID returns the collection ID.

func (WebHookOutput) GetID Uses

func (o WebHookOutput) GetID() string

GetID returns the output ID.

func (WebHookOutput) GetTags Uses

func (o WebHookOutput) GetTags() map[string]string

GetTags returns the output's tags.

func (WebHookOutput) IsDisabled Uses

func (o WebHookOutput) IsDisabled() bool

IsDisabled returns whether the output is disabled.

Package nbiot imports 12 packages (graph). Updated 2019-04-20. Refresh now. Tools for package owners.