Awesome Open Source
Awesome Open Source

Gomulocity

Gomulocity REST SDK

Go Go Report Card GitHub GitHub last commit

Gomulocity is a Go library to interact with the REST API of the Cumulocity IoT platform of Software AG (c8y).

Table of Contents

Usage

APIs are split into seperate imports you can select from:

import "github.com/tarent/gomulocity/alarm"
import "github.com/tarent/gomulocity/events"
import "github.com/tarent/gomulocity/measurement"
import "github.com/tarent/gomulocity/inventory"

The APIs need clients with credentials to work.

var c8yClient = &generic.Client{
	HTTPClient: http.DefaultClient,
	BaseURL:    "https://management.cumulocity.com",
	Username:   "user",
	Password:   "password",
}

Device Bootstrap

Configuration

The bootstrap API needs basic credentials to be able to register your client. Please contact your platform provider for the correct bootstrap credentials. Assure that the base url points to the correct platform instance.

var bootstrapClient = &generic.Client{
	HTTPClient: http.DefaultClient,
	BaseURL:    "https://management.cumulocity.com",
	Username:   "bootstrapuser",
	Password:   "password",
}

You can then register your device with a unique ID at your tenant:

	deviceId := "uniqueDeviceID"
	deviceCredentialsApi := device_bootstrap.NewDeviceCredentialsApi(bootstrapClient)

    deviceCredentials, _ := deviceCredentialsApi.Create(deviceId)

To register a device, you need to add the registration with the unique ID to your tenant via registration API or UI. More information about the registration cycle is available in the device integration part of the c8y docs. After obtaining credentials for your device, you need to create the device itself as a managed object. Use the inventory API to accomplish this.

Device Registration API

Start a new device registration with a unique device ID:

    deviceRegistration, err := gomulocity.DeviceRegistration.Create("123")

Get a device registration by device ID:

    deviceRegistration, err := gomulocity.DeviceRegistration.Get("123")

Get all device registrations page by page:

    deviceRegistrations, err := gomulocity.DeviceRegistration.GetAll(10)
    deviceRegistrations, err = gomulocity.DeviceRegistration.NextPage(deviceRegistrations)
    deviceRegistrations, err = gomulocity.DeviceRegistration.PreviousPage(deviceRegistrations)

Update device registration status:

    deviceRegistration, err := gomulocity.DeviceRegistration.Update("123", device_bootstrap.ACCEPTED)

Delete device registration by device ID:

    err := gomulocity.DeviceRegistration.Delete("123")

Device Credentials API

Create DeviceCredentials:

    deviceCredentials, err := gomulocity.DeviceCredentials.Create("123")

Feature coverage

REST API:

  • [x] inventory/managedObjects
  • [x] measurement
  • [x] alarm
  • [x] event
  • [x] deviceControl/operations
  • [x] bootstrapping
  • [x] identity
  • [ ] Realtime notifications via websockets
  • [x] audit
  • [x] user
  • [ ] tenant

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue with the owners of this repository before making a change.

License

See LICENSE file.

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Golang (164,214
Sdk (32,762
Rest (29,240
Cloud Computing (29,155
Bootstrap (28,125
Credentials (5,992
Registration (5,716
Golang Library (1,676
Unique Id (518
Cumulocity (43
C8y (7