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 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 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) Address Uses

func (c *Client) Address() string

Address returns the client's address.

func (*Client) Collection Uses

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

Collection gets a collection.

func (*Client) CollectionOutputStream Uses

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

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) 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) Data Uses

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

Data returns all the stored data for the collection

func (*Client) DeleteCollection Uses

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

DeleteCollection deletes a collection.

func (*Client) DeleteDevice Uses

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

DeleteDevice deletes a device.

func (*Client) DeleteOutput Uses

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

DeleteOutput removes an output

func (*Client) DeleteTeam Uses

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

DeleteTeam deletes a team.

func (*Client) Device Uses

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

Device gets a device.

func (*Client) DeviceOutputStream Uses

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

func (*Client) Devices Uses

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

Devices gets all devices in the collection.

func (*Client) Output Uses

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

Output retrieves 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) 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.

func (*Client) UpdateDevice Uses

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

UpdateDevice updates a device.

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

func (*Client) UpdateTeam Uses

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

UpdateTeam updates a team.

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 {
    CollectionID string            `json:"collectionId"`
    TeamID       *string           `json:"teamId"`
    Tags         map[string]string `json:"tags,omitempty"`
}

Collection represents a collection.

type Datapoint Uses

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

Datapoint represents a data point in a collection

type Device Uses

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

Device represents a device.

type IFTTTOutput Uses

type IFTTTOutput struct {
    ID           string
    CollectionID string
    Key          string
    EventName    string
    AsIsPayload  bool
}

type MQTTOutput Uses

type MQTTOutput struct {
    ID               string
    CollectionID     string
    Endpoint         string
    DisableCertCheck bool
    Username         string
    Password         string
    ClientID         string
    TopicName        string
}

type Member Uses

type Member struct {
    UserID        *string `json:"userId"`
    Role          *string `json:"role"`
    Email         *string `json:"email"`
    Phone         *string `json:"phone"`
    VerifiedEmail *bool   `json:"verifiedEmail"`
    VerifiedPhone *bool   `json:"verifiedPhone"`
    ConnectID     *string `json:"connectId"`
}

Member is the member element of the Team type

type Output Uses

type Output interface {
    // contains filtered or unexported methods
}

Output represents a data output for a collection

type OutputDataMessage Uses

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

type OutputStream Uses

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

func (*OutputStream) Close Uses

func (s *OutputStream) Close()

func (*OutputStream) Recv Uses

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

type Team Uses

type Team struct {
    TeamID  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
}

type WebHookOutput Uses

type WebHookOutput struct {
    ID                string
    CollectionID      string
    URL               string
    BasicAuthUser     string
    BasicAuthPass     string
    CustomHeaderName  string
    CustomHeaderValue string
}

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