Overview
SuperMQ operates with several key entities that define the structure and interactions within the system. This document provides an overview of these entities, explaining their attributes and how they interact.
User
A User represents an individual interacting with the system. Each user has a unique Username and Secret. Users can have different roles and permissions, manage clients, and be assigned to domains or groups. This User entity is structured in Go with specific fields:
type User struct {
ID string `json:"id"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Tags []string `json:"tags,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
Status Status `json:"status"` // 0 for enabled, 1 for disabled
Role Role `json:"role"` // 0 for normal user, 1 for admin
ProfilePicture string `json:"profile_picture,omitempty"` // profile picture URL
Credentials Credentials `json:"credentials,omitempty"`
Permissions []string `json:"permissions,omitempty"`
Email string `json:"email,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
UpdatedBy string `json:"updated_by,omitempty"`
}
// Credentials represent user credentials: its
// "username" a user's unique username;
// and "secret" which can be a password or access token.
type Credentials struct {
Username string `json:"username,omitempty"` // username or profile name
Secret string `json:"secret,omitempty"` // password or token
}
User Attributes
IDis a unique identifier for each user. It is a string value.FirstNameis a required field that represents the first name of the user.LastNameis a required field that represents the last name of the user.Emailis a required filed that represents the email address of the user which can be used to log them in.Tagsis an optional field that represents the tags related to the user. It is a slice of string values.Credentialsis a struct that represents the user's authentication details. It contains two fields:UsernameThis is the username of the user, which must be unique.SecretThis is the secret of the user, which can be a password, secret key, or access token.
Metadatais an optional field that is used for customized describing of the user.CreatedAtis a field that represents the time when the user was created. It is atime.Timevalue.UpdatedAtis a field that represents the time when the user was last updated. It is atime.Timevalue.UpdatedByis a field that represents the user who last updated the user.Statusis a field that represents the status for the user. It can be either 1 for enabled or 0 for disabled.Roleis an optional field that represents the role of the user. It can be either 1 for admin or 0 for the user.ProfilePictureis a string url that leads to an image in the database that can be used as the user's profile picture.Permissionsis a list of actions the user is allowed to perform.
The Users Service allows for creating, updating, reading, and deleting Users and Groups. Users can bear multiple permissions that allow them various actions over other services and entities in the platform.
The API endpoint for interacting with users are described in the Users API.
Role
A Role defines a set of permissions that a user can have within the system. Roles allow for fine-grained access control by associating users with actions they are allowed to perform.
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"`
}
Role Attributes
IDis a unique identifier for each role. It is a string value.Nameis a required field representing the name of the role. It is a string value.EntityIDis the ID of the user associated with the role. It is a string value.CreatedByis the ID of the user who created the role. It is a string value.CreatedAtis a field that represents the time when the role was created. It is atime.Timevalue.UpdatedByis an optional field representing the user who last updated the role. It is a string value.UpdatedAtis a field that represents the time when the role was last updated. It is atime.Timevalue.OptionalActionsis an optional list of actions that can be assigned to the role.OptionalMembersis an optional list of members associated with the role.
Group
A Group is a hierarchical structure used to organize clients and channels within a domain. A group entity is structured in Go with these specific fields:
type Group struct {
ID string `json:"id"`
Domain string `json:"domain_id,omitempty"`
Parent string `json:"parent_id,omitempty"`
Name string `json:"name"`
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"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
UpdatedBy string `json:"updated_by,omitempty"`
Status Status `json:"status"`
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"`
}
Group Attributes
IDis a unique identifier for each group. It is a string value.Domainis an optional field that represents the ID of the domain the group belongs to. It is a string value.Parentis an optional field that contains the ID of the parent group. It is a string value.Nameis a required field representing the name of the group. It is a string value.Descriptionis an optional field describing the group’s purpose. It is a string value.Metadatais an optional field that provides additional structured data about the group.Levelis an optional field that represents the depth of the group within the hierarchy. It is an integer value. Root node is level 1.Pathis an optional field representing the full hierarchical path from the root to this group. It is a string value consisting of group IDs. Paths are unique per domain.Childrenis an optional field representing sub-groups contained within this group.CreatedAtis a field that represents the time when the group was created. It is atime.Timevalue.UpdatedAtis a field that represents the time when the group was last updated. It is atime.Timevalue.UpdatedByis an optional field representing the user who last updated the group. It is a string value.Statusis a field that represents whether the group is enabled or disabled.RoleIDis an optional field representing the role ID associated with the group. It is a string value.RoleNameis an optional field representing the role name associated with the group. It is a string value.Actionsis an optional list of actions allowed on the group.AccessTypeis an optional field defining a group's reach. It is a string value.AccessProviderIdis an optional field representing the ID of the entity providing access to the group. It is a string value.AccessProviderRoleIdis an optional field representing the role ID assigned by the access provider. It is a string value.AccessProviderRoleNameis an optional field representing the role name assigned by the access provider. It is a string value.AccessProviderRoleActionsis an optional list of actions assigned by the access provider.
The API endpoint for interacting with groups are described in the groups API.
Client
A Client represents a device or service that connects to channels for communication.
type Client struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Tags []string `json:"tags,omitempty"`
Domain string `json:"domain_id,omitempty"`
ParentGroup string `json:"parent_group_id,omitempty"`
Credentials Credentials `json:"credentials,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 Status `json:"status,omitempty"` // 1 for enabled, 0 for disabled
Identity string `json:"identity,omitempty"`
// Extended
ParentGroupPath string `json:"parent_group_path,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"`
ConnectionTypes []connections.ConnType `json:"connection_types,omitempty"`
}
type Credentials struct {
Identity string `json:"identity,omitempty"` // username or generated login ID
Secret string `json:"secret,omitempty"` // password or token
}
Client Attributes
IDis a unique identifier for each client. It is a string value.Nameis an optional field that represents the name of the client. It is a string value.Tagsis an optional field that represents tags related to the client. It is a slice of string values.Domainis an optional field that represents the ID of the domain to which the client belongs. It is a string value.ParentGroupis an optional field that contains the ID of the group that owns the client. It is a string value.Credentialsis an optional struct representing authentication details for the client, containing:Identityis a unique identifier assigned to the client. It is a string value.Secretis a password, access token, or other authentication mechanism. It is a string value that is always generated upon client creation if not specified.
Metadatais an optional field that provides additional structured data about the client.CreatedAtis a field that represents the time when the client was created. It is atime.Timevalue.UpdatedAtis a field that represents the time when the client was last updated. It is atime.Timevalue.UpdatedByis an optional field that represents the user who last updated the client. It is a string value.Statusis a field that represents whether the client is enabled (1) or disabled (0). It is an integer value.Identityis an optional field that represents a unique identifier assigned to the client. It is a string value.ParentGroupPathis an optional field representing the hierarchical path of the parent group. It is a string value.RoleIDis an optional field representing the role ID assigned to the client. It is a string value.RoleNameis an optional field representing the role name assigned to the client. It is a string value.Actionsis an optional list of actions that the client is allowed to perform.AccessTypeis an optional field defining how access is controlled. It is a string value.AccessProviderIdis an optional field representing the ID of the entity providing access to the client. It is a string value.AccessProviderRoleIdis an optional field representing the role ID assigned by the access provider. It is a string value.AccessProviderRoleNameis an optional field representing the role name assigned by the access provider. It is a string value.AccessProviderRoleActionsis an optional list of actions assigned by the access provider.ConnectionTypesis an optional field representing different connection protocols the client can use. It is a slice of connection types.
Hence any phsical device with an embeded system can be handed a unique key (secret) that will be used as a token during publishing and subscribing to a channel can be classified as a client.
The API endpoint for interacting with clients are described in the clients API.
Channel
A Channel is a message conduit between clients connected to it. It serves as a message topic that can be consumed by all of the clients connected to it. Clients can publish or subscribe to the Channel.
type Channel struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Tags []string `json:"tags,omitempty"`
ParentGroup string `json:"parent_group_id,omitempty"`
Domain string `json:"domain_id,omitempty"`
Metadata clients.Metadata `json:"metadata,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
UpdatedBy string `json:"updated_by,omitempty"`
Status clients.Status `json:"status,omitempty"` // 1 for enabled, 0 for disabled
// Extended
ParentGroupPath string `json:"parent_group_path,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"`
ConnectionTypes []connections.ConnType `json:"connection_types,omitempty"`
}
Channel Attributes
IDis a unique identifier for each channel. It is a string value.Nameis an optional field that represents the name of the channel. It is a string value.Tagsis an optional field that represents tags related to the channel. It is a slice of string values.ParentGroupis an optional field that contains the ID of the group that owns the channel. It is a string value.Domainis an optional field that represents the ID of the domain under which the channel exists. It is a string value.Metadatais an optional field that provides additional structured data about the channel.CreatedByis an optional field representing the ID of the user who created the channel. It is a string value.CreatedAtis a field that represents the time when the channel was created. It is atime.Timevalue.UpdatedAtis a field that represents the time when the channel was last updated. It is atime.Timevalue.UpdatedByis an optional field that represents the user who last updated the channel. It is a string value.Statusis a field that represents whether the channel is enabled (1) or disabled (0). It is an integer value.ParentGroupPathis an optional field that represents the full hierarchical path of the parent group. It is a string value.RoleIDis an optional field representing the role ID assigned to the channel. It is a string value.RoleNameis an optional field representing the role name assigned to the channel. It is a string value.Actionsis an optional list of actions that can be performed on the channel.AccessTypeis an optional field defining how access to the channel is managed. It is a string value.AccessProviderIdis an optional field representing the ID of the entity providing access to the channel. It is a string value.AccessProviderRoleIdis an optional field representing the role ID assigned by the access provider. It is a string value.AccessProviderRoleNameis an optional field representing the role name assigned by the access provider. It is a string value.AccessProviderRoleActionsis an optional list of actions assigned by the access provider.ConnectionTypesis an optional field representing different connection protocols supported by the channel. It is a slice of connection types.
The API endpoint for interacting with channels are described in the channels API.
Domain
A Domain is a logical grouping that separates different tenants and governs access control.
type Domain struct {
ID string `json:"id"`
Name string `json:"name"`
Metadata Metadata `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
Alias string `json:"alias,omitempty"`
Status Status `json:"status"`
RoleID string `json:"role_id,omitempty"`
RoleName string `json:"role_name,omitempty"`
Actions []string `json:"actions,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedBy string `json:"updated_by,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
Domain Attributes
IDis a unique identifier for each domain. It is a string value.Nameis a required field representing the name of the domain. It is a string value.Metadatais an optional field that provides additional structured data about the domain.Tagsis an optional field that represents tags related to the domain. It is a slice of string values.Aliasis an optional field that represents an alternate identifier for the domain. It is a string value.Statusis a field that represents whether the domain is enabled or disabled.RoleIDis an optional field representing the role ID assigned to the domain. It is a string value.RoleNameis an optional field representing the role name assigned to the domain. It is a string value.Actionsis an optional list of allowed operations within the domain.CreatedByis an optional field representing the user who created the domain. It is a string value.CreatedAtis a field that represents the time when the domain was created. It is atime.Timevalue.UpdatedByis an optional field representing the user who last updated the domain. It is a string value.UpdatedAtis a field that represents the time when the domain was last updated. It is atime.Timevalue.
The API endpoint for interacting with Domains are described in the domains API.