sdk

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

Magistrala Go SDK

Go SDK, a Go driver for Magistrala HTTP API.

Does both system administration (provisioning) and messaging.

Installation

Import "github.com/andychao217/magistrala/sdk/go" in your Go package.

import "github.com/andychao217/magistrala/pkg/sdk/go"```

Then call SDK Go functions to interact with the system.

## API Reference

```go
FUNCTIONS

func NewMgxSDK(host, port string, tls bool) *MgxSDK

func (sdk *MgxSDK) Channel(id, token string) (things.Channel, error)
    Channel - gets channel by ID

func (sdk *MgxSDK) Channels(token string) ([]things.Channel, error)
    Channels - gets all channels

func (sdk *MgxSDK) Connect(struct{[]string, []string}, token string) error
    Connect - connect things to channels

func (sdk *MgxSDK) CreateChannel(data, token string) (string, error)
    CreateChannel - creates new channel and generates UUID

func (sdk *MgxSDK) CreateThing(data, token string) (string, error)
    CreateThing - creates new thing and generates thing UUID

func (sdk *MgxSDK) CreateToken(user, pwd string) (string, error)
    CreateToken - create user token

func (sdk *MgxSDK) CreateUser(user, pwd string) error
    CreateUser - create user

func (sdk *MgxSDK) User(pwd string) (user, error)
    User - gets user

func (sdk *MgxSDK) UpdateUser(user, pwd string) error
    UpdateUser - update user

func (sdk *MgxSDK) UpdatePassword(user, pwd string) error
    UpdatePassword - update user password

func (sdk *MgxSDK) DeleteChannel(id, token string) error
    DeleteChannel - removes channel

func (sdk *MgxSDK) DeleteThing(id, token string) error
    DeleteThing - removes thing

func (sdk *MgxSDK) DisconnectThing(thingID, chanID, token string) error
    DisconnectThing - connect thing to a channel

func (sdk *MgxSDK) SendMessage(chanID, msg, token string) error
    SendMessage - send message on Magistrala channel

func (sdk *MgxSDK) SetContentType(ct ContentType) error
    SetContentType - set message content type. Available options are SenML
    JSON, custom JSON and custom binary (octet-stream).

func (sdk *MgxSDK) Thing(id, token string) (Thing, error)
    Thing - gets thing by ID

func (sdk *MgxSDK) Things(token string) ([]Thing, error)
    Things - gets all things

func (sdk *MgxSDK) UpdateChannel(channel Channel, token string) error
    UpdateChannel - update a channel

func (sdk *MgxSDK) UpdateThing(thing Thing, token string) error
    UpdateThing - updates thing by ID

func (sdk *MgxSDK) Health() (magistrala.Health, error)
    Health - things service health check

Documentation

Overview

Package sdk contains Magistrala SDK.

Index

Constants

View Source
const (
	MaxLevel = uint64(5)
	MinLevel = uint64(1)
)
View Source
const (
	// CTJSON represents JSON content type.
	CTJSON ContentType = "application/json"

	// CTJSONSenML represents JSON SenML content type.
	CTJSONSenML ContentType = "application/senml+json"

	// CTBinary represents binary content type.
	CTBinary ContentType = "application/octet-stream"

	// EnabledStatus represents enable status for a client.
	EnabledStatus = "enabled"

	// DisabledStatus represents disabled status for a client.
	DisabledStatus = "disabled"

	BearerPrefix = "Bearer "

	ThingPrefix = "Thing "
)
View Source
const (
	PasswordResetEndpoint = "password"
)

Variables

View Source
var (
	// ErrFailedCreation indicates that entity creation failed.
	ErrFailedCreation = errors.New("failed to create entity in the db")

	// ErrFailedList indicates that entities list failed.
	ErrFailedList = errors.New("failed to list entities")

	// ErrFailedUpdate indicates that entity update failed.
	ErrFailedUpdate = errors.New("failed to update entity")

	// ErrFailedFetch indicates that fetching of entity data failed.
	ErrFailedFetch = errors.New("failed to fetch entity")

	// ErrFailedRemoval indicates that entity removal failed.
	ErrFailedRemoval = errors.New("failed to remove entity")

	// ErrFailedEnable indicates that client enable failed.
	ErrFailedEnable = errors.New("failed to enable client")

	// ErrFailedDisable indicates that client disable failed.
	ErrFailedDisable = errors.New("failed to disable client")

	ErrInvalidJWT = errors.New("invalid JWT")
)

Functions

This section is empty.

Types

type BootstrapConfig

type BootstrapConfig struct {
	Channels    interface{} `json:"channels,omitempty"`
	ExternalID  string      `json:"external_id,omitempty"`
	ExternalKey string      `json:"external_key,omitempty"`
	ThingID     string      `json:"thing_id,omitempty"`
	ThingKey    string      `json:"thing_key,omitempty"`
	Name        string      `json:"name,omitempty"`
	ClientCert  string      `json:"client_cert,omitempty"`
	ClientKey   string      `json:"client_key,omitempty"`
	CACert      string      `json:"ca_cert,omitempty"`
	Content     string      `json:"content,omitempty"`
	State       int         `json:"state,omitempty"`
}

BootstrapConfig represents Configuration entity. It wraps information about external entity as well as info about corresponding Magistrala entities. MGThing represents corresponding Magistrala Thing ID. MGKey is key of corresponding Magistrala Thing. MGChannels is a list of Magistrala Channels corresponding Magistrala Thing connects to.

func (*BootstrapConfig) UnmarshalJSON

func (ts *BootstrapConfig) UnmarshalJSON(data []byte) error

type BootstrapPage

type BootstrapPage struct {
	Configs []BootstrapConfig `json:"configs"`
	// contains filtered or unexported fields
}

bootstrapsPage contains list of bootstrap configs in a page with proper metadata.

type Cert

type Cert struct {
	ThingID    string    `json:"thing_id,omitempty"`
	CertSerial string    `json:"cert_serial,omitempty"`
	ClientKey  string    `json:"client_key,omitempty"`
	ClientCert string    `json:"client_cert,omitempty"`
	Expiration time.Time `json:"expiration,omitempty"`
}

Cert represents certs data.

type CertSerials

type CertSerials struct {
	Certs []Cert `json:"certs"`
	// contains filtered or unexported fields
}

type Channel

type Channel struct {
	ID          string     `json:"id,omitempty"`
	DomainID    string     `json:"domain_id,omitempty"`
	ParentID    string     `json:"parent_id,omitempty"`
	Name        string     `json:"name,omitempty"`
	Description string     `json:"description,omitempty"`
	Metadata    Metadata   `json:"metadata,omitempty"`
	Level       int        `json:"level,omitempty"`
	Path        string     `json:"path,omitempty"`
	Children    []*Channel `json:"children,omitempty"`
	CreatedAt   time.Time  `json:"created_at,omitempty"`
	UpdatedAt   time.Time  `json:"updated_at,omitempty"`
	Status      string     `json:"status,omitempty"`
	Permissions []string   `json:"permissions,omitempty"`
}

Channel represents magistrala channel.

type ChannelsPage

type ChannelsPage struct {
	Channels []Channel `json:"groups"`
	// contains filtered or unexported fields
}

ChannelsPage contains list of channels in a page with proper metadata.

type Config

type Config struct {
	BootstrapURL   string
	CertsURL       string
	HTTPAdapterURL string
	ReaderURL      string
	ThingsURL      string
	UsersURL       string
	DomainsURL     string
	InvitationsURL string
	HostURL        string

	MsgContentType  ContentType
	TLSVerification bool
}

Config contains sdk configuration parameters.

type Connection

type Connection struct {
	ThingID   string `json:"thing_id,omitempty"`
	ChannelID string `json:"channel_id,omitempty"`
}

Connection contains thing and channel ID that are connected.

type ContentType

type ContentType string

ContentType represents all possible content types.

type Credentials

type Credentials struct {
	Identity string `json:"identity,omitempty"` // username or generated login ID
	Secret   string `json:"secret,omitempty"`   // password or token
}

Credentials represent client credentials: it contains "identity" which can be a username, email, generated name; and "secret" which can be a password or access token.

type Domain

type Domain struct {
	ID          string    `json:"id,omitempty"`
	Name        string    `json:"name,omitempty"`
	Metadata    Metadata  `json:"metadata,omitempty"`
	Tags        []string  `json:"tags,omitempty"`
	Alias       string    `json:"alias,omitempty"`
	Status      string    `json:"status,omitempty"`
	Permission  string    `json:"permission,omitempty"`
	CreatedBy   string    `json:"created_by,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedBy   string    `json:"updated_by,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
	Permissions []string  `json:"permissions,omitempty"`
}

Domain represents magistrala domain.

type DomainsPage

type DomainsPage struct {
	Domains []Domain `json:"domains"`
	// contains filtered or unexported fields
}

type Group

type Group struct {
	ID          string    `json:"id,omitempty"`
	DomainID    string    `json:"domain_id,omitempty"`
	ParentID    string    `json:"parent_id,omitempty"`
	Name        string    `json:"name,omitempty"`
	Description string    `json:"description,omitempty"`
	Metadata    Metadata  `json:"metadata,omitempty"`
	Level       int       `json:"level,omitempty"`
	Path        string    `json:"path,omitempty"`
	Children    []*Group  `json:"children,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
	Status      string    `json:"status,omitempty"`
	Permissions []string  `json:"permissions,omitempty"`
}

Group represents the group of Clients. Indicates a level in tree hierarchy. Root node is level 1. Path in a tree consisting of group IDs Paths are unique per owner.

type GroupsPage

type GroupsPage struct {
	Groups []Group `json:"groups"`
	// contains filtered or unexported fields
}

type HealthInfo

type HealthInfo struct {
	// Status contains service status.
	Status string `json:"status"`

	// Version contains current service version.
	Version string `json:"version"`

	// Commit represents the git hash commit.
	Commit string `json:"commit"`

	// Description contains service description.
	Description string `json:"description"`

	// BuildTime contains service build time.
	BuildTime string `json:"build_time"`
}

HealthInfo contains version endpoint response.

type Invitation

type Invitation struct {
	InvitedBy   string    `json:"invited_by"`
	UserID      string    `json:"user_id"`
	DomainID    string    `json:"domain_id"`
	Token       string    `json:"token,omitempty"`
	Relation    string    `json:"relation,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
	ConfirmedAt time.Time `json:"confirmed_at,omitempty"`
	Resend      bool      `json:"resend,omitempty"`
}

type InvitationPage

type InvitationPage struct {
	Total       uint64       `json:"total"`
	Offset      uint64       `json:"offset"`
	Limit       uint64       `json:"limit"`
	Invitations []Invitation `json:"invitations"`
}

type Login

type Login struct {
	Identity string `json:"identity"`
	Secret   string `json:"secret"`
	DomainID string `json:"domain_id,omitempty"`
}

type MembersPage

type MembersPage struct {
	Members []User `json:"members"`
	// contains filtered or unexported fields
}

type MembershipsPage

type MembershipsPage struct {
	Memberships []Group `json:"memberships"`
	// contains filtered or unexported fields
}

MembershipsPage contains page related metadata as well as list of memberships that belong to this page.

type MessagePageMetadata

type MessagePageMetadata struct {
	PageMetadata
	Subtopic    string  `json:"subtopic,omitempty"`
	Publisher   string  `json:"publisher,omitempty"`
	Comparator  string  `json:"comparator,omitempty"`
	BoolValue   *bool   `json:"vb,omitempty"`
	StringValue string  `json:"vs,omitempty"`
	DataValue   string  `json:"vd,omitempty"`
	From        float64 `json:"from,omitempty"`
	To          float64 `json:"to,omitempty"`
	Aggregation string  `json:"aggregation,omitempty"`
	Interval    string  `json:"interval,omitempty"`
	Value       float64 `json:"value,omitempty"`
	Protocol    string  `json:"protocol,omitempty"`
}

type MessagesPage

type MessagesPage struct {
	Messages []senml.Message `json:"messages,omitempty"`
	// contains filtered or unexported fields
}

MessagesPage contains list of messages in a page with proper metadata.

type Metadata

type Metadata map[string]interface{}

type PageMetadata

type PageMetadata struct {
	Total           uint64   `json:"total"`
	Offset          uint64   `json:"offset"`
	Limit           uint64   `json:"limit"`
	Order           string   `json:"order,omitempty"`
	Direction       string   `json:"direction,omitempty"`
	Level           uint64   `json:"level,omitempty"`
	Identity        string   `json:"identity,omitempty"`
	Name            string   `json:"name,omitempty"`
	Type            string   `json:"type,omitempty"`
	Metadata        Metadata `json:"metadata,omitempty"`
	Status          string   `json:"status,omitempty"`
	Action          string   `json:"action,omitempty"`
	Subject         string   `json:"subject,omitempty"`
	Object          string   `json:"object,omitempty"`
	Permission      string   `json:"permission,omitempty"`
	Tag             string   `json:"tag,omitempty"`
	Owner           string   `json:"owner,omitempty"`
	SharedBy        string   `json:"shared_by,omitempty"`
	Visibility      string   `json:"visibility,omitempty"`
	OwnerID         string   `json:"owner_id,omitempty"`
	Topic           string   `json:"topic,omitempty"`
	Contact         string   `json:"contact,omitempty"`
	State           string   `json:"state,omitempty"`
	ListPermissions string   `json:"list_perms,omitempty"`
	InvitedBy       string   `json:"invited_by,omitempty"`
	UserID          string   `json:"user_id,omitempty"`
	DomainID        string   `json:"domain_id,omitempty"`
	Relation        string   `json:"relation,omitempty"`
}

type SDK

type SDK interface {
	// CreateUser registers magistrala user.
	//
	// example:
	//  user := sdk.User{
	//    Name:	 "John Doe",
	//    Credentials: sdk.Credentials{
	//      Identity: "john.doe@example",
	//      Secret:   "12345678",
	//    },
	//  }
	//  user, _ := sdk.CreateUser(user)
	//  fmt.Println(user)
	CreateUser(user User, token string) (User, errors.SDKError)

	// User returns user object by id.
	//
	// example:
	//  user, _ := sdk.User("userID", "token")
	//  fmt.Println(user)
	User(id, token string) (User, errors.SDKError)

	// Users returns list of users.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Name:   "John Doe",
	//	}
	//	users, _ := sdk.Users(pm, "token")
	//	fmt.Println(users)
	Users(pm PageMetadata, token string) (UsersPage, errors.SDKError)

	// UserProfile returns user logged in.
	//
	// example:
	//  user, _ := sdk.UserProfile("token")
	//  fmt.Println(user)
	UserProfile(token string) (User, errors.SDKError)

	// UpdateUser updates existing user.
	//
	// example:
	//  user := sdk.User{
	//    ID:   "userID",
	//    Name: "John Doe",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  user, _ := sdk.UpdateUser(user, "token")
	//  fmt.Println(user)
	UpdateUser(user User, token string) (User, errors.SDKError)

	// UpdateUserTags updates the user's tags.
	//
	// example:
	//  user := sdk.User{
	//    ID:   "userID",
	//    Tags: []string{"tag1", "tag2"},
	//  }
	//  user, _ := sdk.UpdateUserTags(user, "token")
	//  fmt.Println(user)
	UpdateUserTags(user User, token string) (User, errors.SDKError)

	// UpdateUserIdentity updates the user's identity
	//
	// example:
	//  user := sdk.User{
	//    ID:   "userID",
	//    Credentials: sdk.Credentials{
	//      Identity: "john.doe@example",
	//    },
	//  }
	//  user, _ := sdk.UpdateUserIdentity(user, "token")
	//  fmt.Println(user)
	UpdateUserIdentity(user User, token string) (User, errors.SDKError)

	// UpdateUserRole updates the user's role.
	//
	// example:
	//  user := sdk.User{
	//    ID:   "userID",
	//    Role: "role",
	//  }
	//  user, _ := sdk.UpdateUserRole(user, "token")
	//  fmt.Println(user)
	UpdateUserRole(user User, token string) (User, errors.SDKError)

	// ResetPasswordRequest sends a password request email to a user.
	//
	// example:
	//  err := sdk.ResetPasswordRequest("example@email.com")
	//  fmt.Println(err)
	ResetPasswordRequest(email string) errors.SDKError

	// ResetPassword changes a user's password to the one passed in the argument.
	//
	// example:
	//  err := sdk.ResetPassword("password","password","token")
	//  fmt.Println(err)
	ResetPassword(password, confPass, token string) errors.SDKError

	// UpdatePassword updates user password.
	//
	// example:
	//  user, _ := sdk.UpdatePassword("oldPass", "newPass", "token")
	//  fmt.Println(user)
	UpdatePassword(oldPass, newPass, token string) (User, errors.SDKError)

	// EnableUser changes the status of the user to enabled.
	//
	// example:
	//  user, _ := sdk.EnableUser("userID", "token")
	//  fmt.Println(user)
	EnableUser(id, token string) (User, errors.SDKError)

	// DisableUser changes the status of the user to disabled.
	//
	// example:
	//  user, _ := sdk.DisableUser("userID", "token")
	//  fmt.Println(user)
	DisableUser(id, token string) (User, errors.SDKError)

	// CreateToken receives credentials and returns user token.
	//
	// example:
	//  lt := sdk.Login{
	//      Identity: "john.doe@example",
	//      Secret:   "12345678",
	//  }
	//  token, _ := sdk.CreateToken(lt)
	//  fmt.Println(token)
	CreateToken(lt Login) (Token, errors.SDKError)

	// RefreshToken receives credentials and returns user token.
	//
	// example:
	//  lt := sdk.Login{
	//      DomainID:   "domain_id",
	//  }
	// example:
	//  token, _ := sdk.RefreshToken(lt,"refresh_token")
	//  fmt.Println(token)
	RefreshToken(lt Login, token string) (Token, errors.SDKError)

	// ListUserChannels list all channels belongs a particular user id.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit", // available Options:  "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
	//	}
	//  channels, _ := sdk.ListUserChannels("user_id_1", pm, "token")
	//  fmt.Println(channels)
	ListUserChannels(userID string, pm PageMetadata, token string) (ChannelsPage, errors.SDKError)

	// ListUserGroups list all groups belongs a particular user id.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit", // available Options:  "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
	//	}
	//  groups, _ := sdk.ListUserGroups("user_id_1", pm, "token")
	//  fmt.Println(channels)
	ListUserGroups(userID string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)

	// ListUserThings list all things belongs a particular user id.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit", // available Options:  "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
	//	}
	//  things, _ := sdk.ListUserThings("user_id_1", pm, "token")
	//  fmt.Println(things)
	ListUserThings(userID string, pm PageMetadata, token string) (ThingsPage, errors.SDKError)

	// CreateThing registers new thing and returns its id.
	//
	// example:
	//  thing := sdk.Thing{
	//    Name: "My Thing",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  thing, _ := sdk.CreateThing(thing, "token")
	//  fmt.Println(thing)
	CreateThing(thing Thing, token string) (Thing, errors.SDKError)

	// CreateThings registers new things and returns their ids.
	//
	// example:
	//  things := []sdk.Thing{
	//    {
	//      Name: "My Thing 1",
	//      Metadata: sdk.Metadata{
	//        "key": "value",
	//      },
	//    },
	//    {
	//      Name: "My Thing 2",
	//      Metadata: sdk.Metadata{
	//        "key": "value",
	//      },
	//    },
	//  }
	//  things, _ := sdk.CreateThings(things, "token")
	//  fmt.Println(things)
	CreateThings(things []Thing, token string) ([]Thing, errors.SDKError)

	// Filters things and returns a page result.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Thing",
	//  }
	//  things, _ := sdk.Things(pm, "token")
	//  fmt.Println(things)
	Things(pm PageMetadata, token string) (ThingsPage, errors.SDKError)

	// ThingsByChannel returns page of things that are connected to specified channel.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Thing",
	//  }
	//  things, _ := sdk.ThingsByChannel("channelID", pm, "token")
	//  fmt.Println(things)
	ThingsByChannel(chanID string, pm PageMetadata, token string) (ThingsPage, errors.SDKError)

	// Thing returns thing object by id.
	//
	// example:
	//  thing, _ := sdk.Thing("thingID", "token")
	//  fmt.Println(thing)
	Thing(id, token string) (Thing, errors.SDKError)

	// ThingPermissions returns user permissions on the thing id.
	//
	// example:
	//  thing, _ := sdk.Thing("thingID", "token")
	//  fmt.Println(thing)
	ThingPermissions(id, token string) (Thing, errors.SDKError)

	// UpdateThing updates existing thing.
	//
	// example:
	//  thing := sdk.Thing{
	//    ID:   "thingID",
	//    Name: "My Thing",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  thing, _ := sdk.UpdateThing(thing, "token")
	//  fmt.Println(thing)
	UpdateThing(thing Thing, token string) (Thing, errors.SDKError)

	// UpdateThingTags updates the client's tags.
	//
	// example:
	//  thing := sdk.Thing{
	//    ID:   "thingID",
	//    Tags: []string{"tag1", "tag2"},
	//  }
	//  thing, _ := sdk.UpdateThingTags(thing, "token")
	//  fmt.Println(thing)
	UpdateThingTags(thing Thing, token string) (Thing, errors.SDKError)

	// UpdateThingSecret updates the client's secret
	//
	// example:
	//  thing, err := sdk.UpdateThingSecret("thingID", "newSecret", "token")
	//  fmt.Println(thing)
	UpdateThingSecret(id, secret, token string) (Thing, errors.SDKError)

	// EnableThing changes client status to enabled.
	//
	// example:
	//  thing, _ := sdk.EnableThing("thingID", "token")
	//  fmt.Println(thing)
	EnableThing(id, token string) (Thing, errors.SDKError)

	// DisableThing changes client status to disabled - soft delete.
	//
	// example:
	//  thing, _ := sdk.DisableThing("thingID", "token")
	//  fmt.Println(thing)
	DisableThing(id, token string) (Thing, errors.SDKError)

	// IdentifyThing validates thing's key and returns its ID
	//
	// example:
	//  id, _ := sdk.IdentifyThing("thingKey")
	//  fmt.Println(id)
	IdentifyThing(key string) (string, errors.SDKError)

	// ShareThing shares thing with other users.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	//  err := sdk.ShareThing("thing_id", req, "token")
	//  fmt.Println(err)
	ShareThing(thingID string, req UsersRelationRequest, token string) errors.SDKError

	// UnshareThing unshare a thing with other users.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	//  err := sdk.UnshareThing("thing_id", req, "token")
	//  fmt.Println(err)
	UnshareThing(thingID string, req UsersRelationRequest, token string) errors.SDKError

	// ListThingUsers all users in a thing.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit", // available Options:  "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
	//	}
	//  users, _ := sdk.ListThingUsers("thing_id", pm, "token")
	//  fmt.Println(users)
	ListThingUsers(thingID string, pm PageMetadata, token string) (UsersPage, errors.SDKError)

	// DeleteThing deletes a thing with the given id.
	//
	// example:
	//  err := sdk.DeleteThing("thingID", "token")
	//  fmt.Println(err)
	DeleteThing(id, token string) errors.SDKError

	// CreateGroup creates new group and returns its id.
	//
	// example:
	//  group := sdk.Group{
	//    Name: "My Group",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  group, _ := sdk.CreateGroup(group, "token")
	//  fmt.Println(group)
	CreateGroup(group Group, token string) (Group, errors.SDKError)

	// Groups returns page of groups.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Group",
	//  }
	//  groups, _ := sdk.Groups(pm, "token")
	//  fmt.Println(groups)
	Groups(pm PageMetadata, token string) (GroupsPage, errors.SDKError)

	// Parents returns page of users groups.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Group",
	//  }
	//  groups, _ := sdk.Parents("groupID", pm, "token")
	//  fmt.Println(groups)
	Parents(id string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)

	// Children returns page of users groups.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Group",
	//  }
	//  groups, _ := sdk.Children("groupID", pm, "token")
	//  fmt.Println(groups)
	Children(id string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)

	// Group returns users group object by id.
	//
	// example:
	//  group, _ := sdk.Group("groupID", "token")
	//  fmt.Println(group)
	Group(id, token string) (Group, errors.SDKError)

	// GroupPermissions returns user permissions by group ID.
	//
	// example:
	//  group, _ := sdk.Group("groupID", "token")
	//  fmt.Println(group)
	GroupPermissions(id, token string) (Group, errors.SDKError)

	// UpdateGroup updates existing group.
	//
	// example:
	//  group := sdk.Group{
	//    ID:   "groupID",
	//    Name: "My Group",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  group, _ := sdk.UpdateGroup(group, "token")
	//  fmt.Println(group)
	UpdateGroup(group Group, token string) (Group, errors.SDKError)

	// EnableGroup changes group status to enabled.
	//
	// example:
	//  group, _ := sdk.EnableGroup("groupID", "token")
	//  fmt.Println(group)
	EnableGroup(id, token string) (Group, errors.SDKError)

	// DisableGroup changes group status to disabled - soft delete.
	//
	// example:
	//  group, _ := sdk.DisableGroup("groupID", "token")
	//  fmt.Println(group)
	DisableGroup(id, token string) (Group, errors.SDKError)

	// AddUserToGroup add user to a group.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	// err := sdk.AddUserToGroup("groupID",req, "token")
	// fmt.Println(err)
	AddUserToGroup(groupID string, req UsersRelationRequest, token string) errors.SDKError

	// RemoveUserFromGroup remove user from a group.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	// err := sdk.RemoveUserFromGroup("groupID",req, "token")
	// fmt.Println(err)
	RemoveUserFromGroup(groupID string, req UsersRelationRequest, token string) errors.SDKError

	// ListGroupUsers list all users in the group id .
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit", // available Options:  "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
	//	}
	//  groups, _ := sdk.ListGroupUsers("groupID", pm, "token")
	//  fmt.Println(groups)
	ListGroupUsers(groupID string, pm PageMetadata, token string) (UsersPage, errors.SDKError)

	// ListGroupChannels list all channels in the group id .
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit", // available Options:  "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
	//	}
	//  groups, _ := sdk.ListGroupChannels("groupID", pm, "token")
	//  fmt.Println(groups)
	ListGroupChannels(groupID string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)

	// DeleteGroup delete given group id.
	//
	// example:
	//  err := sdk.DeleteGroup("groupID", "token")
	//  fmt.Println(err)
	DeleteGroup(id, token string) errors.SDKError

	// CreateChannel creates new channel and returns its id.
	//
	// example:
	//  channel := sdk.Channel{
	//    Name: "My Channel",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  channel, _ := sdk.CreateChannel(channel, "token")
	//  fmt.Println(channel)
	CreateChannel(channel Channel, token string) (Channel, errors.SDKError)

	// CreateChannels registers new channels and returns their ids.
	//
	// example:
	//  channels := []sdk.Channel{
	//    {
	//      Name: "My Channel 1",
	//      Metadata: sdk.Metadata{
	//        "key": "value",
	//      },
	//    },
	//    {
	//      Name: "My Channel 2",
	//      Metadata: sdk.Metadata{
	//        "key": "value",
	//      },
	//    },
	//  }
	//  channels, _ := sdk.CreateChannels(channels, "token")
	//  fmt.Println(channels)
	CreateChannels(channels []Channel, token string) ([]Channel, errors.SDKError)

	// Channels returns page of channels.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Channel",
	//  }
	//  channels, _ := sdk.Channels(pm, "token")
	//  fmt.Println(channels)
	Channels(pm PageMetadata, token string) (ChannelsPage, errors.SDKError)

	// ChannelsByThing returns page of channels that are connected to specified thing.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Channel",
	//  }
	//  channels, _ := sdk.ChannelsByThing("thingID", pm, "token")
	//  fmt.Println(channels)
	ChannelsByThing(thingID string, pm PageMetadata, token string) (ChannelsPage, errors.SDKError)

	// Channel returns channel data by id.
	//
	// example:
	//  channel, _ := sdk.Channel("channelID", "token")
	//  fmt.Println(channel)
	Channel(id, token string) (Channel, errors.SDKError)

	// ChannelPermissions returns user permissions on the channel ID.
	//
	// example:
	//  channel, _ := sdk.Channel("channelID", "token")
	//  fmt.Println(channel)
	ChannelPermissions(id, token string) (Channel, errors.SDKError)

	// UpdateChannel updates existing channel.
	//
	// example:
	//  channel := sdk.Channel{
	//    ID:   "channelID",
	//    Name: "My Channel",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  channel, _ := sdk.UpdateChannel(channel, "token")
	//  fmt.Println(channel)
	UpdateChannel(channel Channel, token string) (Channel, errors.SDKError)

	// EnableChannel changes channel status to enabled.
	//
	// example:
	//  channel, _ := sdk.EnableChannel("channelID", "token")
	//  fmt.Println(channel)
	EnableChannel(id, token string) (Channel, errors.SDKError)

	// DisableChannel changes channel status to disabled - soft delete.
	//
	// example:
	//  channel, _ := sdk.DisableChannel("channelID", "token")
	//  fmt.Println(channel)
	DisableChannel(id, token string) (Channel, errors.SDKError)

	// AddUserToChannel add user to a channel.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
	// 		UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	// err := sdk.AddUserToChannel("channel_id", req, "token")
	// fmt.Println(err)
	AddUserToChannel(channelID string, req UsersRelationRequest, token string) errors.SDKError

	// RemoveUserFromChannel remove user from a group.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	// err := sdk.RemoveUserFromChannel("channel_id", req, "token")
	// fmt.Println(err)
	RemoveUserFromChannel(channelID string, req UsersRelationRequest, token string) errors.SDKError

	// ListChannelUsers list all users in a channel .
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit",  // available Options:  "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
	//	}
	//  users, _ := sdk.ListChannelUsers("channel_id", pm, "token")
	//  fmt.Println(users)
	ListChannelUsers(channelID string, pm PageMetadata, token string) (UsersPage, errors.SDKError)

	// AddUserGroupToChannel add user group to a channel.
	//
	// example:
	// req := sdk.UserGroupsRequest{
	//  	GroupsIDs: ["group_id_1", "group_id_2", "group_id_3"]
	// }
	// err := sdk.AddUserGroupToChannel("channel_id",req, "token")
	// fmt.Println(err)
	AddUserGroupToChannel(channelID string, req UserGroupsRequest, token string) errors.SDKError

	// RemoveUserGroupFromChannel remove user group from a channel.
	//
	// example:
	// req := sdk.UserGroupsRequest{
	//  	GroupsIDs: ["group_id_1", "group_id_2", "group_id_3"]
	// }
	// err := sdk.RemoveUserGroupFromChannel("channel_id",req, "token")
	// fmt.Println(err)
	RemoveUserGroupFromChannel(channelID string, req UserGroupsRequest, token string) errors.SDKError

	// ListChannelUserGroups list all user groups in a channel.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "view",
	//	}
	//  groups, _ := sdk.ListChannelUserGroups("channel_id_1", pm, "token")
	//  fmt.Println(groups)
	ListChannelUserGroups(channelID string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)

	// DeleteChannel delete given group id.
	//
	// example:
	//  err := sdk.DeleteChannel("channelID", "token")
	//  fmt.Println(err)
	DeleteChannel(id, token string) errors.SDKError

	// Connect bulk connects things to channels specified by id.
	//
	// example:
	//  conns := sdk.Connection{
	//    ChannelID: "channel_id_1",
	//    ThingID:   "thing_id_1",
	//  }
	//  err := sdk.Connect(conns, "token")
	//  fmt.Println(err)
	Connect(conns Connection, token string) errors.SDKError

	// Disconnect
	//
	// example:
	//  conns := sdk.Connection{
	//    ChannelID: "channel_id_1",
	//    ThingID:   "thing_id_1",
	//  }
	//  err := sdk.Disconnect(conns, "token")
	//  fmt.Println(err)
	Disconnect(connIDs Connection, token string) errors.SDKError

	// ConnectThing connects thing to specified channel by id.
	//
	// The `ConnectThing` method calls the `CreateThingPolicy` method under the hood.
	//
	// example:
	//  err := sdk.ConnectThing("thingID", "channelID", "token")
	//  fmt.Println(err)
	ConnectThing(thingID, chanID, token string) errors.SDKError

	// DisconnectThing disconnect thing from specified channel by id.
	//
	// The `DisconnectThing` method calls the `DeleteThingPolicy` method under the hood.
	//
	// example:
	//  err := sdk.DisconnectThing("thingID", "channelID", "token")
	//  fmt.Println(err)
	DisconnectThing(thingID, chanID, token string) errors.SDKError

	// SendMessage send message to specified channel.
	//
	// example:
	//  msg := '[{"bn":"some-base-name:","bt":1.276020076001e+09, "bu":"A","bver":5, "n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2}, {"n":"current","t":-4,"v":1.3}]'
	//  err := sdk.SendMessage("channelID", msg, "thingSecret")
	//  fmt.Println(err)
	SendMessage(chanID, msg, key string) errors.SDKError

	// ReadMessages read messages of specified channel.
	//
	// example:
	//  pm := sdk.MessagePageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//  }
	//  msgs, _ := sdk.ReadMessages(pm,"channelID", "token")
	//  fmt.Println(msgs)
	ReadMessages(pm MessagePageMetadata, chanID, token string) (MessagesPage, errors.SDKError)

	// SetContentType sets message content type.
	//
	// example:
	//  err := sdk.SetContentType("application/json")
	//  fmt.Println(err)
	SetContentType(ct ContentType) errors.SDKError

	// Health returns service health check.
	//
	// example:
	//  health, _ := sdk.Health("service")
	//  fmt.Println(health)
	Health(service string) (HealthInfo, errors.SDKError)

	// AddBootstrap add bootstrap configuration
	//
	// example:
	//  cfg := sdk.BootstrapConfig{
	//    ThingID: "thingID",
	//    Name: "bootstrap",
	//    ExternalID: "externalID",
	//    ExternalKey: "externalKey",
	//    Channels: []string{"channel1", "channel2"},
	//  }
	//  id, _ := sdk.AddBootstrap(cfg, "token")
	//  fmt.Println(id)
	AddBootstrap(cfg BootstrapConfig, token string) (string, errors.SDKError)

	// View returns Thing Config with given ID belonging to the user identified by the given token.
	//
	// example:
	//  bootstrap, _ := sdk.ViewBootstrap("id", "token")
	//  fmt.Println(bootstrap)
	ViewBootstrap(id, token string) (BootstrapConfig, errors.SDKError)

	// Update updates editable fields of the provided Config.
	//
	// example:
	//  cfg := sdk.BootstrapConfig{
	//    ThingID: "thingID",
	//    Name: "bootstrap",
	//    ExternalID: "externalID",
	//    ExternalKey: "externalKey",
	//    Channels: []string{"channel1", "channel2"},
	//  }
	//  err := sdk.UpdateBootstrap(cfg, "token")
	//  fmt.Println(err)
	UpdateBootstrap(cfg BootstrapConfig, token string) errors.SDKError

	// Update bootstrap config certificates.
	//
	// example:
	//  err := sdk.UpdateBootstrapCerts("id", "clientCert", "clientKey", "ca", "token")
	//  fmt.Println(err)
	UpdateBootstrapCerts(id string, clientCert, clientKey, ca string, token string) (BootstrapConfig, errors.SDKError)

	// UpdateBootstrapConnection updates connections performs update of the channel list corresponding Thing is connected to.
	//
	// example:
	//  err := sdk.UpdateBootstrapConnection("id", []string{"channel1", "channel2"}, "token")
	//  fmt.Println(err)
	UpdateBootstrapConnection(id string, channels []string, token string) errors.SDKError

	// Remove removes Config with specified token that belongs to the user identified by the given token.
	//
	// example:
	//  err := sdk.RemoveBootstrap("id", "token")
	//  fmt.Println(err)
	RemoveBootstrap(id, token string) errors.SDKError

	// Bootstrap returns Config to the Thing with provided external ID using external key.
	//
	// example:
	//  bootstrap, _ := sdk.Bootstrap("externalID", "externalKey")
	//  fmt.Println(bootstrap)
	Bootstrap(externalID, externalKey string) (BootstrapConfig, errors.SDKError)

	// BootstrapSecure retrieves a configuration with given external ID and encrypted external key.
	//
	// example:
	//  bootstrap, _ := sdk.BootstrapSecure("externalID", "externalKey", "cryptoKey")
	//  fmt.Println(bootstrap)
	BootstrapSecure(externalID, externalKey, cryptoKey string) (BootstrapConfig, errors.SDKError)

	// Bootstraps retrieves a list of managed configs.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//  }
	//  bootstraps, _ := sdk.Bootstraps(pm, "token")
	//  fmt.Println(bootstraps)
	Bootstraps(pm PageMetadata, token string) (BootstrapPage, errors.SDKError)

	// Whitelist updates Thing state Config with given ID belonging to the user identified by the given token.
	//
	// example:
	//  cfg := sdk.BootstrapConfig{
	//    ThingID: "thingID",
	//    Name: "bootstrap",
	//    ExternalID: "externalID",
	//    ExternalKey: "externalKey",
	//    Channels: []string{"channel1", "channel2"},
	//  }
	//  err := sdk.Whitelist(cfg, "token")
	//  fmt.Println(err)
	Whitelist(cfg BootstrapConfig, token string) errors.SDKError

	// IssueCert issues a certificate for a thing required for mTLS.
	//
	// example:
	//  cert, _ := sdk.IssueCert("thingID", "valid", "token")
	//  fmt.Println(cert)
	IssueCert(thingID, valid, token string) (Cert, errors.SDKError)

	// ViewCert returns a certificate given certificate ID
	//
	// example:
	//  cert, _ := sdk.ViewCert("certID", "token")
	//  fmt.Println(cert)
	ViewCert(certID, token string) (Cert, errors.SDKError)

	// ViewCertByThing retrieves a list of certificates' serial IDs for a given thing ID.
	//
	// example:
	//  cserial, _ := sdk.ViewCertByThing("thingID", "token")
	//  fmt.Println(cserial)
	ViewCertByThing(thingID, token string) (CertSerials, errors.SDKError)

	// RevokeCert revokes certificate for thing with thingID
	//
	// example:
	//  tm, _ := sdk.RevokeCert("thingID", "token")
	//  fmt.Println(tm)
	RevokeCert(thingID, token string) (time.Time, errors.SDKError)

	// CreateSubscription creates a new subscription
	//
	// example:
	//  subscription, _ := sdk.CreateSubscription("topic", "contact", "token")
	//  fmt.Println(subscription)
	CreateSubscription(topic, contact, token string) (string, errors.SDKError)

	// ListSubscriptions list subscriptions given list parameters.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//  }
	//  subscriptions, _ := sdk.ListSubscriptions(pm, "token")
	//  fmt.Println(subscriptions)
	ListSubscriptions(pm PageMetadata, token string) (SubscriptionPage, errors.SDKError)

	// ViewSubscription retrieves a subscription with the provided id.
	//
	// example:
	//  subscription, _ := sdk.ViewSubscription("id", "token")
	//  fmt.Println(subscription)
	ViewSubscription(id, token string) (Subscription, errors.SDKError)

	// DeleteSubscription removes a subscription with the provided id.
	//
	// example:
	//  err := sdk.DeleteSubscription("id", "token")
	//  fmt.Println(err)
	DeleteSubscription(id, token string) errors.SDKError

	// CreateDomain creates new domain and returns its details.
	//
	// example:
	//  domain := sdk.Domain{
	//    Name: "My Domain",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  domain, _ := sdk.CreateDomain(group, "token")
	//  fmt.Println(domain)
	CreateDomain(d Domain, token string) (Domain, errors.SDKError)

	// Domain retrieve domain information of given domain ID .
	//
	// example:
	//  domain, _ := sdk.Domain("domainID", "token")
	//  fmt.Println(domain)
	Domain(domainID, token string) (Domain, errors.SDKError)

	// DomainPermissions retrieve user permissions on the given domain ID .
	//
	// example:
	//  permissions, _ := sdk.DomainPermissions("domainID", "token")
	//  fmt.Println(permissions)
	DomainPermissions(domainID, token string) (Domain, errors.SDKError)

	// UpdateDomain updates details of the given domain ID.
	//
	// example:
	//  domain := sdk.Domain{
	//    ID : "domainID"
	//    Name: "New Domain Name",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  domain, _ := sdk.UpdateDomain(domain, "token")
	//  fmt.Println(domain)
	UpdateDomain(d Domain, token string) (Domain, errors.SDKError)

	// Domains returns list of domain for the given filters.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Domain",
	//    Permission : "view"
	//  }
	//  domains, _ := sdk.Domains(pm, "token")
	//  fmt.Println(domains)
	Domains(pm PageMetadata, token string) (DomainsPage, errors.SDKError)

	// ListDomainUsers returns list of users for the given domain ID and filters.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Permission : "view"
	//  }
	//  users, _ := sdk.ListDomainUsers("domainID", pm, "token")
	//  fmt.Println(users)
	ListDomainUsers(domainID string, pm PageMetadata, token string) (UsersPage, errors.SDKError)

	// ListUserDomains returns list of domains for the given user ID and filters.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Permission : "view"
	//  }
	//  domains, _ := sdk.ListUserDomains("userID", pm, "token")
	//  fmt.Println(domains)
	ListUserDomains(userID string, pm PageMetadata, token string) (DomainsPage, errors.SDKError)

	// EnableDomain changes the status of the domain to enabled.
	//
	// example:
	//  err := sdk.EnableDomain("domainID", "token")
	//  fmt.Println(err)
	EnableDomain(domainID, token string) errors.SDKError

	// DisableDomain changes the status of the domain to disabled.
	//
	// example:
	//  err := sdk.DisableDomain("domainID", "token")
	//  fmt.Println(err)
	DisableDomain(domainID, token string) errors.SDKError

	// AddUserToDomain adds a user to a domain.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer",  "member"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	// err := sdk.AddUserToDomain("domainID", req, "token")
	// fmt.Println(err)
	AddUserToDomain(domainID string, req UsersRelationRequest, token string) errors.SDKError

	// RemoveUserFromDomain removes a user from a domain.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "viewer", // available options: "owner", "admin", "editor", "viewer" , "member"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	// err := sdk.RemoveUserFromDomain("domainID", req, "token")
	// fmt.Println(err)
	RemoveUserFromDomain(domainID string, req UsersRelationRequest, token string) errors.SDKError

	// SendInvitation sends an invitation to the email address associated with the given user.
	//
	// For example:
	//  invitation := sdk.Invitation{
	//    DomainID: "domainID",
	//    UserID:   "userID",
	//    Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
	//  }
	//  err := sdk.SendInvitation(invitation, "token")
	//  fmt.Println(err)
	SendInvitation(invitation Invitation, token string) (err error)

	// Invitation returns an invitation.
	//
	// For example:
	//  invitation, _ := sdk.Invitation("userID", "domainID", "token")
	//  fmt.Println(invitation)
	Invitation(userID, domainID, token string) (invitation Invitation, err error)

	// Invitations returns a list of invitations.
	//
	// For example:
	//  invitations, _ := sdk.Invitations(PageMetadata{Offset: 0, Limit: 10, Domain: "domainID"}, "token")
	//  fmt.Println(invitations)
	Invitations(pm PageMetadata, token string) (invitations InvitationPage, err error)

	// AcceptInvitation accepts an invitation by adding the user to the domain that they were invited to.
	//
	// For example:
	//  err := sdk.AcceptInvitation("domainID", "token")
	//  fmt.Println(err)
	AcceptInvitation(domainID, token string) (err error)

	// DeleteInvitation deletes an invitation.
	//
	// For example:
	//  err := sdk.DeleteInvitation("userID", "domainID", "token")
	//  fmt.Println(err)
	DeleteInvitation(userID, domainID, token string) (err error)
}

SDK contains Magistrala API.

func NewSDK

func NewSDK(conf Config) SDK

NewSDK returns new magistrala SDK instance.

type Subscription

type Subscription struct {
	ID      string `json:"id,omitempty"`
	OwnerID string `json:"owner_id,omitempty"`
	Topic   string `json:"topic,omitempty"`
	Contact string `json:"contact,omitempty"`
}

type SubscriptionPage

type SubscriptionPage struct {
	Subscriptions []Subscription `json:"subscriptions"`
	// contains filtered or unexported fields
}

type Thing

type Thing struct {
	ID          string                 `json:"id,omitempty"`
	Name        string                 `json:"name,omitempty"`
	Credentials Credentials            `json:"credentials"`
	Tags        []string               `json:"tags,omitempty"`
	DomainID    string                 `json:"domain_id,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
	CreatedAt   time.Time              `json:"created_at,omitempty"`
	UpdatedAt   time.Time              `json:"updated_at,omitempty"`
	Status      string                 `json:"status,omitempty"`
	Permissions []string               `json:"permissions,omitempty"`
}

Thing represents magistrala thing.

type ThingsPage

type ThingsPage struct {
	Things []Thing `json:"things"`
	// contains filtered or unexported fields
}

ThingsPage contains list of things in a page with proper metadata.

type Token

type Token struct {
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	AccessType   string `json:"access_type,omitempty"`
}

Token is used for authentication purposes. It contains AccessToken, RefreshToken and AccessExpiry.

type User

type User struct {
	ID          string      `json:"id"`
	Name        string      `json:"name,omitempty"`
	Credentials Credentials `json:"credentials"`
	Tags        []string    `json:"tags,omitempty"`
	Domain      string      `json:"-"` // ignoring Domain Field, since it will be always empty for users
	Metadata    Metadata    `json:"metadata,omitempty"`
	CreatedAt   time.Time   `json:"created_at,omitempty"`
	UpdatedAt   time.Time   `json:"updated_at,omitempty"`
	Status      string      `json:"status,omitempty"`
	Role        string      `json:"role,omitempty"`
}

User represents magistrala user its credentials.

type UserGroupsRequest

type UserGroupsRequest struct {
	UserGroupIDs []string `json:"group_ids"`
}

type UserPasswordReq

type UserPasswordReq struct {
	OldPassword string `json:"old_password,omitempty"`
	Password    string `json:"password,omitempty"`
}

UserPasswordReq contains old and new passwords.

type UsersPage

type UsersPage struct {
	Users []User `json:"users"`
	// contains filtered or unexported fields
}

type UsersRelationRequest

type UsersRelationRequest struct {
	Relation string   `json:"relation"`
	UserIDs  []string `json:"user_ids"`
}

Jump to

Keyboard shortcuts

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