Documentation
¶
Index ¶
- Constants
- type AuthClient
- type AuthzReq
- type Condition
- type Group
- type GroupInvite
- type GroupMembership
- type GroupMembershipsPage
- type GroupPage
- type Identity
- type JSONMessagesPage
- type JSONPageMetadata
- type Key
- type KeysPage
- type Message
- type MessagesPage
- type Metadata
- type Org
- type OrgAccessReq
- type OrgInvite
- type OrgInvitesPage
- type OrgMembership
- type OrgMembershipsPage
- type OrgsPage
- type PlatformInvite
- type PlatformInvitesPage
- type Profile
- type ProfileConfig
- type ProfilesPage
- type PubConfigInfo
- type ReadersClient
- type RuleInfo
- type SenMLMessagesPage
- type SenMLPageMetadata
- type Thing
- type ThingAccessReq
- type ThingCommandReq
- type ThingGroupCommandReq
- type ThingKey
- type ThingsClient
- type ThingsPage
- type Transformer
- type User
- type UserAccessReq
- type UsersClient
- type UsersPage
- type UsersPageMetadata
Constants ¶
const ( // AlarmOriginRule indicates an alarm was triggered by a rule. AlarmOriginRule = "rule" // AlarmOriginScript indicates an alarm was triggered by a Lua script. AlarmOriginScript = "script" )
const ( RootSub = "root" OrgSub = "org" )
Subject type constants for authorization.
const ( OrgAdmin = "admin" OrgOwner = "owner" OrgEditor = "editor" OrgViewer = "viewer" )
Org role constants.
const ( // RoleRootAdmin is the super admin role. RoleRootAdmin = "root" // RoleAdmin is the admin role. RoleAdmin = "admin" )
Platform role constants.
const ( LoginKey uint32 = iota RecoveryKey APIKey )
Key type constants.
const ( KeyTypeInternal = "internal" KeyTypeExternal = "external" )
Thing key type constants.
const ( GroupViewer = "viewer" GroupEditor = "editor" GroupAdmin = "admin" GroupOwner = "owner" )
Group role constants.
const ( EnabledStatusKey = "enabled" DisabledStatusKey = "disabled" AllStatusKey = "all" )
Status key constants for user filtering.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthClient ¶ added in v0.40.0
type AuthClient interface {
// Issue issues a token for the given id, email and key type.
Issue(ctx context.Context, id, email string, keyType uint32) (string, error)
// Identify validates the token and returns the identity.
Identify(ctx context.Context, token string) (Identity, error)
// Authorize checks if the subject is authorized to perform the action on the object.
Authorize(ctx context.Context, ar AuthzReq) error
// GetOwnerIDByOrg returns the owner ID of the organization.
GetOwnerIDByOrg(ctx context.Context, orgID string) (string, error)
// AssignRole assigns a role to a user.
AssignRole(ctx context.Context, id, role string) error
// RetrieveRole retrieves the role for a user.
RetrieveRole(ctx context.Context, id string) (string, error)
// CreateDormantOrgInvite creates a dormant org invite.
CreateDormantOrgInvite(ctx context.Context, token, orgID, inviteeRole, platformInviteID string, groupInvites []GroupInvite) error
// ActivateOrgInvite activates an org invite.
ActivateOrgInvite(ctx context.Context, platformInviteID, userID, redirectPath string) error
// GetDormantOrgInviteByPlatformInvite retrieves a dormant org invite by platform invite ID.
GetDormantOrgInviteByPlatformInvite(ctx context.Context, platformInviteID string) (OrgInvite, error)
// ViewOrg retrieves organization details.
ViewOrg(ctx context.Context, token, orgID string) (Org, error)
}
type Condition ¶ added in v0.40.0
type Condition struct {
Field string `json:"field"`
Comparator string `json:"comparator"`
Threshold *float64 `json:"threshold"`
}
Condition represents a single evaluatable condition used in rules and recorded on alarms.
type Group ¶
type Group struct {
ID string `json:"id,omitempty"`
OrgID string `json:"org_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Group represents group information.
type GroupInvite ¶
type GroupInvite struct {
GroupID string `json:"group_id,omitempty"`
MemberRole string `json:"member_role,omitempty"`
}
GroupInvite represents a group membership invite.
type GroupMembership ¶
type GroupMembership struct {
GroupID string `json:"group_id,omitempty"`
MemberID string `json:"member_id,omitempty"`
Email string `json:"email,omitempty"`
Role string `json:"role,omitempty"`
}
GroupMembership represents a group membership.
type GroupMembershipsPage ¶
type GroupMembershipsPage struct {
Total uint64 `json:"total"`
GroupMemberships []GroupMembership `json:"group_memberships"`
}
GroupMembershipsPage contains page metadata and list of group memberships.
type JSONMessagesPage ¶
type JSONMessagesPage struct {
JSONPageMetadata
MessagesPage
}
JSONMessagesPage contains a page of JSON messages.
type JSONPageMetadata ¶
type JSONPageMetadata struct {
Offset uint64 `json:"offset"`
Limit uint64 `json:"limit"`
Subtopic string `json:"subtopic,omitempty"`
Publisher string `json:"publisher,omitempty"`
Protocol string `json:"protocol,omitempty"`
From int64 `json:"from,omitempty"`
To int64 `json:"to,omitempty"`
Filter string `json:"filter,omitempty"`
AggInterval string `json:"agg_interval,omitempty"`
AggValue uint64 `json:"agg_value,omitempty"`
AggType string `json:"agg_type,omitempty"`
AggFields []string `json:"agg_fields,omitempty"`
Dir string `json:"dir,omitempty"`
}
JSONPageMetadata represents the parameters used to create database queries.
type Key ¶
type Key struct {
ID string `json:"id,omitempty"`
Type uint32 `json:"type,omitempty"`
IssuerID string `json:"issuer_id,omitempty"`
Subject string `json:"subject,omitempty"`
IssuedAt time.Time `json:"issued_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
}
Key represents API key.
type MessagesPage ¶
MessagesPage contains a page of messages.
type Org ¶
type Org struct {
ID string `json:"id,omitempty"`
OwnerID string `json:"owner_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
Org represents org information.
type OrgAccessReq ¶
OrgAccessReq represents an org access request.
type OrgInvite ¶
type OrgInvite struct {
ID string `json:"id,omitempty"`
OrgID string `json:"org_id,omitempty"`
OrgName string `json:"org_name,omitempty"`
InviteeRole string `json:"invitee_role,omitempty"`
GroupInvites []GroupInvite `json:"group_invites,omitempty"`
InviteeID string `json:"invitee_id,omitempty"`
InviteeEmail string `json:"invitee_email,omitempty"`
InviterID string `json:"inviter_id,omitempty"`
InviterEmail string `json:"inviter_email,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
State string `json:"state,omitempty"`
}
OrgInvite represents org invite information.
type OrgInvitesPage ¶
OrgInvitesPage contains page metadata and list of org invites.
type OrgMembership ¶
type OrgMembership struct {
MemberID string `json:"member_id,omitempty"`
OrgID string `json:"org_id,omitempty"`
Role string `json:"role,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Email string `json:"email,omitempty"`
}
OrgMembership represents org membership information.
type OrgMembershipsPage ¶
type OrgMembershipsPage struct {
Total uint64 `json:"total"`
OrgMemberships []OrgMembership `json:"org_memberships"`
}
OrgMembershipsPage contains page metadata and list of org memberships.
type PlatformInvite ¶
type PlatformInvite struct {
ID string `json:"id,omitempty"`
InviteeEmail string `json:"invitee_email,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
State string `json:"state,omitempty"`
OrgInvite *OrgInvite `json:"org_invite"`
}
PlatformInvite represents platform invite information.
type PlatformInvitesPage ¶
type PlatformInvitesPage struct {
Total uint64 `json:"total"`
Invites []PlatformInvite `json:"invites"`
}
PlatformInvitesPage contains page metadata and list of platform invites.
type Profile ¶
type Profile struct {
ID string `json:"id,omitempty"`
GroupID string `json:"group_id,omitempty"`
Name string `json:"name,omitempty"`
Config *ProfileConfig `json:"config,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
}
Profile represents a communication group (things that can exchange messages).
type ProfileConfig ¶ added in v0.40.0
type ProfileConfig struct {
ContentType string `json:"content_type"`
Transformer Transformer `json:"transformer"`
}
ProfileConfig represents profile configuration.
type ProfilesPage ¶
ProfilesPage contains page metadata and list of profiles.
type PubConfigInfo ¶
type PubConfigInfo struct {
PublisherID string
ProfileConfig *ProfileConfig
}
PubConfigInfo represents publisher config from GetPubConfigByKey.
type ReadersClient ¶ added in v0.40.0
type ReadersClient interface {
ListJSONMessages(ctx context.Context, key ThingKey, pm JSONPageMetadata) (JSONMessagesPage, error)
ListSenMLMessages(ctx context.Context, key ThingKey, pm SenMLPageMetadata) (SenMLMessagesPage, error)
}
ReadersClient specifies the API for querying messages from the readers service via gRPC.
type RuleInfo ¶ added in v0.40.0
type RuleInfo struct {
Conditions []Condition `json:"conditions"`
Operator string `json:"operator,omitempty"`
}
RuleInfo captures the evaluation logic of the rule that triggered an alarm.
type SenMLMessagesPage ¶
type SenMLMessagesPage struct {
SenMLPageMetadata
MessagesPage
}
SenMLMessagesPage contains a page of SenML messages.
type SenMLPageMetadata ¶
type SenMLPageMetadata struct {
Offset uint64 `json:"offset"`
Limit uint64 `json:"limit"`
Subtopic string `json:"subtopic,omitempty"`
Publisher string `json:"publisher,omitempty"`
Protocol string `json:"protocol,omitempty"`
Name string `json:"name,omitempty"`
Value float64 `json:"v,omitempty"`
Comparator string `json:"comparator,omitempty"`
BoolValue bool `json:"vb,omitempty"`
StringValue string `json:"vs,omitempty"`
DataValue string `json:"vd,omitempty"`
From int64 `json:"from,omitempty"`
To int64 `json:"to,omitempty"`
AggInterval string `json:"agg_interval,omitempty"`
AggValue uint64 `json:"agg_value,omitempty"`
AggType string `json:"agg_type,omitempty"`
AggFields []string `json:"agg_fields,omitempty"`
Dir string `json:"dir,omitempty"`
}
SenMLPageMetadata represents the parameters used to create database queries.
type Thing ¶
type Thing struct {
ID string `json:"id,omitempty"`
GroupID string `json:"group_id,omitempty"`
ProfileID string `json:"profile_id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Key string `json:"key,omitempty"`
ExternalKey string `json:"external_key,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
}
Thing represents a Mainflux thing. Each thing is owned by one user, and it is assigned with the unique identifier and (temporary) access key.
type ThingAccessReq ¶
ThingAccessReq represents a thing access request.
type ThingCommandReq ¶
ThingCommandReq represents a request to authorize an inter-thing command.
type ThingGroupCommandReq ¶
ThingGroupCommandReq represents a request to authorize a thing group command.
type ThingsClient ¶ added in v0.40.0
type ThingsClient interface {
GetPubConfigByKey(ctx context.Context, key ThingKey) (PubConfigInfo, error)
GetConfigByThing(ctx context.Context, thingID string) (*ProfileConfig, error)
CanUserAccessThing(ctx context.Context, ar UserAccessReq) error
CanUserAccessProfile(ctx context.Context, ar UserAccessReq) error
CanUserAccessGroup(ctx context.Context, ar UserAccessReq) error
CanThingAccessGroup(ctx context.Context, ar ThingAccessReq) error
CanThingCommand(ctx context.Context, req ThingCommandReq) error
CanThingGroupCommand(ctx context.Context, req ThingGroupCommandReq) error
Identify(ctx context.Context, key ThingKey) (string, error)
GetGroupIDByThing(ctx context.Context, thingID string) (string, error)
GetGroupIDByProfile(ctx context.Context, profileID string) (string, error)
GetGroupIDsByOrg(ctx context.Context, ar OrgAccessReq) ([]string, error)
GetThingIDsByProfile(ctx context.Context, profileID string) ([]string, error)
CreateGroupMemberships(ctx context.Context, memberships ...GroupMembership) error
GetGroup(ctx context.Context, groupID string) (Group, error)
GetKeyByThingID(ctx context.Context, thingID string) (ThingKey, error)
}
type ThingsPage ¶
ThingsPage contains page related metadata as well as list of things that belong to this page.
type Transformer ¶
type Transformer struct {
DataFilters []string `json:"data_filters"`
DataField string `json:"data_field"`
TimeField string `json:"time_field"`
TimeFormat string `json:"time_format"`
TimeLocation string `json:"time_location"`
}
Transformer represents message transformation config.
type User ¶
type User struct {
ID string `json:"id,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
Status string `json:"status,omitempty"`
Role string `json:"role,omitempty"`
}
User represents user account information.
type UserAccessReq ¶
UserAccessReq represents a user access request.
type UsersClient ¶ added in v0.40.0
type UsersClient interface {
// GetUsersByIDs retrieves users by their IDs with optional pagination.
GetUsersByIDs(ctx context.Context, ids []string, pm UsersPageMetadata) (UsersPage, error)
// GetUsersByEmails retrieves users by their email addresses.
GetUsersByEmails(ctx context.Context, emails []string) ([]User, error)
}
type UsersPageMetadata ¶ added in v0.40.0
type UsersPageMetadata struct {
Total uint64 `json:"total,omitempty"`
Offset uint64 `json:"offset,omitempty"`
Limit uint64 `json:"limit,omitempty"`
Order string `json:"order,omitempty"`
Dir string `json:"dir,omitempty"`
Email string `json:"email,omitempty"`
Status string `json:"status,omitempty"`
State string `json:"state,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
}
PageMetadata contains page metadata that helps navigation.