sdk

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

SuperMQ Go SDK

Go SDK, a Go driver for SuperMQ HTTP API.

Does both system administration (provisioning) and messaging.

Installation

Import "github.com/absmach/supermq/sdk" in your Go package.

import "github.com/absmach/supermq/pkg/sdk"

You can check SuperMQ CLI as an example of SDK usage.

Then call SDK Go functions to interact with the system.

API Reference

FUNCTIONS

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

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

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

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

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

func (sdk *MgxSDK) CreateClient(data, token string) (string, error)
    CreateClient - creates new client and generates client 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) DeleteClient(id, token string) error
    DeleteClient - removes client

func (sdk *MgxSDK) DisconnectClient(clientID, chanID, token string) error
    DisconnectClient - connect client to a channel

func (sdk *MgxSDK) SendMessage(chanID, msg, token string) error
    SendMessage - send message on SuperMQ 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) Client(id, token string) (Client, error)
    Client - gets client by ID

func (sdk *MgxSDK) Clients(token string) ([]Client, error)
    Clients - gets all clients

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

func (sdk *MgxSDK) UpdateClient(client Client, token string) error
    UpdateClient - updates client by ID

func (sdk *MgxSDK) Health() (supermq.Health, error)
    Health - clients service health check

Documentation

Overview

Package sdk contains SuperMQ 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 "

	ClientPrefix = "Client "
)
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"`
	ClientID     string      `json:"client_id,omitempty"`
	ClientSecret string      `json:"client_secret,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 SuperMQ entities. MGClient represents corresponding SuperMQ Client ID. MGKey is key of corresponding SuperMQ Client. MGChannels is a list of SuperMQ Channels corresponding SuperMQ Client connects to.

func (*BootstrapConfig) UnmarshalJSON

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

type BootstrapPage

type BootstrapPage struct {
	Configs []BootstrapConfig `json:"configs"`
	PageRes
}

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

type Cert

type Cert struct {
	SerialNumber string    `json:"serial_number,omitempty"`
	Certificate  string    `json:"certificate,omitempty"`
	Key          string    `json:"key,omitempty"`
	Revoked      bool      `json:"revoked,omitempty"`
	ExpiryTime   time.Time `json:"expiry_time,omitempty"`
	ClientID     string    `json:"client_id,omitempty"`
}

Cert represents certs data.

type CertSerials

type CertSerials struct {
	Certs []Cert `json:"certs"`
	PageRes
}

type Channel

type Channel struct {
	ID          string     `json:"id,omitempty"`
	DomainID    string     `json:"domain_id,omitempty"`
	ParentGroup string     `json:"parent_group_id,omitempty"`
	Name        string     `json:"name,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 supermq channel.

type ChannelsPage

type ChannelsPage struct {
	Channels []Channel `json:"channels"`
	PageRes
}

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

type Client

type Client struct {
	ID          string                 `json:"id,omitempty"`
	Name        string                 `json:"name,omitempty"`
	Credentials ClientCredentials      `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"`
}

Client represents supermq client.

type ClientCredentials

type ClientCredentials struct {
	Identity string `json:"identity,omitempty"`
	Secret   string `json:"secret,omitempty"`
}

type ClientsPage

type ClientsPage struct {
	Clients []Client `json:"clients"`
	PageRes
}

ClientsPage contains list of clients in a page with proper metadata.

type Config

type Config struct {
	BootstrapURL   string
	CertsURL       string
	HTTPAdapterURL string
	ReaderURL      string
	ClientsURL     string
	UsersURL       string
	GroupsURL      string
	ChannelsURL    string
	DomainsURL     string
	InvitationsURL string
	JournalURL     string
	HostURL        string

	MsgContentType  ContentType
	TLSVerification bool
	CurlFlag        bool
}

Config contains sdk configuration parameters.

type Connection

type Connection struct {
	ClientIDs  []string `json:"client_ids,omitempty"`
	ChannelIDs []string `json:"channel_ids,omitempty"`
	Types      []string `json:"types,omitempty"`
}

Connection contains clients and channel IDs that are connected.

type ContentType

type ContentType string

ContentType represents all possible content types.

type Credentials

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

Credentials represent client credentials: it contains "username" which can be a username, 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 supermq domain.

type DomainsPage

type DomainsPage struct {
	Domains []Domain `json:"domains"`
	PageRes
}

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"`
	PageRes
}

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"`
	RejectedAt  time.Time `json:"rejected_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 Journal

type Journal struct {
	ID         string    `json:"id,omitempty"`
	Operation  string    `json:"operation,omitempty"`
	OccurredAt time.Time `json:"occurred_at,omitempty"`
	Attributes Metadata  `json:"attributes,omitempty"`
	Metadata   Metadata  `json:"metadata,omitempty"`
}

type JournalsPage

type JournalsPage struct {
	Total    uint64    `json:"total"`
	Offset   uint64    `json:"offset"`
	Limit    uint64    `json:"limit"`
	Journals []Journal `json:"journals"`
}

type Login

type Login struct {
	Identity string `json:"identity"`
	Secret   string `json:"secret"`
}

type MembersPage

type MembersPage struct {
	Members []User `json:"members"`
	PageRes
}

type MembershipsPage

type MembershipsPage struct {
	PageRes
	Memberships []Group `json:"memberships"`
}

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"`
	PageRes
}

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"`
	Email           string   `json:"email,omitempty"`
	Username        string   `json:"username,omitempty"`
	LastName        string   `json:"last_name,omitempty"`
	FirstName       string   `json:"first_name,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"`
	Operation       string   `json:"operation,omitempty"`
	From            int64    `json:"from,omitempty"`
	To              int64    `json:"to,omitempty"`
	WithMetadata    bool     `json:"with_metadata,omitempty"`
	WithAttributes  bool     `json:"with_attributes,omitempty"`
	ID              string   `json:"id,omitempty"`
}

type PageRes

type PageRes struct {
	Total  uint64 `json:"total"`
	Offset uint64 `json:"offset"`
	Limit  uint64 `json:"limit"`
}

type SDK

type SDK interface {
	// CreateUser registers supermq user.
	//
	// example:
	//  user := sdk.User{
	//    Name:	 "John Doe",
	// 	  Email: "john.doe@example",
	//    Credentials: sdk.Credentials{
	//      Username: "john.doe",
	//      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)

	// Members returns list of users that are members of a group.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		DomainID: "domainID"
	//	}
	//	members, _ := sdk.Members("groupID", pm, "token")
	//	fmt.Println(members)
	Members(groupID string, meta 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)

	// UpdateUserEmail updates the user's email
	//
	// example:
	//  user := sdk.User{
	//    ID:   "userID",
	//    Credentials: sdk.Credentials{
	//      Email: "john.doe@example",
	//    },
	//  }
	//  user, _ := sdk.UpdateUserEmail(user, "token")
	//  fmt.Println(user)
	UpdateUserEmail(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)

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

	// UpdateProfilePicture updates the user's profile picture.
	//
	// example:
	//  user := sdk.User{
	//    ID:            "userID",
	//    ProfilePicture: "https://cloudstorage.example.com/bucket-name/user-images/profile-picture.jpg",
	//  }
	//  user, _ := sdk.UpdateProfilePicture(user, "token")
	//  fmt.Println(user)
	UpdateProfilePicture(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)

	// DeleteUser deletes a user with the given id.
	//
	// example:
	//  err := sdk.DeleteUser("userID", "token")
	//  fmt.Println(err)
	DeleteUser(id, token string) errors.SDKError

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

	// RefreshToken receives credentials and returns user token.
	//
	// example:
	//  token, _ := sdk.RefreshToken("refresh_token")
	//  fmt.Println(token)
	RefreshToken(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", "administrator", "delete", edit", "view", "share", "owner", "owner", "admin", "editor", "viewer", "guest", "editor", "contributor", "create"
	//	}
	//  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", "administrator", "delete", edit", "view", "share", "owner", "owner", "admin", "editor", "contributor", "editor", "viewer", "guest", "create"
	//	}
	//  groups, _ := sdk.ListUserGroups("user_id_1", pm, "token")
	//  fmt.Println(channels)
	ListUserGroups(userID string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)

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

	// SeachUsers filters users and returns a page result.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//	Offset: 0,
	//	Limit:  10,
	//	Name:   "John Doe",
	//  }
	//  users, _ := sdk.SearchUsers(pm, "token")
	//  fmt.Println(users)
	SearchUsers(pm PageMetadata, token string) (UsersPage, errors.SDKError)

	// CreateClient registers new client and returns its id.
	//
	// example:
	//  client := sdk.Client{
	//    Name: "My Client",
	//    Metadata: sdk.Metadata{"domain_1"
	//      "key": "value",
	//    },
	//  }
	//  client, _ := sdk.CreateClient(client, "domainID", "token")
	//  fmt.Println(client)
	CreateClient(client Client, domainID, token string) (Client, errors.SDKError)

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

	// Filters clients and returns a page result.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Client",
	//  }
	//  clients, _ := sdk.Clients(pm, "domainID", "token")
	//  fmt.Println(clients)
	Clients(pm PageMetadata, domainID, token string) (ClientsPage, errors.SDKError)

	// ClientByChannel returns page of clients that are connected to specified channel.
	//
	// example:
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//    Name:   "My Client",
	//  }
	//  clients, _ := sdk.ClientsByChannel("channelID", pm, "domainID", "token")
	//  fmt.Println(clients)
	ClientsByChannel(chanID string, pm PageMetadata, domainID, token string) (ClientsPage, errors.SDKError)

	// Client returns client object by id.
	//
	// example:
	//  client, _ := sdk.Client("clientID", "domainID", "token")
	//  fmt.Println(client)
	Client(id, domainID, token string) (Client, errors.SDKError)

	// ClientPermissions returns user permissions on the client id.
	//
	// example:
	//  client, _ := sdk.Client("clientID", "domainID", "token")
	//  fmt.Println(client)
	ClientPermissions(id, domainID, token string) (Client, errors.SDKError)

	// UpdateClient updates existing client.
	//
	// example:
	//  client := sdk.Client{
	//    ID:   "clientID",
	//    Name: "My Client",
	//    Metadata: sdk.Metadata{
	//      "key": "value",
	//    },
	//  }
	//  client, _ := sdk.UpdateClient(client, "domainID", "token")
	//  fmt.Println(client)
	UpdateClient(client Client, domainID, token string) (Client, errors.SDKError)

	// UpdateClientTags updates the client's tags.
	//
	// example:
	//  client := sdk.Client{
	//    ID:   "clientID",
	//    Tags: []string{"tag1", "tag2"},
	//  }
	//  client, _ := sdk.UpdateClientTags(client, "domainID", "token")
	//  fmt.Println(client)
	UpdateClientTags(client Client, domainID, token string) (Client, errors.SDKError)

	// UpdateClientSecret updates the client's secret
	//
	// example:
	//  client, err := sdk.UpdateClientSecret("clientID", "newSecret", "domainID," "token")
	//  fmt.Println(client)
	UpdateClientSecret(id, secret, domainID, token string) (Client, errors.SDKError)

	// EnableClient changes client status to enabled.
	//
	// example:
	//  client, _ := sdk.EnableClient("clientID", "domainID", "token")
	//  fmt.Println(client)
	EnableClient(id, domainID, token string) (Client, errors.SDKError)

	// DisableClient changes client status to disabled - soft delete.
	//
	// example:
	//  client, _ := sdk.DisableClient("clientID", "domainID", "token")
	//  fmt.Println(client)
	DisableClient(id, domainID, token string) (Client, errors.SDKError)

	// ShareClient shares client with other users.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "contributor", // available options: "owner", "admin", "editor", "contributor", "guest"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	//  err := sdk.ShareClient("client_id", req, "domainID","token")
	//  fmt.Println(err)
	ShareClient(id string, req UsersRelationRequest, domainID, token string) errors.SDKError

	// UnshareClient unshare a client with other users.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "contributor", // available options: "owner", "admin", "editor", "contributor", "guest"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	//  err := sdk.UnshareClient("client_id", req, "domainID", "token")
	//  fmt.Println(err)
	UnshareClient(id string, req UsersRelationRequest, domainID, token string) errors.SDKError

	// ListClientUsers all users in a client.
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit", // available Options:  "administrator", "administrator", "delete", edit", "view", "share", "owner", "owner", "admin", "editor", "contributor", "editor", "viewer", "guest", "create"
	//	}
	//  users, _ := sdk.ListClientUsers("client_id", pm, "domainID", "token")
	//  fmt.Println(users)
	ListClientUsers(id string, pm PageMetadata, domainID, token string) (UsersPage, errors.SDKError)

	// DeleteClient deletes a client with the given id.
	//
	// example:
	//  err := sdk.DeleteClient("clientID", "domainID", "token")
	//  fmt.Println(err)
	DeleteClient(id, domainID, 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, "domainID", "token")
	//  fmt.Println(group)
	CreateGroup(group Group, domainID, 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, "domainID", "token")
	//  fmt.Println(groups)
	Groups(pm PageMetadata, domainID, 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, "domainID", "token")
	//  fmt.Println(groups)
	Parents(id string, pm PageMetadata, domainID, 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, "domainID", "token")
	//  fmt.Println(groups)
	Children(id string, pm PageMetadata, domainID, token string) (GroupsPage, errors.SDKError)

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

	// GroupPermissions returns user permissions by group ID.
	//
	// example:
	//  group, _ := sdk.Group("groupID", "domainID" "token")
	//  fmt.Println(group)
	GroupPermissions(id, domainID, 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, "domainID", "token")
	//  fmt.Println(group)
	UpdateGroup(group Group, domainID, token string) (Group, errors.SDKError)

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

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

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

	// RemoveUserFromGroup remove user from a group.
	//
	// example:
	// req := sdk.UsersRelationRequest{
	//		Relation: "contributor", // available options: "owner", "admin", "editor", "contributor", "guest"
	//  	UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
	// }
	// err := sdk.RemoveUserFromGroup("groupID",req, "domainID", "token")
	// fmt.Println(err)
	RemoveUserFromGroup(groupID string, req UsersRelationRequest, domainID, 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", "administrator", "delete", edit", "view", "share", "owner", "owner", "admin", "editor", "contributor", "editor", "viewer", "guest", "create"
	//	}
	//  groups, _ := sdk.ListGroupUsers("groupID", pm, "domainID", "token")
	//  fmt.Println(groups)
	ListGroupUsers(groupID string, pm PageMetadata, domainID, 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", "administrator", "delete", edit", "view", "share", "owner", "owner", "admin", "editor", "contributor", "editor", "viewer", "guest", "create"
	//	}
	//  groups, _ := sdk.ListGroupChannels("groupID", pm, "domainID", "token")
	//  fmt.Println(groups)
	ListGroupChannels(groupID string, pm PageMetadata, domainID, token string) (ChannelsPage, errors.SDKError)

	// DeleteGroup delete given group id.
	//
	// example:
	//  err := sdk.DeleteGroup("groupID", "domainID", "token")
	//  fmt.Println(err)
	DeleteGroup(id, domainID, 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, "domainID", "token")
	//  fmt.Println(channel)
	CreateChannel(channel Channel, domainID, 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, "domainID", "token")
	//  fmt.Println(channels)
	Channels(pm PageMetadata, domainID, token string) (ChannelsPage, errors.SDKError)

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

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

	// ChannelPermissions returns user permissions on the channel ID.
	//
	// example:
	//  channel, _ := sdk.Channel("channelID", "domainID", "token")
	//  fmt.Println(channel)
	ChannelPermissions(id, domainID, 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, "domainID", "token")
	//  fmt.Println(channel)
	UpdateChannel(channel Channel, domainID, token string) (Channel, errors.SDKError)

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

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

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

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

	// ListChannelUsers list all users in a channel .
	//
	// example:
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//		Permission: "edit",  // available Options:  "administrator", "administrator", "delete", edit", "view", "share", "owner", "owner", "admin", "editor", "contributor", "editor", "viewer", "guest", "create"
	//	}
	//  users, _ := sdk.ListChannelUsers("channel_id", pm, "domainID", "token")
	//  fmt.Println(users)
	ListChannelUsers(channelID string, pm PageMetadata, domainID, 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, "domainID", "token")
	// fmt.Println(err)
	AddUserGroupToChannel(channelID string, req UserGroupsRequest, domainID, 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, "domainID", "token")
	// fmt.Println(err)
	RemoveUserGroupFromChannel(channelID string, req UserGroupsRequest, domainID, 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, "domainID", "token")
	//  fmt.Println(groups)
	ListChannelUserGroups(channelID string, pm PageMetadata, domainID, token string) (GroupsPage, errors.SDKError)

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

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

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

	// ConnectClient connects client to specified channel by id.
	//
	// The `ConnectClient` method calls the `CreateClientPolicy` method under the hood.
	//
	// example:
	//  err := sdk.ConnectClient("clientID", "channelID",[]string{"Publish", "Subscribe"} "token")
	//  fmt.Println(err)
	ConnectClient(clientID, chanID string, connTypes []string, domainID, token string) errors.SDKError

	// DisconnectClient disconnect client from specified channel by id.
	//
	// The `DisconnectClient` method calls the `DeleteClientPolicy` method under the hood.
	//
	// example:
	//  err := sdk.DisconnectClient("clientID", "channelID",[]string{"Publish", "Subscribe"} "token")
	//  fmt.Println(err)
	DisconnectClient(clientID, chanID string, connTypes []string, domainID, 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, "clientSecret")
	//  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", "domainID", "token")
	//  fmt.Println(msgs)
	ReadMessages(pm MessagePageMetadata, chanID, domainID, 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{
	//    ClientID: "clientID",
	//    Name: "bootstrap",
	//    ExternalID: "externalID",
	//    ExternalKey: "externalKey",
	//    Channels: []string{"channel1", "channel2"},
	//  }
	//  id, _ := sdk.AddBootstrap(cfg, "domainID", "token")
	//  fmt.Println(id)
	AddBootstrap(cfg BootstrapConfig, domainID, token string) (string, errors.SDKError)

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

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

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

	// UpdateBootstrapConnection updates connections performs update of the channel list corresponding Client is connected to.
	//
	// example:
	//  err := sdk.UpdateBootstrapConnection("id", []string{"channel1", "channel2"}, "domainID", "token")
	//  fmt.Println(err)
	UpdateBootstrapConnection(id string, channels []string, domainID, 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", "domainID", "token")
	//  fmt.Println(err)
	RemoveBootstrap(id, domainID, token string) errors.SDKError

	// Bootstrap returns Config to the Client 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, "domainID", "token")
	//  fmt.Println(bootstraps)
	Bootstraps(pm PageMetadata, domainID, token string) (BootstrapPage, errors.SDKError)

	// Whitelist updates Client state Config with given ID belonging to the user identified by the given token.
	//
	// example:
	//  err := sdk.Whitelist("clientID", 1, "domainID", "token")
	//  fmt.Println(err)
	Whitelist(clientID string, state int, domainID, token string) errors.SDKError

	// IssueCert issues a certificate for a client required for mTLS.
	//
	// example:
	//  cert, _ := sdk.IssueCert("clientID", "24h", "domainID", "token")
	//  fmt.Println(cert)
	IssueCert(clientID, validity, domainID, token string) (Cert, errors.SDKError)

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

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

	// RevokeCert revokes certificate for client with clientID
	//
	// example:
	//  tm, _ := sdk.RevokeCert("clientID", "domainID", "token")
	//  fmt.Println(tm)
	RevokeCert(clientID, domainID, 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: "contributor", // available options: "owner", "admin", "editor", "contributor",  "member", "guest"
	//  	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:
	// err := sdk.RemoveUserFromDomain("domainID", "userID", "token")
	// fmt.Println(err)
	RemoveUserFromDomain(domainID, userID, 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: "contributor", // available options: "owner", "admin", "editor", "contributor", "guest"
	//  }
	//  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}, "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)

	// RejectInvitation rejects an invitation.
	//
	// For example:
	//  err := sdk.RejectInvitation("domainID", "token")
	//  fmt.Println(err)
	RejectInvitation(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)

	// Journal returns a list of journal logs.
	//
	// For example:
	//  journals, _ := sdk.Journal("client", "clientID","domainID", PageMetadata{Offset: 0, Limit: 10, Operation: "thing.create"}, "token")
	//  fmt.Println(journals)
	Journal(entityType, entityID, domainID string, pm PageMetadata, token string) (journal JournalsPage, err error)
}

SDK contains SuperMQ API.

func NewSDK

func NewSDK(conf Config) SDK

NewSDK returns new supermq 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"`
	PageRes
}

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 UpdateUsernameReq

type UpdateUsernameReq struct {
	Username string `json:"username"`
	// contains filtered or unexported fields
}

type User

type User struct {
	ID             string      `json:"id"`
	FirstName      string      `json:"first_name,omitempty"`
	LastName       string      `json:"last_name,omitempty"`
	Email          string      `json:"email,omitempty"`
	Credentials    Credentials `json:"credentials"`
	Tags           []string    `json:"tags,omitempty"`
	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"`
	ProfilePicture string      `json:"profile_picture,omitempty"`
}

User represents supermq 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"`
	PageRes
}

type UsersRelationRequest

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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