sdk

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 18 Imported by: 14

README

SuperMQ Go SDK

Go SDK, a Go driver for SuperMQ HTTP API.

Provides comprehensive functionality for system administration (provisioning), messaging, user management, domain management, groups, channels, clients, certificates, invitations, and journal operations.

Installation

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

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

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

Quick Start

import (
    "context"
    "fmt"
    "github.com/absmach/supermq/pkg/sdk"
)

func main() {
    conf := sdk.Config{
        UsersURL:       "http://localhost:9002",
        ClientsURL:     "http://localhost:9000",
        ChannelsURL:    "http://localhost:9001",
        DomainsURL:     "http://localhost:8189",
        HTTPAdapterURL: "http://localhost:8008",
        CertsURL:       "http://localhost:9019",
        JournalURL:     "http://localhost:9021",
        HostURL:        "http://localhost",
    }

    // Create SDK instance
    smqsdk := sdk.NewSDK(conf)

    ctx := context.Background()

    // Create user
    user := sdk.User{
        Name: "John Doe",
        Email: "john.doe@example.com",
        Credentials: sdk.Credentials{
            Username: "john.doe",
            Secret:   "12345678",
        },
    }
    user, err := smqsdk.CreateUser(ctx, user, "")
    if err != nil {
        fmt.Printf("Error creating user: %v\n", err)
        return
    }

    // Create token
    login := sdk.Login{
        Identity: "john.doe",
        Secret:   "12345678",
    }
    token, err := smqsdk.CreateToken(ctx, login)
    if err != nil {
        fmt.Printf("Error creating token: %v\n", err)
        return
    }

    fmt.Printf("User created: %+v\n", user)
    fmt.Printf("Token: %s\n", token.AccessToken)
}

API Reference

Configuration
type Config struct {
    CertsURL        string
    HTTPAdapterURL  string
    ClientsURL      string
    UsersURL        string
    GroupsURL       string
    ChannelsURL     string
    DomainsURL      string
    JournalURL      string
    HostURL         string
    MsgContentType  ContentType
    TLSVerification bool
    CurlFlag        bool
    Roles           bool
}

func NewSDK(conf Config) SDK
User Management
// Create a new user
CreateUser(ctx context.Context, user User, token string) (User, errors.SDKError)

// Get user by ID
User(ctx context.Context, id, token string) (User, errors.SDKError)

// Get current user profile
UserProfile(ctx context.Context, token string) (User, errors.SDKError)

// List users with pagination
Users(ctx context.Context, pm PageMetadata, token string) (UsersPage, errors.SDKError)

// Search users
SearchUsers(ctx context.Context, pm PageMetadata, token string) (UsersPage, errors.SDKError)

// Update user information
UpdateUser(ctx context.Context, user User, token string) (User, errors.SDKError)
UpdateUserEmail(ctx context.Context, user User, token string) (User, errors.SDKError)
UpdateUserTags(ctx context.Context, user User, token string) (User, errors.SDKError)
UpdateUsername(ctx context.Context, user User, token string) (User, errors.SDKError)
UpdateProfilePicture(ctx context.Context, user User, token string) (User, errors.SDKError)
UpdateUserRole(ctx context.Context, user User, token string) (User, errors.SDKError)

// Password management
UpdatePassword(ctx context.Context, oldPass, newPass, token string) (User, errors.SDKError)
ResetPasswordRequest(ctx context.Context, email string) errors.SDKError
ResetPassword(ctx context.Context, password, confPass, token string) errors.SDKError

// User status management
EnableUser(ctx context.Context, id, token string) (User, errors.SDKError)
DisableUser(ctx context.Context, id, token string) (User, errors.SDKError)
DeleteUser(ctx context.Context, id, token string) errors.SDKError
Authentication
// Create authentication token
CreateToken(ctx context.Context, lt Login) (Token, errors.SDKError)

// Refresh authentication token
RefreshToken(ctx context.Context, token string) (Token, errors.SDKError)
Domain Management
// Create domain
CreateDomain(ctx context.Context, d Domain, token string) (Domain, errors.SDKError)

// Get domain information
Domain(ctx context.Context, domainID, token string) (Domain, errors.SDKError)

// List domains
Domains(ctx context.Context, pm PageMetadata, token string) (DomainsPage, errors.SDKError)

// Update domain
UpdateDomain(ctx context.Context, d Domain, token string) (Domain, errors.SDKError)

// Domain status management
EnableDomain(ctx context.Context, domainID, token string) errors.SDKError
DisableDomain(ctx context.Context, domainID, token string) errors.SDKError
FreezeDomain(ctx context.Context, domainID, token string) errors.SDKError

// Domain roles management
CreateDomainRole(ctx context.Context, id string, rq RoleReq, token string) (Role, errors.SDKError)
DomainRoles(ctx context.Context, id string, pm PageMetadata, token string) (RolesPage, errors.SDKError)
DomainRole(ctx context.Context, id, roleID, token string) (Role, errors.SDKError)
UpdateDomainRole(ctx context.Context, id, roleID, newName string, token string) (Role, errors.SDKError)
DeleteDomainRole(ctx context.Context, id, roleID, token string) errors.SDKError

// Domain role actions management
AddDomainRoleActions(ctx context.Context, id, roleID string, actions []string, token string) ([]string, errors.SDKError)
DomainRoleActions(ctx context.Context, id, roleID string, token string) ([]string, errors.SDKError)
RemoveDomainRoleActions(ctx context.Context, id, roleID string, actions []string, token string) errors.SDKError
RemoveAllDomainRoleActions(ctx context.Context, id, roleID, token string) errors.SDKError
AvailableDomainRoleActions(ctx context.Context, token string) ([]string, errors.SDKError)

// Domain role members management
AddDomainRoleMembers(ctx context.Context, id, roleID string, members []string, token string) ([]string, errors.SDKError)
DomainRoleMembers(ctx context.Context, id, roleID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError)
RemoveDomainRoleMembers(ctx context.Context, id, roleID string, members []string, token string) errors.SDKError
RemoveAllDomainRoleMembers(ctx context.Context, id, roleID, token string) errors.SDKError
ListDomainMembers(ctx context.Context, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)
Client Management
// Create clients
CreateClient(ctx context.Context, client Client, domainID, token string) (Client, errors.SDKError)
CreateClients(ctx context.Context, client []Client, domainID, token string) ([]Client, errors.SDKError)

// Get client information
Client(ctx context.Context, id, domainID, token string) (Client, errors.SDKError)
Clients(ctx context.Context, pm PageMetadata, domainID, token string) (ClientsPage, errors.SDKError)

// Update clients
UpdateClient(ctx context.Context, client Client, domainID, token string) (Client, errors.SDKError)
UpdateClientTags(ctx context.Context, client Client, domainID, token string) (Client, errors.SDKError)
UpdateClientSecret(ctx context.Context, id, secret, domainID, token string) (Client, errors.SDKError)

// Client status management
EnableClient(ctx context.Context, id, domainID, token string) (Client, errors.SDKError)
DisableClient(ctx context.Context, id, domainID, token string) (Client, errors.SDKError)
DeleteClient(ctx context.Context, id, domainID, token string) errors.SDKError

// Client hierarchy management
SetClientParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError
RemoveClientParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

// Client roles management
CreateClientRole(ctx context.Context, id, domainID string, rq RoleReq, token string) (Role, errors.SDKError)
ClientRoles(ctx context.Context, id, domainID string, pm PageMetadata, token string) (RolesPage, errors.SDKError)
ClientRole(ctx context.Context, id, roleID, domainID, token string) (Role, errors.SDKError)
UpdateClientRole(ctx context.Context, id, roleID, newName, domainID string, token string) (Role, errors.SDKError)
DeleteClientRole(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

// Client role actions management
AddClientRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError)
ClientRoleActions(ctx context.Context, id, roleID, domainID string, token string) ([]string, errors.SDKError)
RemoveClientRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) errors.SDKError
RemoveAllClientRoleActions(ctx context.Context, id, roleID, domainID, token string) errors.SDKError
AvailableClientRoleActions(ctx context.Context, domainID, token string) ([]string, errors.SDKError)

// Client role members management
AddClientRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError)
ClientRoleMembers(ctx context.Context, id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError)
RemoveClientRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) errors.SDKError
RemoveAllClientRoleMembers(ctx context.Context, id, roleID, domainID, token string) errors.SDKError
ListClientMembers(ctx context.Context, clientID, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)
Channel Management
// Create channels
CreateChannel(ctx context.Context, channel Channel, domainID, token string) (Channel, errors.SDKError)
CreateChannels(ctx context.Context, channels []Channel, domainID, token string) ([]Channel, errors.SDKError)

// Get channel information
Channel(ctx context.Context, id, domainID, token string) (Channel, errors.SDKError)
Channels(ctx context.Context, pm PageMetadata, domainID, token string) (ChannelsPage, errors.SDKError)

// Update channels
UpdateChannel(ctx context.Context, channel Channel, domainID, token string) (Channel, errors.SDKError)
UpdateChannelTags(ctx context.Context, c Channel, domainID, token string) (Channel, errors.SDKError)

// Channel status management
EnableChannel(ctx context.Context, id, domainID, token string) (Channel, errors.SDKError)
DisableChannel(ctx context.Context, id, domainID, token string) (Channel, errors.SDKError)
DeleteChannel(ctx context.Context, id, domainID, token string) errors.SDKError

// Channel hierarchy management
SetChannelParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError
RemoveChannelParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

// Channel connections
Connect(ctx context.Context, conn Connection, domainID, token string) errors.SDKError
Disconnect(ctx context.Context, conn Connection, domainID, token string) errors.SDKError
ConnectClients(ctx context.Context, channelID string, clientIDs, connTypes []string, domainID, token string) errors.SDKError
DisconnectClients(ctx context.Context, channelID string, clientIDs, connTypes []string, domainID, token string) errors.SDKError

// List channel members
ListChannelMembers(ctx context.Context, channelID, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)
Group Management
// Create group
CreateGroup(ctx context.Context, group Group, domainID, token string) (Group, errors.SDKError)

// Get group information
Group(ctx context.Context, id, domainID, token string) (Group, errors.SDKError)
Groups(ctx context.Context, pm PageMetadata, domainID, token string) (GroupsPage, errors.SDKError)

// Update groups
UpdateGroup(ctx context.Context, group Group, domainID, token string) (Group, errors.SDKError)
UpdateGroupTags(ctx context.Context, group Group, domainID, token string) (Group, errors.SDKError)

// Group status management
EnableGroup(ctx context.Context, id, domainID, token string) (Group, errors.SDKError)
DisableGroup(ctx context.Context, id, domainID, token string) (Group, errors.SDKError)
DeleteGroup(ctx context.Context, id, domainID, token string) errors.SDKError

// Group hierarchy management
SetGroupParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError
RemoveGroupParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError
AddChildren(ctx context.Context, id, domainID string, groupIDs []string, token string) errors.SDKError
RemoveChildren(ctx context.Context, id, domainID string, groupIDs []string, token string) errors.SDKError
RemoveAllChildren(ctx context.Context, id, domainID, token string) errors.SDKError
Children(ctx context.Context, id, domainID string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)
Hierarchy(ctx context.Context, id, domainID string, pm PageMetadata, token string) (GroupsHierarchyPage, errors.SDKError)

// Group roles management
CreateGroupRole(ctx context.Context, id, domainID string, rq RoleReq, token string) (Role, errors.SDKError)
GroupRoles(ctx context.Context, id, domainID string, pm PageMetadata, token string) (RolesPage, errors.SDKError)
GroupRole(ctx context.Context, id, roleID, domainID, token string) (Role, errors.SDKError)
UpdateGroupRole(ctx context.Context, id, roleID, newName, domainID string, token string) (Role, errors.SDKError)
DeleteGroupRole(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

// Group role actions management
AddGroupRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError)
GroupRoleActions(ctx context.Context, id, roleID, domainID string, token string) ([]string, errors.SDKError)
RemoveGroupRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) errors.SDKError
RemoveAllGroupRoleActions(ctx context.Context, id, roleID, domainID, token string) errors.SDKError
AvailableGroupRoleActions(ctx context.Context, id, token string) ([]string, errors.SDKError)

// Group role members management
AddGroupRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError)
GroupRoleMembers(ctx context.Context, id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError)
RemoveGroupRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) errors.SDKError
RemoveAllGroupRoleMembers(ctx context.Context, id, roleID, domainID, token string) errors.SDKError
ListGroupMembers(ctx context.Context, groupID, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)
Certificate Management
// Issue certificate for mTLS
IssueCert(ctx context.Context, clientID, validity, domainID, token string) (Cert, errors.SDKError)

// View certificate
ViewCert(ctx context.Context, certID, domainID, token string) (Cert, errors.SDKError)

// View certificates by client
ViewCertByClient(ctx context.Context, clientID, domainID, token string) (CertSerials, errors.SDKError)

// Revoke certificates
RevokeCert(ctx context.Context, certID, domainID, token string) (time.Time, errors.SDKError)
RevokeAllCerts(ctx context.Context, clientID, domainID, token string) (time.Time, errors.SDKError)
Invitation Management
// Send invitation
SendInvitation(ctx context.Context, invitation Invitation, token string) error

// List invitations
Invitations(ctx context.Context, pm PageMetadata, token string) (InvitationPage, error)
DomainInvitations(ctx context.Context, pm PageMetadata, token, domainID string) (InvitationPage, error)

// Manage invitations
AcceptInvitation(ctx context.Context, domainID, token string) error
RejectInvitation(ctx context.Context, domainID, token string) error
DeleteInvitation(ctx context.Context, userID, domainID, token string) error
Journal Management
// Get journal logs
Journal(ctx context.Context, entityType, entityID, domainID string, pm PageMetadata, token string) (JournalsPage, error)
Messaging
// Send message to channel
SendMessage(ctx context.Context, domainID, topic, msg, secret string) errors.SDKError

// Set message content type
SetContentType(ct ContentType) errors.SDKError
Health Check
// Service health check
Health(service string) (HealthInfo, errors.SDKError)

Examples

Domain and User Management
ctx := context.Background()

// Create domain
domain := sdk.Domain{
    Name: "My Domain",
    Metadata: sdk.Metadata{"key": "value"},
}
domain, err := smqsdk.CreateDomain(ctx, domain, adminToken)

// Create user in domain
user := sdk.User{
    Name: "Jane Doe",
    Email: "jane@example.com",
    Credentials: sdk.Credentials{
        Username: "jane.doe",
        Secret:   "password123",
    },
}
user, err = smqsdk.CreateUser(ctx, user, adminToken)
Client and Channel Operations
// Create client
client := sdk.Client{
    Name: "Temperature Sensor",
    Metadata: sdk.Metadata{"location": "office"},
}
client, err := smqsdk.CreateClient(ctx, client, domainID, token)

// Create channel
channel := sdk.Channel{
    Name: "Temperature Data",
    Metadata: sdk.Metadata{"type": "sensor_data"},
}
channel, err = smqsdk.CreateChannel(ctx, channel, domainID, token)

// Connect client to channel
conn := sdk.Connection{
    ClientIDs:  []string{client.ID},
    ChannelIDs: []string{channel.ID},
    Types:      []string{"publish", "subscribe"},
}
err = smqsdk.Connect(ctx, conn, domainID, token)
Group Management
// Create group
group := sdk.Group{
    Name: "Sensors Group",
    Metadata: sdk.Metadata{"type": "sensors"},
}
group, err := smqsdk.CreateGroup(ctx, group, domainID, token)

// Set client parent group
err = smqsdk.SetClientParent(ctx, client.ID, domainID, group.ID, token)
Role Management
// Create domain role
roleReq := sdk.RoleReq{
    RoleName: "Editor",
    OptionalActions: []string{"read", "update"},
    OptionalMembers: []string{user.ID},
}
role, err := smqsdk.CreateDomainRole(ctx, domainID, roleReq, token)

// Add role members
members := []string{user.ID}
addedMembers, err := smqsdk.AddDomainRoleMembers(ctx, domainID, role.ID, members, token)

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 Channel

type Channel struct {
	ID          string                    `json:"id,omitempty"`
	Name        string                    `json:"name,omitempty"`
	Tags        []string                  `json:"tags,omitempty"`
	Route       string                    `json:"route,omitempty"`
	ParentGroup string                    `json:"parent_group_id,omitempty"`
	DomainID    string                    `json:"domain_id,omitempty"`
	Metadata    Metadata                  `json:"metadata,omitempty"`
	CreatedAt   time.Time                 `json:"created_at,omitempty"`
	UpdatedAt   time.Time                 `json:"updated_at,omitempty"`
	UpdatedBy   string                    `json:"updated_by,omitempty"`
	Status      string                    `json:"status,omitempty"`
	Permissions []string                  `json:"permissions,omitempty"`
	Roles       []roles.MemberRoleActions `json:"roles,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"`
	Tags            []string                  `json:"tags,omitempty"`
	DomainID        string                    `json:"domain_id,omitempty"`
	ParentGroup     string                    `json:"parent_group_id,omitempty"`
	Credentials     ClientCredentials         `json:"credentials"`
	Metadata        map[string]any            `json:"metadata,omitempty"`
	PrivateMetadata map[string]any            `json:"private_metadata,omitempty"`
	CreatedAt       time.Time                 `json:"created_at,omitempty"`
	UpdatedAt       time.Time                 `json:"updated_at,omitempty"`
	UpdatedBy       string                    `json:"updated_by,omitempty"`
	Status          string                    `json:"status,omitempty"`
	Permissions     []string                  `json:"permissions,omitempty"`
	Roles           []roles.MemberRoleActions `json:"roles,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 {
	CertsURL       string
	HTTPAdapterURL string
	ClientsURL     string
	UsersURL       string
	GroupsURL      string
	ChannelsURL    string
	DomainsURL     string
	JournalURL     string
	HostURL        string

	MsgContentType  ContentType
	TLSVerification bool
	CurlFlag        bool
	Roles           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"`
	Route       string                    `json:"route,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"`
	Roles       []roles.MemberRoleActions `json:"roles,omitempty"`
}

Domain represents supermq domain.

type DomainsPage

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

type EntityMembersPage added in v0.17.0

type EntityMembersPage struct {
	Total   uint64        `json:"total"`
	Offset  uint64        `json:"offset"`
	Limit   uint64        `json:"limit"`
	Members []MemberRoles `json:"members"`
}

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"`
	Tags                      []string                  `json:"tags,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"`
	UpdatedBy                 string                    `json:"updated_by,omitempty"`
	Status                    string                    `json:"status,omitempty"`
	RoleID                    string                    `json:"role_id,omitempty"`
	RoleName                  string                    `json:"role_name,omitempty"`
	Actions                   []string                  `json:"actions,omitempty"`
	AccessType                string                    `json:"access_type,omitempty"`
	AccessProviderId          string                    `json:"access_provider_id,omitempty"`
	AccessProviderRoleId      string                    `json:"access_provider_role_id,omitempty"`
	AccessProviderRoleName    string                    `json:"access_provider_role_name,omitempty"`
	AccessProviderRoleActions []string                  `json:"access_provider_role_actions,omitempty"`
	Roles                     []roles.MemberRoleActions `json:"roles,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 GroupsHierarchyPage added in v0.17.0

type GroupsHierarchyPage struct {
	Level     uint64  `json:"level"`
	Direction int64   `json:"direction"`
	Groups    []Group `json:"groups"`
}

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"`
	InviteeUserID string    `json:"invitee_user_id"`
	DomainID      string    `json:"domain_id"`
	DomainName    string    `json:"domain_name,omitempty"`
	RoleID        string    `json:"role_id,omitempty"`
	RoleName      string    `json:"role_name,omitempty"`
	Actions       []string  `json:"actions,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 {
	Username    string `json:"username"`
	Password    string `json:"password"`
	Description string `json:"description,omitempty"`
}

type MemberRole added in v0.17.0

type MemberRole struct {
	Actions            []string `json:"actions,omitempty"`
	RoleName           string   `json:"role_name,omitempty"`
	RoleID             string   `json:"role_id,omitempty"`
	AccessType         string   `json:"access_type,omitempty"`
	AccessProviderID   string   `json:"access_provider_id,omitempty"`
	AccessProviderPath string   `json:"access_provider_path,omitempty"`
}

type MemberRoles added in v0.17.0

type MemberRoles struct {
	MemberID string       `json:"member_id"`
	Roles    []MemberRole `json:"roles"`
}

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]any

type Operator added in v0.19.0

type Operator uint8
const (
	OrOp Operator = iota
	AndOp
)

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"`
	Tags            TagsQuery `json:"tags,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"`
	Tree            bool      `json:"tree,omitempty"`
	StartLevel      int64     `json:"start_level,omitempty"`
	EndLevel        int64     `json:"end_level,omitempty"`
	CreatedFrom     time.Time `json:"created_from,omitempty"`
	CreatedTo       time.Time `json:"created_to,omitempty"`
}

type PageRes

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

type Role added in v0.17.0

type Role struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	EntityID        string    `json:"entity_id"`
	CreatedBy       string    `json:"created_by"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedBy       string    `json:"updated_by"`
	UpdatedAt       time.Time `json:"updated_at"`
	OptionalActions []string  `json:"optional_actions,omitempty"`
	OptionalMembers []string  `json:"optional_members,omitempty"`
}

type RoleMembersPage added in v0.17.0

type RoleMembersPage struct {
	Total   uint64   `json:"total"`
	Offset  uint64   `json:"offset"`
	Limit   uint64   `json:"limit"`
	Members []string `json:"members"`
}

type RoleReq added in v0.17.0

type RoleReq struct {
	RoleName        string   `json:"role_name"`
	OptionalActions []string `json:"optional_actions"`
	OptionalMembers []string `json:"optional_members"`
}

type RolesPage added in v0.17.0

type RolesPage struct {
	Total  uint64 `json:"total"`
	Offset uint64 `json:"offset"`
	Limit  uint64 `json:"limit"`
	Roles  []Role `json:"roles"`
}

type SDK

type SDK interface {
	// CreateUser registers supermq user.
	//
	// example:
	//  ctx := context.Background()
	//  user := sdk.User{
	//    Name:	 "John Doe",
	// 	  Email: "john.doe@example",
	//    Credentials: sdk.Credentials{
	//      Username: "john.doe",
	//      Secret:   "12345678",
	//    },
	//  }
	//  user, _ := sdk.CreateUser(ctx, user)
	//  fmt.Println(user)
	CreateUser(ctx context.Context, user User, token string) (User, errors.SDKError)

	// SendVerification sends a verification email to the user.
	//
	// example:
	//  err := sdk.SendVerification("token")
	//  fmt.Println(err)
	SendVerification(ctx context.Context, token string) errors.SDKError

	// VerifyEmail verifies the user's email address using the provided token.
	//
	// example:
	//  err := sdk.VerifyEmail("verificationToken")
	//  fmt.Println(user)
	VerifyEmail(ctx context.Context, verificationToken string) errors.SDKError

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

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

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

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

	// UpdateUserEmail updates the user's email
	//
	// example:
	//  ctx := context.Background()
	//  user := sdk.User{
	//    ID:   "userID",
	//    Credentials: sdk.Credentials{
	//      Email: "john.doe@example",
	//    },
	//  }
	//  user, _ := sdk.UpdateUserEmail(ctx, user, "token")
	//  fmt.Println(user)
	UpdateUserEmail(ctx context.Context, user User, token string) (User, errors.SDKError)

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

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

	// UpdateProfilePicture updates the user's profile picture.
	//
	// example:
	//  ctx := context.Background()
	//  user := sdk.User{
	//    ID:            "userID",
	//    ProfilePicture: "https://cloudstorage.example.com/bucket-name/user-images/profile-picture.jpg",
	//  }
	//  user, _ := sdk.UpdateProfilePicture(ctx, user, "token")
	//  fmt.Println(user)
	UpdateProfilePicture(ctx context.Context, user User, token string) (User, errors.SDKError)

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

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

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

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

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

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

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

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

	// RefreshToken receives credentials and returns user token.
	//
	// example:
	//  ctx := context.Background()
	//  token, _ := sdk.RefreshToken(ctx, "refresh_token")
	//  fmt.Println(token)
	RefreshToken(ctx context.Context, token string) (Token, errors.SDKError)

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

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

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

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

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

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

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

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

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

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

	// DeleteClient deletes a client with the given id.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.DeleteClient(ctx, "clientID", "domainID", "token")
	//  fmt.Println(err)
	DeleteClient(ctx context.Context, id, domainID, token string) errors.SDKError

	// SetClientParent sets the parent group of a client.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.SetClientParent(ctx, "clientID", "domainID", "groupID", "token")
	//  fmt.Println(err)
	SetClientParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

	// RemoveClientParent removes the parent group of a client.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveClientParent(ctx, "clientID", "domainID", "groupID", "token")
	//  fmt.Println(err)
	RemoveClientParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

	// CreateClientRole creates new client role and returns its id.
	//
	// example:
	//  ctx := context.Background()
	//  rq := sdk.RoleReq{
	//    RoleName: "My Role",
	//    OptionalActions: []string{"read", "update"},
	//    OptionalMembers: []string{"member_id_1", "member_id_2"},
	//  }
	//  role, _ := sdk.CreateClientRole(ctx, "clientID", "domainID", rq, "token")
	//  fmt.Println(role)
	CreateClientRole(ctx context.Context, id, domainID string, rq RoleReq, token string) (Role, errors.SDKError)

	// ClientRoles returns client roles.
	//
	// example:
	//  ctx := context.Background()
	// pm := sdk.PageMetadata{
	//   Offset: 0,
	//   Limit:  10,
	// }
	//  roles, _ := sdk.ClientRoles(ctx, "clientID", "domainID", pm, "token")
	//  fmt.Println(roles)
	ClientRoles(ctx context.Context, id, domainID string, pm PageMetadata, token string) (RolesPage, errors.SDKError)

	// ClientRole returns client role object by roleID.
	//
	// example:
	//  ctx := context.Background()
	//  role, _ := sdk.ClientRole(ctx, "clientID", "roleID", "domainID", "token")
	//  fmt.Println(role)
	ClientRole(ctx context.Context, id, roleID, domainID, token string) (Role, errors.SDKError)

	// UpdateClientRole updates existing client role name.
	//
	// example:
	//  ctx := context.Background()
	//  role, _ := sdk.UpdateClientRole(ctx, "clientID", "roleID", "newName", "domainID", "token")
	//  fmt.Println(role)
	UpdateClientRole(ctx context.Context, id, roleID, newName, domainID string, token string) (Role, errors.SDKError)

	// DeleteClientRole deletes a client role with the given clientID and  roleID.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.DeleteClientRole(ctx, "clientID", "roleID", "domainID", "token")
	//  fmt.Println(err)
	DeleteClientRole(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

	// AddClientRoleActions adds actions to a client role.
	//
	// example:
	//  ctx := context.Background()
	//  actions := []string{"read", "update"}
	//  actions, _ := sdk.AddClientRoleActions(ctx, "clientID", "roleID", "domainID", actions, "token")
	//  fmt.Println(actions)
	AddClientRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError)

	// ClientRoleActions returns client role actions by roleID.
	//
	// example:
	//  ctx := context.Background()
	//  actions, _ := sdk.ClientRoleActions(ctx, "clientID", "roleID", "domainID", "token")
	//  fmt.Println(actions)
	ClientRoleActions(ctx context.Context, id, roleID, domainID string, token string) ([]string, errors.SDKError)

	// RemoveClientRoleActions removes actions from a client role.
	//
	// example:
	//  ctx := context.Background()
	//  actions := []string{"read", "update"}
	//  err := sdk.RemoveClientRoleActions(ctx, "clientID", "roleID", "domainID", actions, "token")
	//  fmt.Println(err)
	RemoveClientRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) errors.SDKError

	// RemoveAllClientRoleActions removes all actions from a client role.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveAllClientRoleActions(ctx, "clientID", "roleID", "domainID", "token")
	//  fmt.Println(err)
	RemoveAllClientRoleActions(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

	// AddClientRoleMembers adds members to a client role.
	//
	// example:
	//  ctx := context.Background()
	//  members := []string{"member_id_1", "member_id_2"}
	//  members, _ := sdk.AddClientRoleMembers(ctx, "clientID", "roleID", "domainID", members, "token")
	//  fmt.Println(members)
	AddClientRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError)

	// ClientRoleMembers returns client role members by roleID.
	//
	// example:
	//  ctx := context.Background()
	// pm := sdk.PageMetadata{
	//   Offset: 0,
	//  Limit:  10,
	// }
	//  members, _ := sdk.ClientRoleMembers(ctx, "clientID", "roleID", "domainID", pm,"token")
	//  fmt.Println(members)
	ClientRoleMembers(ctx context.Context, id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError)

	// RemoveClientRoleMembers removes members from a client role.
	//
	// example:
	//  ctx := context.Background()
	//  members := []string{"member_id_1", "member_id_2"}
	//  err := sdk.RemoveClientRoleMembers(ctx, "clientID", "roleID", "domainID", members, "token")
	//  fmt.Println(err)
	RemoveClientRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) errors.SDKError

	// RemoveAllClientRoleMembers removes all members from a client role.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveAllClientRoleMembers(ctx, "clientID", "roleID", "domainID", "token")
	//  fmt.Println(err)
	RemoveAllClientRoleMembers(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

	// AvailableClientRoleActions returns available actions for a client role.
	//
	// example:
	//  ctx := context.Background()
	//  actions, _ := sdk.AvailableClientRoleActions(ctx, "domainID", "token")
	//  fmt.Println(actions)
	AvailableClientRoleActions(ctx context.Context, domainID, token string) ([]string, errors.SDKError)

	// ListClientMembers list all members from all roles in a client .
	//
	// example:
	//  ctx := context.Background()
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//	}
	//  members, _ := sdk.ListClientMembers(ctx, "client_id","domainID", pm, "token")
	//  fmt.Println(members)
	ListClientMembers(ctx context.Context, clientID, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)

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

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

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

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

	// UpdateGroupTags updates tags for existing group.
	//
	// example:
	//  ctx := context.Background()
	//  group := sdk.Group{
	//    ID:   "groupID",
	//    Tags: []string{"tag1", "tag2"}
	//  }
	//  group, _ := sdk.UpdateGroupTags(ctx, group, "domainID", "token")
	//  fmt.Println(group)
	UpdateGroupTags(ctx context.Context, group Group, domainID, token string) (Group, errors.SDKError)

	// SetGroupParent sets the parent group of a group.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.SetGroupParent(ctx, "groupID", "domainID", "groupID", "token")
	//  fmt.Println(err)
	SetGroupParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

	// RemoveGroupParent removes the parent group of a group.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveGroupParent(ctx, "groupID", "domainID", "groupID", "token")
	//  fmt.Println(err)
	RemoveGroupParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

	// AddChildren adds children groups to a group.
	//
	// example:
	//  ctx := context.Background()
	//  groupIDs := []string{"groupID1", "groupID2"}
	//  err := sdk.AddChildren(ctx, "groupID", "domainID", groupIDs, "token")
	//  fmt.Println(err)
	AddChildren(ctx context.Context, id, domainID string, groupIDs []string, token string) errors.SDKError

	// RemoveChildren removes children groups from a group.
	//
	// example:
	//  ctx := context.Background()
	//  groupIDs := []string{"groupID1", "groupID2"}
	//  err := sdk.RemoveChildren(ctx, "groupID", "domainID", groupIDs, "token")
	//  fmt.Println(err)
	RemoveChildren(ctx context.Context, id, domainID string, groupIDs []string, token string) errors.SDKError

	// RemoveAllChildren removes all children groups from a group.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveAllChildren(ctx, "groupID", "domainID", "token")
	//  fmt.Println(err)
	RemoveAllChildren(ctx context.Context, id, domainID, token string) errors.SDKError

	// Children returns page of children groups.
	//
	// example:
	//  ctx := context.Background()
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//  }
	//  groups, _ := sdk.Children(ctx, "groupID", "domainID", pm, "token")
	//  fmt.Println(groups)
	Children(ctx context.Context, id, domainID string, pm PageMetadata, token string) (GroupsPage, errors.SDKError)

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

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

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

	// Hierarchy returns page of groups hierarchy.
	//
	// example:
	//  ctx := context.Background()
	//  pm := sdk.PageMetadata{
	//    Level: 2,
	//    Direction : -1,
	//	  Tree: true,
	//  }
	// groups, _ := sdk.Hierarchy(ctx, "groupID", "domainID", pm, "token")
	// fmt.Println(groups)
	Hierarchy(ctx context.Context, id, domainID string, pm PageMetadata, token string) (GroupsHierarchyPage, errors.SDKError)

	// CreateGroupRole creates new group role and returns its id.
	//
	// example:
	//  ctx := context.Background()
	//  rq := sdk.RoleReq{
	//    RoleName: "My Role",
	//    OptionalActions: []string{"read", "update"},
	//    OptionalMembers: []string{"member_id_1", "member_id_2"},
	//  }
	//  role, _ := sdk.CreateGroupRole(ctx, "groupID", "domainID", rq, "token")
	//  fmt.Println(role)
	CreateGroupRole(ctx context.Context, id, domainID string, rq RoleReq, token string) (Role, errors.SDKError)

	// GroupRoles returns group roles.
	//
	// example:
	//  ctx := context.Background()
	//  pm := sdk.PageMetadata{
	//   Offset: 0,
	//   Limit:  10,
	// }
	//  roles, _ := sdk.GroupRoles(ctx, "groupID", "domainID",pm, "token")
	//  fmt.Println(roles)
	GroupRoles(ctx context.Context, id, domainID string, pm PageMetadata, token string) (RolesPage, errors.SDKError)

	// GroupRole returns group role object by roleID.
	//
	// example:
	//  ctx := context.Background()
	//  role, _ := sdk.GroupRole(ctx, "groupID", "roleID", "domainID", "token")
	//  fmt.Println(role)
	GroupRole(ctx context.Context, id, roleID, domainID, token string) (Role, errors.SDKError)

	// UpdateGroupRole updates existing group role name.
	//
	// example:
	//  ctx := context.Background()
	//  role, _ := sdk.UpdateGroupRole(ctx, "groupID", "roleID", "newName", "domainID", "token")
	//  fmt.Println(role)
	UpdateGroupRole(ctx context.Context, id, roleID, newName, domainID string, token string) (Role, errors.SDKError)

	// DeleteGroupRole deletes a group role with the given groupID and  roleID.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.DeleteGroupRole(ctx, "groupID", "roleID", "domainID", "token")
	//  fmt.Println(err)
	DeleteGroupRole(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

	// AddGroupRoleActions adds actions to a group role.
	//
	// example:
	//  ctx := context.Background()
	//  actions := []string{"read", "update"}
	//  actions, _ := sdk.AddGroupRoleActions(ctx, "groupID", "roleID", "domainID", actions, "token")
	//  fmt.Println(actions)
	AddGroupRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError)

	// GroupRoleActions returns group role actions by roleID.
	//
	// example:
	//  ctx := context.Background()
	//  actions, _ := sdk.GroupRoleActions(ctx, "groupID", "roleID", "domainID", "token")
	//  fmt.Println(actions)
	GroupRoleActions(ctx context.Context, id, roleID, domainID string, token string) ([]string, errors.SDKError)

	// RemoveGroupRoleActions removes actions from a group role.
	//
	// example:
	//  ctx := context.Background()
	//  actions := []string{"read", "update"}
	//  err := sdk.RemoveGroupRoleActions(ctx, "groupID", "roleID", "domainID", actions, "token")
	//  fmt.Println(err)
	RemoveGroupRoleActions(ctx context.Context, id, roleID, domainID string, actions []string, token string) errors.SDKError

	// RemoveAllGroupRoleActions removes all actions from a group role.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveAllGroupRoleActions(ctx, "groupID", "roleID", "domainID", "token")
	//  fmt.Println(err)
	RemoveAllGroupRoleActions(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

	// AddGroupRoleMembers adds members to a group role.
	//
	// example:
	//  ctx := context.Background()
	//  members := []string{"member_id_1", "member_id_2"}
	//  members, _ := sdk.AddGroupRoleMembers(ctx, "groupID", "roleID", "domainID", members, "token")
	//  fmt.Println(members)
	AddGroupRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError)

	// GroupRoleMembers returns group role members by roleID.
	//
	// example:
	// ctx := context.Background()
	// pm := sdk.PageMetadata{
	//   Offset: 0,
	//  Limit:  10,
	// }
	//  members, _ := sdk.GroupRoleMembers(ctx, "groupID", "roleID", "domainID", "token")
	//  fmt.Println(members)
	GroupRoleMembers(ctx context.Context, id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError)

	// RemoveGroupRoleMembers removes members from a group role.
	//
	// example:
	//  ctx := context.Background()
	//  members := []string{"member_id_1", "member_id_2"}
	//  err := sdk.RemoveGroupRoleMembers(ctx, "groupID", "roleID", "domainID", members, "token")
	//  fmt.Println(err)
	RemoveGroupRoleMembers(ctx context.Context, id, roleID, domainID string, members []string, token string) errors.SDKError

	// RemoveAllGroupRoleMembers removes all members from a group role.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveAllGroupRoleMembers(ctx, "groupID", "roleID", "domainID", "token")
	//  fmt.Println(err)
	RemoveAllGroupRoleMembers(ctx context.Context, id, roleID, domainID, token string) errors.SDKError

	// AvailableGroupRoleActions returns available actions for a group role.
	//
	// example:
	//  ctx := context.Background()
	//  actions, _ := sdk.AvailableGroupRoleActions(ctx, "groupID", "token")
	//  fmt.Println(actions)
	AvailableGroupRoleActions(ctx context.Context, id, token string) ([]string, errors.SDKError)

	// ListGroupMembers list all members from all roles in a group .
	//
	// example:
	//	ctx := context.Background()
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//	}
	//  members, _ := sdk.ListGroupMembers(ctx, "group_id","domainID", pm, "token")
	//  fmt.Println(members)
	ListGroupMembers(ctx context.Context, groupID, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)

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

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

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

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

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

	// UpdateChannelTags updates the channel's tags.
	//
	// example:
	//  ctx := context.Background()
	//  channel := sdk.Channel{
	//    ID:   "channelID",
	//    Tags: []string{"tag1", "tag2"},
	//  }
	//  channel, _ := sdk.UpdateChannelTags(ctx, channel, "domainID", "token")
	//  fmt.Println(channel)
	UpdateChannelTags(ctx context.Context, c Channel, domainID, token string) (Channel, errors.SDKError)

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

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

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

	// SetChannelParent sets the parent group of a channel.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.SetChannelParent(ctx, "channelID", "domainID", "groupID", "token")
	//  fmt.Println(err)
	SetChannelParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

	// RemoveChannelParent removes the parent group of a channel.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveChannelParent(ctx, "channelID", "domainID", "groupID", "token")
	//  fmt.Println(err)
	RemoveChannelParent(ctx context.Context, id, domainID, groupID, token string) errors.SDKError

	// Connect bulk connects clients to channels specified by id.
	//
	// example:
	//  ctx := context.Background()
	//  conns := sdk.Connection{
	//    ChannelIDs: []string{"channel_id_1"},
	//    ClientIDs:  []string{"client_id_1"},
	//    Types:   	  []string{"Publish", "Subscribe"},
	//  }
	//  err := sdk.Connect(ctx, conns, "domainID", "token")
	//  fmt.Println(err)
	Connect(ctx context.Context, conn Connection, domainID, token string) errors.SDKError

	// Disconnect
	//
	// example:
	//  ctx := context.Background()
	//  conns := sdk.Connection{
	//    ChannelIDs: []string{"channel_id_1"},
	//    ClientIDs:  []string{"client_id_1"},
	//    Types:   	  []string{"Publish", "Subscribe"},
	//  }
	//  err := sdk.Disconnect(ctx, conns, "domainID", "token")
	//  fmt.Println(err)
	Disconnect(ctx context.Context, conn Connection, domainID, token string) errors.SDKError

	// ConnectClient connects client to specified channel by id.
	//
	// example:
	//  ctx := context.Background()
	//  clientIDs := []string{"client_id_1", "client_id_2"}
	//  err := sdk.ConnectClients(ctx, "channelID", clientIDs, []string{"Publish", "Subscribe"}, "domainID", "token")
	//  fmt.Println(err)
	ConnectClients(ctx context.Context, channelID string, clientIDs, connTypes []string, domainID, token string) errors.SDKError

	// DisconnectClient disconnect client from specified channel by id.
	//
	// example:
	//  ctx := context.Background()
	//  clientIDs := []string{"client_id_1", "client_id_2"}
	//  err := sdk.DisconnectClients(ctx, "channelID", clientIDs, []string{"Publish", "Subscribe"}, "domainID", "token")
	//  fmt.Println(err)
	DisconnectClients(ctx context.Context, channelID string, clientIDs, connTypes []string, domainID, token string) errors.SDKError

	// ListChannelMembers list all members from all roles in a channel .
	//
	// example:
	//	ctx := context.Background()
	//	pm := sdk.PageMetadata{
	//		Offset: 0,
	//		Limit:  10,
	//	}
	//  members, _ := sdk.ListChannelMembers(ctx, "channel_id","domainID", pm, "token")
	//  fmt.Println(members)
	ListChannelMembers(ctx context.Context, channelID, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)

	// SendMessage send message to specified channel.
	//
	// example:
	//  ctx := context.Background()
	//  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(ctx, "domainID", "topic", msg, "clientSecret")
	//  fmt.Println(err)
	SendMessage(ctx context.Context, domainID, topic, msg, secret string) 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)

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

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

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

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

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

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

	// FreezeDomain changes the status of the domain to frozen.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.FreezeDomain(ctx, "domainID", "token")
	//  fmt.Println(err)
	FreezeDomain(ctx context.Context, domainID, token string) errors.SDKError

	// CreateDomainRole creates new domain role and returns its id.
	//
	// example:
	//  ctx := context.Background()
	//  rq := sdk.RoleReq{
	//    RoleName: "My Role",
	//    OptionalActions: []string{"read", "update"},
	//    OptionalMembers: []string{"member_id_1", "member_id_2"},
	//  }
	//  role, _ := sdk.CreateDomainRole(ctx, "domainID", rq, "token")
	//  fmt.Println(role)
	CreateDomainRole(ctx context.Context, id string, rq RoleReq, token string) (Role, errors.SDKError)

	// DomainRoles returns domain roles.
	//
	// example:
	//  ctx := context.Background()
	//  pm := sdk.PageMetadata{
	//   Offset: 0,
	//   Limit:  10,
	// }
	//  roles, _ := sdk.DomainRoles(ctx, "domainID", pm, "token")
	//  fmt.Println(roles)
	DomainRoles(ctx context.Context, id string, pm PageMetadata, token string) (RolesPage, errors.SDKError)

	// DomainRole returns domain role object by roleID.
	//
	// example:
	//  ctx := context.Background()
	//  role, _ := sdk.DomainRole(ctx, "domainID", "roleID", "token")
	//  fmt.Println(role)
	DomainRole(ctx context.Context, id, roleID, token string) (Role, errors.SDKError)

	// UpdateDomainRole updates existing domain role name.
	//
	// example:
	//  ctx := context.Background()
	//  role, _ := sdk.UpdateDomainRole(ctx, "domainID", "roleID", "newName", "token")
	//  fmt.Println(role)
	UpdateDomainRole(ctx context.Context, id, roleID, newName string, token string) (Role, errors.SDKError)

	// DeleteDomainRole deletes a domain role with the given domainID and roleID.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.DeleteDomainRole(ctx, "domainID", "roleID", "token")
	//  fmt.Println(err)
	DeleteDomainRole(ctx context.Context, id, roleID, token string) errors.SDKError

	// AddDomainRoleActions adds actions to a domain role.
	//
	// example:
	//  ctx := context.Background()
	//  actions := []string{"read", "update"}
	//  actions, _ := sdk.AddDomainRoleActions(ctx, "domainID", "roleID", actions, "token")
	//  fmt.Println(actions)
	AddDomainRoleActions(ctx context.Context, id, roleID string, actions []string, token string) ([]string, errors.SDKError)

	// DomainRoleActions returns domain role actions by roleID.
	//
	// example:
	//  ctx := context.Background()
	//  actions, _ := sdk.DomainRoleActions(ctx, "domainID", "roleID", "token")
	//  fmt.Println(actions)
	DomainRoleActions(ctx context.Context, id, roleID string, token string) ([]string, errors.SDKError)

	// RemoveDomainRoleActions removes actions from a domain role.
	//
	// example:
	//  ctx := context.Background()
	//  actions := []string{"read", "update"}
	//  err := sdk.RemoveDomainRoleActions(ctx, "domainID", "roleID", actions, "token")
	//  fmt.Println(err)
	RemoveDomainRoleActions(ctx context.Context, id, roleID string, actions []string, token string) errors.SDKError

	// RemoveAllDomainRoleActions removes all actions from a domain role.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveAllDomainRoleActions(ctx, "domainID", "roleID", "token")
	//  fmt.Println(err)
	RemoveAllDomainRoleActions(ctx context.Context, id, roleID, token string) errors.SDKError

	// AddDomainRoleMembers adds members to a domain role.
	//
	// example:
	//  ctx := context.Background()
	//  members := []string{"member_id_1", "member_id_2"}
	//  members, _ := sdk.AddDomainRoleMembers(ctx, "domainID", "roleID", members, "token")
	//  fmt.Println(members)
	AddDomainRoleMembers(ctx context.Context, id, roleID string, members []string, token string) ([]string, errors.SDKError)

	// DomainRoleMembers returns domain role members by roleID.
	//
	// example:
	//  ctx := context.Background()
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//  }
	//  members, _ := sdk.DomainRoleMembers(ctx, "domainID", "roleID", "token")
	//  fmt.Println(members)
	DomainRoleMembers(ctx context.Context, id, roleID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError)

	// RemoveDomainRoleMembers removes members from a domain role.
	//
	// example:
	//  ctx := context.Background()
	//  members := []string{"member_id_1", "member_id_2"}
	//  err := sdk.RemoveDomainRoleMembers(ctx, "domainID", "roleID", members, "token")
	//  fmt.Println(err)
	RemoveDomainRoleMembers(ctx context.Context, id, roleID string, members []string, token string) errors.SDKError

	// RemoveAllDomainRoleMembers removes all members from a domain role.
	//
	// example:
	//  ctx := context.Background()
	//  err := sdk.RemoveAllDomainRoleMembers(ctx, "domainID", "roleID", "token")
	//  fmt.Println(err)
	RemoveAllDomainRoleMembers(ctx context.Context, id, roleID, token string) errors.SDKError

	// AvailableDomainRoleActions returns available actions for a domain role.
	//
	// example:
	//  ctx := context.Background()
	//  actions, _ := sdk.AvailableDomainRoleActions(ctx, "token")
	//  fmt.Println(actions)
	AvailableDomainRoleActions(ctx context.Context, token string) ([]string, errors.SDKError)

	// ListDomainUsers returns list of users for the given domain ID and filters.
	//
	// example:
	//  ctx := context.Background()
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//  }
	//  members, _ := sdk.ListDomainMembers(ctx, "domain_id", pm, "token")
	//  fmt.Println(members)
	ListDomainMembers(ctx context.Context, domainID string, pm PageMetadata, token string) (EntityMembersPage, errors.SDKError)

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

	// Invitations returns a list of invitations.
	//
	// For example:
	//  ctx := context.Background()
	//  invitations, _ := sdk.Invitations(ctx, PageMetadata{Offset: 0, Limit: 10}, "token")
	//  fmt.Println(invitations)
	Invitations(ctx context.Context, 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:
	//  ctx := context.Background()
	//  err := sdk.AcceptInvitation(ctx, "domainID", "token")
	//  fmt.Println(err)
	AcceptInvitation(ctx context.Context, domainID, token string) (err error)

	// RejectInvitation rejects an invitation.
	//
	// For example:
	//  ctx := context.Background()
	//  err := sdk.RejectInvitation(ctx, "domainID", "token")
	//  fmt.Println(err)
	RejectInvitation(ctx context.Context, domainID, token string) (err error)

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

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

	// DomainInvitations returns a list of invitations for a specific domain.
	// For example:
	//  ctx := context.Background()
	//  pm := sdk.PageMetadata{
	//    Offset: 0,
	//    Limit:  10,
	//  }
	//  invitations, _ := sdk.DomainInvitations(ctx, "domainID", pm, "token")
	//  fmt.Println(invitations)
	DomainInvitations(ctx context.Context, pm PageMetadata, token, domainID string) (invitations InvitationPage, err error)
}

SDK contains SuperMQ API.

func NewSDK

func NewSDK(conf Config) SDK

NewSDK returns new supermq SDK instance.

type TagsQuery added in v0.19.0

type TagsQuery struct {
	Elements []string
	Operator Operator
}

func ToTagsQuery added in v0.19.0

func ToTagsQuery(s string) TagsQuery

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"`
	PrivateMetadata Metadata    `json:"private_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"`
	AuthProvider    string      `json:"auth_provider,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