mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00

* Add list channels by thing id endpoint Add list channels by thing id endpoint to things service. Add pagination format and logic. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add fetch channels by thing endpoint Add fetch channels by thing endpoint with pagination. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update list endpoints to contain pagination Update list endpoints to contain pagination metadata. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add tests for two new endpoints Add tests for two new endpoints and update existing ones. Also, remove connected field from channel response. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Fix tests for SDK Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add SDK methods for new endpoints Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update swagger docs for things service Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add error handling to http tests Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Fix response body in http tests Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Remove unused responses from things service Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add test cases to things postgres tests Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add test cases for event sourcing Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
79 lines
2.3 KiB
Go
79 lines
2.3 KiB
Go
//
|
|
// Copyright (c) 2018
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package things
|
|
|
|
// Channel represents a Mainflux "communication group". This group contains the
|
|
// things that can exchange messages between eachother.
|
|
type Channel struct {
|
|
ID string
|
|
Owner string
|
|
Name string
|
|
Metadata string
|
|
}
|
|
|
|
// ChannelsPage contains page related metadata as well as list of channels that
|
|
// belong to this page.
|
|
type ChannelsPage struct {
|
|
PageMetadata
|
|
Channels []Channel
|
|
}
|
|
|
|
// ChannelRepository specifies a channel persistence API.
|
|
type ChannelRepository interface {
|
|
// Save persists the channel. Successful operation is indicated by unique
|
|
// identifier accompanied by nil error response. A non-nil error is
|
|
// returned to indicate operation failure.
|
|
Save(Channel) (string, error)
|
|
|
|
// Update performs an update to the existing channel. A non-nil error is
|
|
// returned to indicate operation failure.
|
|
Update(Channel) error
|
|
|
|
// RetrieveByID retrieves the channel having the provided identifier, that is owned
|
|
// by the specified user.
|
|
RetrieveByID(string, string) (Channel, error)
|
|
|
|
// RetrieveAll retrieves the subset of channels owned by the specified user.
|
|
RetrieveAll(string, uint64, uint64) ChannelsPage
|
|
|
|
// RetrieveByThing retrieves the subset of channels owned by the specified
|
|
// user and have specified thing connected to them.
|
|
RetrieveByThing(string, string, uint64, uint64) ChannelsPage
|
|
|
|
// Remove removes the channel having the provided identifier, that is owned
|
|
// by the specified user.
|
|
Remove(string, string) error
|
|
|
|
// Connect adds thing to the channel's list of connected things.
|
|
Connect(string, string, string) error
|
|
|
|
// Disconnect removes thing from the channel's list of connected
|
|
// things.
|
|
Disconnect(string, string, string) error
|
|
|
|
// HasThing determines whether the thing with the provided access key, is
|
|
// "connected" to the specified channel. If that's the case, it returns
|
|
// thing's ID.
|
|
HasThing(string, string) (string, error)
|
|
}
|
|
|
|
// ChannelCache contains channel-thing connection caching interface.
|
|
type ChannelCache interface {
|
|
// Connect channel thing connection.
|
|
Connect(string, string) error
|
|
|
|
// HasThing checks if thing is connected to channel.
|
|
HasThing(string, string) bool
|
|
|
|
// Disconnects thing from channel.
|
|
Disconnect(string, string) error
|
|
|
|
// Removes channel from cache.
|
|
Remove(string) error
|
|
}
|