Documentation
¶
Index ¶
- Constants
- Variables
- type Cert
- type Config
- type ContentType
- type Group
- type GroupMember
- type GroupMembersPage
- type GroupsPage
- type Key
- type KeyRes
- type Member
- type MembersPage
- type MessagesPage
- type Metadata
- type Org
- type OrgMember
- type OrgsPage
- type PageMetadata
- type Profile
- type ProfilesPage
- type SDK
- type Thing
- type ThingsPage
- type User
- type UserPasswordReq
- type UsersPage
- type Webhook
- type Webhooks
Constants ¶
const ( // LoginKey is temporary User key received on successfull login. LoginKey uint32 = iota // RecoveryKey represents a key for resseting password. RecoveryKey // APIKey enables the one to act on behalf of the user. APIKey )
Variables ¶
var ( // ErrFailedCreation indicates that entity creation failed. ErrFailedCreation = errors.New("failed to create entity") // 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") // ErrFailedPublish indicates that publishing message failed. ErrFailedPublish = errors.New("failed to publish message") // ErrFailedRead indicates that read messages failed. ErrFailedRead = errors.New("failed to read messages") // ErrInvalidContentType indicates that non-existent message content type // was passed. ErrInvalidContentType = errors.New("Unknown Content Type") // ErrFetchHealth indicates that fetching of health check failed. ErrFetchHealth = errors.New("failed to fetch health check") // ErrCerts indicates error fetching certificates. ErrCerts = errors.New("failed to fetch certs data") // ErrCertsRemove indicates failure while cleaning up from the Certs service. ErrCertsRemove = errors.New("failed to remove certificate") // ErrMemberAdd failed to add member to a group. ErrMemberAdd = errors.New("failed to add member to group") )
Functions ¶
This section is empty.
Types ¶
type Cert ¶
type Cert struct { CACert string `json:"issuing_ca,omitempty"` ClientKey string `json:"client_key,omitempty"` ClientCert string `json:"client_cert,omitempty"` }
Cert represents certs data.
type Config ¶
type Config struct { AuthURL string BootstrapURL string CertsURL string HTTPAdapterURL string ReaderURL string ThingsURL string WebhooksURL string UsersURL string MsgContentType ContentType TLSVerification bool }
Config contains sdk configuration parameters.
type ContentType ¶
type ContentType string
ContentType represents all possible content types.
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" )
type Group ¶
type Group struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` OwnerID string `json:"owner_id,omitempty"` OrgID string `json:"org_id,omitempty"` Description string `json:"description,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` }
Group represents mainflux users group.
type GroupMember ¶
type GroupMember struct { ID string `json:"id,omitempty"` Role string `json:"role,omitempty"` Email string `json:"email,omitempty"` }
GroupMember represents mainflux Group Member.
type GroupMembersPage ¶ added in v0.24.0
type GroupMembersPage struct { GroupMembers []GroupMember `json:"group_members"` // contains filtered or unexported fields }
GroupMembersPage contains a list of roles for a certain group with proper metadata.
type GroupsPage ¶
type GroupsPage struct { Groups []Group `json:"groups"` // contains filtered or unexported fields }
GroupsPage contains list of groups in a page with proper metadata.
type KeyRes ¶
type MembersPage ¶
type MembersPage struct { Members []Member `json:"members"` // contains filtered or unexported fields }
MembersPage contains list of members in a page with proper metadata.
type MessagesPage ¶
type MessagesPage struct { Messages []senml.Message `json:"messages,omitempty"` // contains filtered or unexported fields }
MessagesPage contains list of messages in a page with proper metadata.
type 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 map[string]interface{} `json:"metadata,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` }
Org represents mainflux org.
type OrgMember ¶
type OrgMember 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"` }
OrgMember represents mainflux Org Member.
type OrgsPage ¶
type OrgsPage struct { Orgs []Org `json:"orgs"` // contains filtered or unexported fields }
OrgsPage contains list of orgs in a page with proper metadata.
type PageMetadata ¶
type PageMetadata struct { Total uint64 `json:"total"` Offset uint64 `json:"offset"` Limit uint64 `json:"limit"` Subtopic string `json:"subtopic,omitempty"` Format string `json:"format,omitempty"` Level uint64 `json:"level,omitempty"` Email string `json:"email,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
type Profile ¶ added in v0.24.0
type Profile struct { ID string `json:"id,omitempty"` GroupID string `json:"group_id,omitempty"` Name string `json:"name,omitempty"` Config map[string]interface{} `json:"config,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
Profile represents mainflux profile.
type ProfilesPage ¶ added in v0.24.0
type ProfilesPage struct { Profiles []Profile `json:"profiles"` // contains filtered or unexported fields }
ProfilesPage contains list of profiles in a page with proper metadata.
type SDK ¶
type SDK interface { // CreateUser creates mainflux user. CreateUser(token string, user User) (string, error) // User returns user object by id. User(token, id string) (User, error) // Users returns list of users. Users(token string, pm PageMetadata) (UsersPage, error) // CreateToken receives credentials and returns user token. CreateToken(user User) (string, error) // RegisterUser registers mainflux user. RegisterUser(user User) (string, error) // UpdateUser updates existing user. UpdateUser(user User, token string) error // UpdatePassword updates user password. UpdatePassword(oldPass, newPass, token string) error // CreateThing registers new thing and returns its id. CreateThing(thing Thing, groupID, token string) (string, error) // CreateThings registers new things and returns their ids. CreateThings(things []Thing, groupID, token string) ([]Thing, error) // Things returns page of things. Things(token string, pm PageMetadata) (ThingsPage, error) // ThingsByProfile returns page of things assigned to the specified profile. ThingsByProfile(profileID, token string, offset, limit uint64) (ThingsPage, error) // Thing returns thing object by id. Thing(id, token string) (Thing, error) // MetadataByKey retrieves metadata about the thing identified by the given key. MetadataByKey(thingKey string) (Metadata, error) // UpdateThing updates existing thing. UpdateThing(thing Thing, thingID, token string) error // DeleteThing removes existing thing. DeleteThing(id, token string) error // DeleteThings removes existing things. DeleteThings(ids []string, token string) error // IdentifyThing validates thing's key and returns its ID IdentifyThing(key string) (string, error) // CreateGroup creates new group and returns its id. CreateGroup(group Group, orgID, token string) (string, error) // DeleteGroup deletes users group. DeleteGroup(id, token string) error // DeleteGroups delete users groups. DeleteGroups(ids []string, token string) error // Groups returns page of groups. Groups(meta PageMetadata, token string) (GroupsPage, error) // Group returns users group object by id. Group(id, token string) (Group, error) // ListThingsByGroup lists things that are members of specified group. ListThingsByGroup(groupID, token string, offset, limit uint64) (ThingsPage, error) // ViewGroupByThing retrieves a group that the specified thing is a member of. ViewGroupByThing(thingID, token string) (Group, error) // UpdateGroup updates existing group. UpdateGroup(group Group, groupID, token string) error // CreateProfile creates new profile and returns its id. CreateProfile(profile Profile, groupID, token string) (string, error) // CreateProfiles registers new profiles and returns their ids. CreateProfiles(profiles []Profile, groupID, token string) ([]Profile, error) // Profiles returns page of profiles. Profiles(token string, pm PageMetadata) (ProfilesPage, error) // ViewProfileByThing returns profile that are assigned to specified thing. ViewProfileByThing(thingID, token string) (Profile, error) // Profile returns profile data by id. Profile(id, token string) (Profile, error) // UpdateProfile updates existing profile. UpdateProfile(profile Profile, profileID, token string) error // DeleteProfile removes existing profile. DeleteProfile(id, token string) error // DeleteProfiles removes existing profile. DeleteProfiles(ids []string, token string) error // ListProfilesByGroup lists profiles that are members of specified group. ListProfilesByGroup(groupID, token string, offset, limit uint64) (ProfilesPage, error) // ViewGroupByProfile retrieves a group that the specified profile is a member of. ViewGroupByProfile(profileID, token string) (Group, error) // CreateRolesByGroup creates new roles by group. CreateRolesByGroup(roles []GroupMember, groupID, token string) error // UpdateRolesByGroup updates existing group roles. UpdateRolesByGroup(roles []GroupMember, groupID, token string) error // RemoveRolesByGroup removes existing group roles. RemoveRolesByGroup(ids []string, groupID, token string) error // ListRolesByGroup lists roles that are specified for a certain group. ListRolesByGroup(groupID, token string, offset, limit uint64) (GroupMembersPage, error) // CreateOrg registers new org. CreateOrg(org Org, token string) error // Org returns org data by id. Org(id, token string) (Org, error) // UpdateOrg updates existing org. UpdateOrg(o Org, orgID, token string) error // DeleteOrg removes existing org. DeleteOrg(id, token string) error // Orgs returns page of orgs. Orgs(meta PageMetadata, token string) (OrgsPage, error) // ViewMember retrieves a member belonging to the specified org. ViewMember(orgID, memberID, token string) (Member, error) // AssignMembers assigns a members to the specified org. AssignMembers(om []OrgMember, orgID, token string) error // UnassignMembers unassigns a members from the specified org. UnassignMembers(token, orgID string, memberIDs ...string) error // UpdateMembers updates existing member. UpdateMembers(members []OrgMember, orgID, token string) error // ListMembersByOrg lists members who belong to a specified org. ListMembersByOrg(orgID, token string, offset, limit uint64) (MembersPage, error) // ListOrgsByMember lists orgs to which the specified member belongs. ListOrgsByMember(memberID, token string, offset, limit uint64) (OrgsPage, error) // CreateWebhooks creates new webhooks. CreateWebhooks(whs []Webhook, groupID, token string) ([]Webhook, error) // ListWebhooksByGroup lists webhooks who belong to a specified group. ListWebhooksByGroup(groupID, token string) (Webhooks, error) // Webhook returns webhook data by id. Webhook(webhookID, token string) (Webhook, error) // UpdateWebhook updates existing webhook. UpdateWebhook(wh Webhook, webhookID, token string) error // DeleteWebhooks removes existing webhooks. DeleteWebhooks(ids []string, token string) error // SendMessage send message. SendMessage(subtopic, msg, token string) error // ReadMessages read messages. ReadMessages(pm PageMetadata, token string) (map[string]interface{}, error) // SetContentType sets message content type. SetContentType(ct ContentType) error // Health returns things service health check. Health() (mainflux.HealthInfo, error) // IssueCert issues a certificate for a thing required for mtls. IssueCert(thingID string, keyBits int, keyType, valid, token string) (Cert, error) // RemoveCert removes a certificate RemoveCert(id, token string) error // RevokeCert revokes certificate with certID for thing with thingID RevokeCert(thingID, certID, token string) error // Issue issues a new key, returning its token value alongside. Issue(token string, duration time.Duration) (KeyRes, error) // Revoke removes the key with the provided ID that is issued by the user identified by the provided key. Revoke(token, id string) error // RetrieveKey retrieves data for the key identified by the provided ID, that is issued by the user identified by the provided key. RetrieveKey(token, id string) (retrieveKeyRes, error) }
SDK contains Mainflux API.
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"` Key string `json:"key,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
Thing represents mainflux thing.
type ThingsPage ¶
type ThingsPage struct { Things []Thing `json:"things"` // contains filtered or unexported fields }
ThingsPage contains list of things in a page with proper metadata.
type User ¶
type User struct { ID string `json:"id,omitempty"` Email string `json:"email,omitempty"` Groups []string `json:"groups,omitempty"` Password string `json:"password,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
User represents mainflux user its credentials.
type UserPasswordReq ¶
type UserPasswordReq struct { OldPassword string `json:"old_password,omitempty"` Password string `json:"password,omitempty"` }
UserPasswordReq contains old and new passwords
type UsersPage ¶
type UsersPage struct { Users []User `json:"users"` // contains filtered or unexported fields }
UsersPage contains list of users in a page with proper metadata.